Introduction
Not familiar with the concept of Web APIs or need some help constructing a request URL? Start by jumping over to this article for a primer.
An API - Application Programming Interface - is the doorway produced by one piece of software so that other software programs can talk to it. Thanks to cloud computing, the most common API language these days is known as "REST-based Web Services".
Intuiface API Explorer enables the no-coding creation of an interface asset for any REST-based Web Services query. With this interface asset, a running Intuiface experience can dynamically read from and write to the data source and/or device accessible via that Web Service.
For anyone, of any skill set, API Explorer opens the door to tens of thousands of public and private APIs available in the cloud. There is everything from movie listings and weather forecasts to currency conversion, the latest photos from NASA, and all those connected objects among the Internet of Things. The majority are free to use - for example, check out the Programmable Web directory - while others may require an access fee. Some may be private and internal to your organization. Regardless, all are accessible in Intuiface.
Key Features
- Supports entry of any Request URL or curl statement; displays the contents of any XML or JSON response.
- Uses a machine learning engine to identify the appropriate type for each result value and which results to preselect for visualization in Intuiface.
- Automatically generates an interface asset for the specified query and creates a visualization of specified properties with an Intuiface experience
- Enables the automatic display of multi-page results in a single view, avoiding the need to manually page through results within a running Intuiface experience.
- Permits on-the-fly modification of host, endpoint, and parameters to tailor the query for specific needs
NOTE: It is still possible to manually create an interface asset for a REST-based Web Service, a topic discussed here. However, as you'll discover, not only is it far easier to use API Explorer, but the process is now accessible to anyone, of any skill set, and not just developers.
How it works
Specifying your request URL or cURL statement
- Launch API Explorer while in Composer's Edit Mode. You must be actively editing an experience to run API Explorer.
- Enter your request URL or curl statement and submit it.
- Review the results. You can
- change the property type for a value to ensure Intuiface properly represents it visually
- change/add/remove parameter values within your request URL or curl statement and resubmit them
- change the property type for a value to ensure Intuiface properly represents it visually
- Select the property values you wish to display in your experience. All property values will be accessible in Composer. You're selecting those properties you wish Composer to display.
- Click the "Create an interface asset" button.
- Assign a name to the interface asset you're about to create and a name for the IA category within which this new IA should be placed. Then click the "Create" button.
- You're returned to Composer. A visualization of the properties you selected is automatically displayed in the scene you were editing while an interface asset appears in the Interface Assets panel.
- If, at any time, you wish to revise your query, right-click your IA in the Interface Assets panel and select the Edit in API Explorer option.
Machine learning engine
To help you decide which properties would be most appropriate for display within Intuiface, API Explorer incorporates a machine learning engine. This engine monitors all queries entered by all Intuiface users around the world to improve its ability to:
- Identify the type of value represented by a given property.
In this example, note how API Explorer guessed that the "Price" property was of the type Quantity.
You understand that this value is really of the type Currency, so you change it.
The machine learning engine will take note of this and how, around the world, Intuiface users are setting "Price" to the type Currency. Eventually, API Explorer will learn to automatically set "Price" to the Currency type. - Preselect properties considered most likely to be interesting for visualization.
In this example, note how API Explorer decided not to preselect the "Description" property for visualization (i.e. it's missing a checkmark).
If you select the "Description" field for visualization, and around the world, Intuiface users are select the property "Description" for visualization - selecting it for any Web Service, not just this particular query - API Explorer will learn to automatically preselect the "Description" field for visualization.
NOTE: IntuiLab SAS, Intuiface, and API Explorer respect user privacy and never shares entered information with anyone. The machine learning engine is using user selections to improve the assistance it can provide.
Modifying your query
To the left of the Results panel is a breakdown of your request URL or curl statement into its constituent parts: host, endpoint, and parameters. Much can be configured here.
- Each value is color-coded. You can match the colored bar to the left of each value with a part of the full statement listed above.
- Hover your mouse over any of these values and it will be highlighted in the full statement above. In the following image, the mouse is hovering over the value "London" for the parameter "area"
- Highlight any part of the Host or Endpoint then click the + button to convert the highlighted content into a new parameter.
- Updating any of the host, endpoint, and parameter values will cause - once mouse focus leaves the modified field - API Explorer to run the now modified Web Services request and update the Results panel.
- Parameter values can be toggled between representation as query or header parameters. Click the corresponding H or Q symbol to open the dialog enabling you to make this change.
- Parameter values can also be tagged as representing collection pagination parameters - i.e. indication of item offset, page offset, or item count per page as well as the applicable list if more than one exists in the results - when the request response is separated across multiple pages. With this information, Intuiface can automatically combine multiple pages into a single view within a running experience.
Create a JSON body for your request
Some web services using a POST, PUT, PATCH, or DELETE verb will require you to pass parameters in a JSON body. To create such a body, you need to add one body parameter per key in the JSON. The parameter name will be the path to that key in the JSON object, using a dot as a hierarchy separator.
Let's take the example of the following body:
{ "product":
{
"name": "BJURSTA",
"size": {
"width": 140,
"height": 90,
"depth": 75
},
"price": "99€"
}
}
The parameters to add in the API Explorer will be the following. You can then change each of these parameters in a property of the generated Interface asset through its associated action.
Sharing results and the standalone API Explorer
API Explorer enables the creation of a shareable link containing all host, endpoint, and parameter values. Entry of this URL in any Web browser will open a standalone instance of API Explorer and display the Results view.
Modifications made to property types or selected properties will not be reflected in the shared view. The machine learning engine will apply its own decision-making.
The standalone API Explorer
- Can be used to research any request URL or curl statement. It is not limited to shared queries
- Creates an ifd file, the file used - under the covers - to represent an interface asset.
Properties, Triggers & Actions
Properties
All Interface assets generated by the API Explorer will have the following properties.
- Automatic refresh: check this property to make sure your content is refreshed on a regular basis.
- Refresh time: the periodicity of the automatic refresh, if activated. Warning: be careful to respect your web service quota
All the other properties will depend on your web service parameters.
Any parameter set in the query, header, or body of the request will appear in the properties panel.
The response of the web service will appear as read-only properties and can be accessed through a binding.
Triggers
All Interface assets generated by the API Explorer will have the following triggers.
- Request started: raised when the request is sent.
- Request completed: raised when a response is received with a success code (200).
-
Request failed: raised when no response or an error is received. This trigger contains the following read-only parameters:
- Status code: the HTTP code returned by the server.
- Raw response: the response or error message received.
Actions
All Interface assets generated by the API Explorer will have the following actions.
- Refresh: use this action to manually refresh the content retrieved through this web service.
- Set Automatic refresh: dynamically change the Automatic refresh property.
- Set Refresh time: dynamically change the Refresh time property.
All the other actions will depend on your web service parameters.
Any parameter set in the query, header, or body of the request will appear as a Set {Parameter name} action so you can dynamically change it.
In the case of a POST, PUT, PATCH, or DELETE method, it will appear as an action.
Result processing
Sometimes the API responses will not give you the information you need with the right or complete form and you may need to process it before using it in Intuiface. An example is the Google Youtube Data API and its Search web service that only returns a videoId for each video result instead of a complete URL. See the picture below.
In this case, you can use a Value Converter to modify this value before using it in a property or an action parameter.
In the YouTube example above, we would use the Concatenate - Text Manipulation converter to build the proper URL using the video Id as the binding input.
Supported protocols & limitations
API Explorer can:
- submit both request URLs and curl statements.
- process GET, POST, PUT, PATCH, and DELETE requests.
- a POST, PUT, PATCH, and DELETE request can have a body parameter. It will be sent in a JSON object with the following format:
{"parameter name": value}
.
- a POST, PUT, PATCH, and DELETE request can have a body parameter. It will be sent in a JSON object with the following format:
- consume XML, JSON, or plain text formatted responses. This includes blog feeds, as those feeds are formatted using XML.
- gzip and deflate compression methods are supported.
Limitations:
- API Explorer only supports Basic or Bearer authentication. It does not yet support Digest or OAuth2 authentication.
- Exception: if the OAuth is a password grant type, this can be achieved with two different calls in the API Explorer.
- It is not possible for multiple instances of Composer running on the same PC to each independently use API Explorer. You must close the first instance of Composer to use API Explorer before you can open API Explorer from another Composer instance.
- It is not possible to individually edit a duplicated Interface Asset generated by API Explorer. Changing any property in the duplicated Interface Asset will always reflect in the original one. In this case, instead, it is best to create a new Interface Asset using API Explorer.
- Re-opening for editing an Interface Asset whose request is behind a firewall or within a local network will no longer contain the previously selected properties or type.
- The cURL type
multipart/form-data
(aka -F, aks -FORM) is not supported. This kind of request is usually used to upload files like images.
You can useapplication/x-www-form-urlencoded
instead, but you will have to add theContent-Type
as the header with theapplication/x-www-form-urlencoded
as a value. - Parameter key and value has to be separated with a column ‘:’ and a blank space character
- A json-formatted response with blank [empty] content before data is not displayed when using Composer or Player for Windows
- GraphQL architectures are not currently supported by the API Explorer
- On iOS devices, the http protocol will not be resolved. Your API Interface Asset should use https instead
- The parameter trailing path must end with a slash, for example:
https://url/api/
will work, whilehttps://url/api
will not work.
Cache management
This is the current cache management mechanisms used by Interface Assets generated with the API Explorer:
- the request & responses are not cached. If you don't have an internet connection when launching the experience in a player, there will be no data.
- when a resource is downloaded from a web URL, such as an image, the file is automatically cached locally. If during the same Composer / Player session (i.e. without restarting it), you try to display the same resource, it won't be downloaded again.
- This media cache is cleared each time you start a new session (i.e. restart) Composer or Player.
- If a new request goes in an error state - due to bad parameters or server issues - the last successful answer is kept in memory. You can use the "Request failed" trigger to hide this cached data if it's not relevant (ex: stock information).
Comments
0 comments
Article is closed for comments.