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
Using the Template Tag requires PHP knowledge.
If you aren’t familiar with PHP, it’s recommended to use the Shortcode.

The Basics

The WPGetAPI plugin creates a new function (or template tag), which at it’s simplest, looks like this:

wpgetapi_endpoint( 'myapi', 'myendpoint' );

Adding this template tag to one of your theme files (or by using a code snippet plugin) will call the API and the endpoint that you set within the first 2 parameters.

In the above example, it would call the API with the Unique ID of ‘myapi’ and the endpoint with the ID of ‘myendpoint’

Results Format

Because the template tag is PHP code, you will most likely want the Results Format set to PHP array data within the endpoint settings.

Using debug mode

The simplest way to test out the call to your endpoint is to copy the template tag from the top of your endpoint page and paste it wherever you need it in your theme file.

You should assign a variable to it, set the debug argument to true and then echo the variable, like shown below:

$data = wpgetapi_endpoint( 'quote', 'random', array( 'debug' => true ) );
echo $data;

This will output a bunch of debugging information to the page like so:

The Data Output section is what the API is actually returning to us, so if this looks good, we can then work with the data however we like.

Working with the data

Looking at the example above, if we simply want to output Robb Stark we would set debug to false and now echoing the ‘name’ key:

$data = wpgetapi_endpoint( 'quote', 'random', array( 'debug' => false ) );
echo $data['character']['name'];

To display the actual quote (the ‘sentence’ key) and the author, we would do something like this:

$data = wpgetapi_endpoint( 'quote', 'random', array( 'debug' => false ) );
echo $data['sentence'];
echo $data['character']['name'];

Going further with HTML

The above examples would not be formatted in a nice way, so we can mix in some HTML like shown below:

<?php
$data = wpgetapi_endpoint( 'quote', 'random', array( 'debug' => false ) );
?>
    <div class="content"><?php echo $data['sentence']; ?></div>
    <div class="author"><?php echo $data['character']['name']; ?></div>
<?php

This will then allow us to style the content and author classes with a little CSS.

We won’t go into a full-blown PHP/HTML/CSS tutorial here, but if you know a little bit of these, then you will be able to see how useful and easy it can be to style up your API content.

Extra Arguments

The PRO plugin adds extra arguments that are available to use alongside the debug argument:

$data = wpgetapi_endpoint( 'myapi', 'myendpoint', 
    array(
        'debug' => false,
        'endpoint_variables' => array(),
        'query_variables' => 'param1=foo,param2=bar',
        'body_variables' => array(),
        'format' => 'html',
        'html_tag' => 'li',
        'html_labels' => false,
        'html_url' => '',
        'html_to_link' => '',
        'img_key' => '',
        'img_prepend' => '',
    ) 
);

The most useful arguments when using the template tag will be the first 4 arguments shown: debug, endpoint_variables, query_variables and body_variables.

 

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.