Will WPGetAPI work with my API?
The short answer is yes, most likely. If your API follows standard REST protocols, then there should be no issue.
Generally when working with API’s, we are either wanting to display data or we are wanting to send data to create or update something through the API.
Regardless of what we are trying to do, the first step is always to connect to the API.
Connecting to the API
WPGetAPI can connect to any REST API if it follows standard REST authentication protocols (including OAuth 2.0 Authorization). Our free plugin can connect using the majority of authentication methods such as API keys, username:password within the body, bearer tokens and more. Our Pro plugin provides the base64 encoded method.
Displaying and formatting data
If the purpose of your API is to display and format some type of data, then there are many different options depending on exactly how you want to display the data and also the size and complexity of your data.
If the data from the API is small and uncomplicated, then WPGetAPI (and possibly in conjunction with the Pro plugin) has you covered and there usually won’t be a need for any code to be written. When there is extremely large and complex data or you need to format it in a complex way, there are still many options but is more likely to require some PHP knowledge and some code written.
Here are some different options for displaying and formatting data, using the free WPGetAPI plugin and also the Pro plugin:
Using the shortcode (easy)
The shortcode will simply display the API data as it is received, without formatting. This is the most basic option.
The shortcode can be extended by using the Pro plugin which provides extra shortcode attributes that allow for more complex formatting and data gathering. Examples of this include being able to retrieve nested data from the API, format the API data as HTML or formatting numbers.
Using the block (easy)
The block will simply display the API data as it is received, without formatting. This is the most basic option just like shortcode.
The block can be extended by using the Pro plugin which provides extra options that allow for more complex formatting and data gathering. Examples of this include format the API data as HTML or formatting numbers, set HTML Tag either “div”, “li” or “span”.
Please see our full guide on using the block.
Using the template tag (harder)
For large and complex data, the template tag is the best option but requires some knowledge of PHP. If you are new to PHP, please also see our article on using the template tag without modifying theme files.
Below are a few ways to format and display complex API data:
- Create an image gallery from API data – https://wpgetapi.com/docs/create-image-gallery/
- Create complex HTML tables from API data – https://wpgetapi.com/docs/using-with-wpdatatables/
- Using the wpDataTables you can create complex and sortable tables and complex charts from your API data.
- Create product listings from API data – Our WooCommerce Import plugin allows you to create WooCommerce products from API data
- Create real estate/car/directory listings – Our Custom Listings plugin allows you to create any type of listings website
Creating or updating data
If the purpose of your API is to create a new customer in a CRM or to create some other type of data within the API, then WPGetAPI can usually achieve this in conjunction with our Pro Plugin. The Pro plugin is normally required as you will most likely be wanting to add dynamic/changing data such as user details from a form and only our Pro plugin will handle this type of dynamic data. This can also be tested with the free WPGetAPI plugin by adding static data within the settings.