Using the shortcode to display your API data is very easy and there are just 2 required attributes: api_id and endpoint_id.
[wpgetapi_endpoint api_id='your_api_id' endpoint_id='your_endpoint_id' debug='false']
In the example above, you would replace the ‘your_api_id’ and ‘your_endpoint_id’ with the actual id’s that you have setup in the admin area. You can then add the shortcode to any post, page, widget or other area that shortcodes are accepted.
The following shortcode attributes are available:
- api_id – (required) this is the ID of the API as set by you in the Setup page
- endpoint_id – (required) this is the ID of the endpoint as set by you in the API page
- debug – can be set to true or false and will display debug information if set to true
Using the shortcode
Below is what the shortcode looks like pasted into a test page we have set up.You can see we have setup this API in our WordPress backend as shown below.
The debug option is set to false to not show debugging info. Changing false to true will output a bunch of debugging information on your page/post, which can be handy for troubleshooting if you are running into issues with the API call.
The data looks strange
The returned data might look something like the below. This is a JSON string and it would require formatting.
See our docs on how to format JSON data or how to format JSON to HTML.
Extra shortcode attributes in the Pro Plugin
The Pro Plugin adds 12 extra attributes to the shortcode that further enhance its features: