The API block is a very advanced tool. You should only use it if you understand API requests and cannot get the data you’re looking for elsewhere.

Please note that we only provide support for advanced modules if you have a plan that includes consulting!

This block allows you to query a JSON API, receive back the data, and assign that data to variables.

You can then use those variables elsewhere in other modules.

Please note that it does not support XML – only JSON format can be used!

Also note that you can use {{variable}} format anywhere in the data you enter here. This will (as with all modules) replace the variable in braces with data or output from other modules.

How to Use It

API URL Address: This is the URL or access point that you need to connect to. If the API is public access then this is all you need.

Authentication

Most APIs require authentication so click the “Details” section to add these.

Header JS Object: Most APIs authenticate using header data that contains an API key, username and/or password. Enter these here in JSON format.

Body JS Object: Some APIs require that you POST them data in the body. This input allows you to define the body. Also needs to be in JSON format.

Request Type: This is one of the standard HTTP verbs such as GET or POST.

Get the Data

Once you set everything up click “Refresh Data API” to get some initial data. This is the data we will browse through to select what we actually want.

If this step fails then check the details for connecting to the API!

Once you succeed click “Select / Morph Data”.

In this screen you can do the following:

  • Click the red X or green tick on the left side to select or deselect
  • Select the icon on the right side of each row to show details
  • In details you can enter “Numeral JS Formats”. This allows you to format numbers (eg, to shorten up decimals)

For reference Numeral JS formats are here: http://numeraljs.com

Example format is 0,0.0 which would take a number like 18101.9328366 and output 18,101.93. Ie, that format puts a comma separator for thousands and limits decimals to 2 places.

Once you’re done the variables will be available in other modules labelled as:

apiX.X.data_name (where X is a number and data_name is the name of data field retrieved).


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *