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
Features in this article are available in the PRO Plugin.
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 Gravity Forms data to APIs – view new article. The methods in this article still work perfectly fine, however the newer method is much easier to implement.



Gravity Forms is a hugely popular WordPress forms plugin that allows you to easily create any type of form on your website. WPGetAPI can interact with Gravity Forms to gather the data that is submitted through a form, and then use this data as a variable to send to any external API.

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

This article uses ‘query_variables’ as well as tokens, which are only available in the Pro Plugin.

Method 1 – Using Tokens (no code)

How it works

This method is so simple with Gravity Forms and only has 3 steps. We need to create our form, create our endpoint using tokens, and then add the endpoint shortcode into the form confirmation.

Step 1: Setup Gravity Forms

We have set up our form with a single field called Crypto Pair – this is what we will use to send to our API. The ID of this field is #1, so Gravity Forms names this as input_1 on the front end. This is important for the next step.

Now we just need to add this form into our page using their shortcode.

Gravity Forms send to API

Step 2: Setup the endpoint

We are setting up our endpoint to query the Binance API and get the price of any crypto currency.

Within the Query String fields is where we are using a token to capture the value of ‘input_1’ when the form is submitted.

The token (system:post:input_1) will capture the data from the form’s ‘input_1’ field. So if the user enters ‘DOGEBUSD’ into this field, ‘DOGEBUSD’ will be sent as the value and we will retrieve the current price of DOGEBUSD.

Step 3: Add shortcode to confirmation

Here we simply need to grab the shortcode from the endpoint screen and then past this into the confirmation. We’ve also set the format attribute to html.

Step 4: Add the form and test it

Here is a working version of the form that is making the API call:

Select a coin to get the current price from Binance.
This field is for validation purposes and should be left unchanged.

 


Method 2 – Using query_variables (coding required)

Step 1: Setup Gravity Forms

We have set up our form with a single field called Crypto Pair – this is what we will use to send to our API. The ID of this field is #1, so Gravity Forms names this as input_1 on the front end. This is important for the next step.

Now we just need to add this form into our page using their shortcode.

Gravity Forms send to API

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/ticker/price

Setting up binance api

Step 3: Process the form and get the API data

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 and then the API will send back our data, retrieving the price. We are then modifying the confirmation message of the form to display the price. Very simple and basic.

add_filter( 'gform_confirmation_7', 'wpgetapi_get_current_price_from_binance', 10, 4 );
function wpgetapi_get_current_price_from_binance( $confirmation, $form, $entry, $ajax ) {
 
    // gets the crypto pair that was sent from the form
    $pair = rgar( $entry, '1' );
 	
    // call the binance api and retrieve the 'price' key
	$price = wpgetapi_endpoint( 'binance', 'price', 
		array( 
		    'debug' => false, 
		    'query_variables' => 'symbol=' . $pair, 
		),
		array(
			'price'
		)
	);

	// output our message to the user
	$confirmation = 'Current '. $pair . ' price is ' . $price;

	return $confirmation;
	
}

View the results

Here is a live working example of the form.

Type in any cryptocurrency pair from Binance to get the current price. Examples: ETHBTC, BTCBUSD, BNBBUSD, DOGEBUSD
This field is for validation purposes and should be left unchanged.

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.