Skip to content
  • Why WPGetAPI?
  • Examples
  • Pricing
  • Plugins
    • PRO Plugin
    • API to Posts Plugin
    • OAuth 2.0 Plugin
  • Docs
  • Support
    • Frequently Asked Questions
    • Feature Request
    • Support Ticket
  • account_circle
PRO Plugin
Howdy! How can we help you?
  • Introduction

    • Quick Start
    • Frequently Asked Questions
    • Will this work with my API?
    • Understanding API docs
    • Step by Step Example
  • Setup

    • Setup Page
    • Endpoint Page
    • Parameters - Query String
    • Parameters - Headers
    • Parameters - Body POST
    • Shortcode
    • Template Tag
    • Gutenberg Block
  • Connecting your API

    • API Key in Headers
    • API Key in Query String
    • Authentication & Authorization
  • Output API Data

    • Format API to HTML
    • Format API to HTML Table
    • Format API to Image Gallery
    • Format JSON Data
  • Integrations

    • Send form data to API
    • WPForms to API
    • Gravity Forms to API
    • Contact Form 7 to API
    • WooCommerce to API
    • WooCommerce API Product Sync
    • wpDataTables to API
    • Connect WordPress to OpenAI
    • Connect RapidAPI to WordPress
    • Connect Zoho CRM to WordPress
    • Page Builders (Elementor, DIVI)
    • Formidable Forms to API
    • Elementor Form to API
    • JetFormBuilder to API
    • Fluent Forms to API
    • WS Form to API
    • Ninja Tables to API
    • Easy Digital Downloads(EDD) API Product Sync
    • Ultimate Member Forms to API
  • Tips & Tricks

    • Filters & Action Hooks
    • Code Snippets Plugin
    • Troubleshooting
    • Code Snippets
  • PRO Plugin

    • Installation
    • Actions
    • Tokens
    • Caching
    • Nested data
    • Chaining API calls
    • Dynamic Variables
    • Format API to HTML
    • Call API on user registration
    • Using AJAX to trigger API call
    • Base64 Encoding
    • Licensing
    • Filters & Action Hooks
  • OAuth 2.0 Plugin

    • Installation
    • How it works
    • Grant Type - Client Credentials
    • Grant Type - Authorization Code
    • Licensing
  • API to Posts Plugin

    • Installation
    • Getting Started
    • Multiple Endpoints
    • Mapping Fields
    • Filters & Action Hooks
    • Pagination
You should use the methods in this article if you are wanting to display the API response data to the user. We now have an easier method for sending Contact Form 7 data to APIs – view new article. The methods in this article still work perfectly fine, however the newer method is much easier to implement.

 

Data that is returned from the API can then be displayed as part of the confirmation message – but please note that Contact Form 7 does not allow HTML within their confirmation message, so the resulting message can only ever be simple text.

There are 2 methods that you can use, with Method 1 being the simplest as it does not require any coding.

Method 1 – No Code

How it works

Contact Form 7 has a feature called custom ‘form-tags‘, which look similar to a shortcode and can be placed within your forms.

We’ve built a custom form-tag which allows us to use tokens to capture the data from form fields, without writing a single line of code.

Let’s jump straight into an example.

Step 1: Setup the API & endpoint

We are setting up our API to send some user data to the Ongage API. Take note of the api_id and the endpoint_id shown below within the shortcode and template tag. That is what we use in the form-tag shown in the next step.

Step 2: Add the form-tag

We’ve created a Sign Up form with some text fields and have included our custom [wpgetapi] form-tag.

Step 3: Capture our fields

Now back in our endpoint settings, we can capture the data coming from each field by using tokens.

The token (system:POST:first_name) captures the data from the form’s ‘first_name’ field. So if the user enters ‘Bob’ into this field, ‘Bob’ will be sent as the value.

Essentially, what we setup in the image above will be sent to the API like this:

{
    "email": "[email protected]",
    "first_name": "Bob",
    "last_name": "Smith"
}

The form-tag attributes

The form-tag is placed within your form and follows this format: [wpgetapi api_id|endpoint_id|message_type "keys"]

To use the form-tag, we simply declare it with an opening bracket and then the keyword wpgetapi followed by our attributes.

The attributes are:

  • api_id: the API ID that you wish to use and that you have setup in the API Setup page
  • endpoint_id: change this to the endpoint ID of the endpoint you wish to use
  • message_type: (optional) defaults to ‘none’. What this will do is inject the returned data from the API into the thank you message after the form is submitted.
    • none – will not use the returned data from the API. Uses the message that you set within CF7
    • replace – completely removes the default CF7 message and replaces it with the returned API data
    • append – this appends the API data to the standard CF7 message
    • prepend – this prepends the API data to the standard CF7 message
  • keys – (optional) must be declared with quotation marks. This steps down into the returned API data. It follows the same syntax as the nested data feature.

A complete form tag might look like this: [wpgetapi ongage_signup|signup|append "data,0,timestamp"]


Method 2 – Some Coding

This method requires some PHP coding knowledge.

We will outline the steps that will allow you to integrate Contact Form 7 with WPGetAPI. In our example we are just using a quick test example to connect to the Binance API and retrieve the price of a cryptocurrency pair. Other more suitable uses for this could be something like sending a subscriber email address to your email marketing platform.

Step 1: Setup Contact Form 7

Once you have Contact Form 7 installed, you will need to add a form. Visit the Contact Form 7 docs for help in setting this up – https://contactform7.com/getting-started-with-contact-form-7/

We have set up our form with the following fields:

  • your-name
  • your-email
  • the-value – this is what we will use to send to our API

In the Additional Settings tab we have also added “skip_mail: on” which stops the email being sent (which is default for Contact Form 7 as it is a contact form).

Now we just need to add the shortcode [contact-form-7 id=”7959″ title=”Untitled”] to our page and it will display our form.

Step 2: Setup the Binance API

The settings for our Binance API are shown in the screenshot below and you can see that we are using the endpoint: https://api.binance.com/api/v3/avgPrice

Step 3: Process the form and get the API data

This is a feature of the PRO plugin.

We now need to add the following code into our themes functions.php file. This will basically get our form value, which will be a cryptocurrency pair and then send this as a query variable to the Binance API to retrieve the price. We are then modifying the output of the forms message to give us the price.

// hook into the contact form 7 action upon processing the form
add_action( 'wpcf7_before_send_mail', 'wpgetapi_send_data_to_api', 10, 3 );

function wpgetapi_send_data_to_api( $contact_form, &$abort, $submission ) {

    // Getting user input through the the-value field
    $the_value = $submission->get_posted_data( 'the-value' );

    // call the binance api and retrieve the 'price' key
	$price = wpgetapi_endpoint( 'binance', 'price_of_coin', 
		array( 
		    'debug' => false, 
		    'query_variables' => 'symbol=' . $the_value, 
		),
		array(
			'price'
		)
	);

	// get the form properties
	$properties = $contact_form->get_properties();

	// set the success message
	$properties['messages']['mail_sent_ok'] = 'Current '. $the_value . ' price is ' . $price;
	$contact_form->set_properties($properties);

}

Step 4: View the results

Now it is just a matter of testing our form to see the results, which will be the current live price of a cryptocurrency pair from Binance.

On this page
contact_support

Still not sure?

APIs can be daunting and sometimes downright confusing.

But we are here to help! Our support is amazing and we can assist you with any setup required and ensure your API integrations are a success!

Ask Us Anything

Connect your WordPress website to external APIs without writing a single line of code. Send data from WordPress to your API or display data from your API within WordPress.

Support

  • Documentation
  • Support Ticket
  • Refund Policy
  • Contact Us
  • About Us
  • Affiliates

Articles

  • Quick Start Guide
  • WooCommerce Orders to API
  • WooCommerce API Products Sync
  • Contact Form 7 to API
  • WPForms to API
  • Gravity Forms to API
  • WordPress to RapidAPI

WordPress API Plugins

  • Free WPGetAPI Plugin
  • PRO Plugin
  • API to Posts Plugin Plugin
  • OAuth 2.0 Authorization Plugin

© 2025 WPGetAPI. All Rights Reserved.

"*" indicates required fields

Name*
This field is for validation purposes and should be left unchanged.