
The REST API data source in Reveal enables you to send GET, POST and PUT HTTP requests to a unique URL in order to manipulate data via a web service.
The REST API data source also provides the possibility to change the received data by simply changing parameters' values in the URL in the midst of creating your visualization without losing your progress.
An API (Application Program Interface) allows two software programs to communicate with each other. All web services are APIs accessed through the web environment.
REST APIs (also referred to as REST web services) are based on REST (Representational State Transfer) - a group of architectural constraints, providing standards for communication between computer systems on the web. In the REST architecture, clients send requests to retrieve or modify resources, and servers send responses to these requests.
To configure a REST API data source, you will need to enter the following information:
Data Source Name: this field will be displayed in the Data Sources list.
URL: the URL where the service is located.
Credentials: after selecting Credentials, you will be able to enter the credentials for your REST API or select existing ones if applicable. You can also choose the No Account option.
Method: from the dropdown menu you can choose your preferred request type - GET, POST or PUT.
Parameters are options you can pass in your URL to influence the response from the web service. You can provide path and query parameters in your URL when configuring the REST API data source.
To use parameters effectively follow the procedure below:
Provide parameters in the URL. You must put path parameters in curly braces and specify query parameters after a question mark (?). You can see in the example below that both path and query parameters are color coded in blue to make them more easily identifiable.
Add parameters' values. In the following screen specify the value of each parameter you have added in the URL.
As a result, the REST API service will respond with the data on the provided URL in a REST compliant format. Generally, you will receive a JSON file:
For more information on how to work with a JSON file, please refer to this topic.
After loading the data you will continue to the Visualization Editor screen.
Change the parameters' values without losing your visualization data. Changing the parameters' values after you have started building your visualization, offers a variety of possibilities such as accessing new data to add to your visualization or directly changing the displayed data in the visualization you have already created.
To do this, click on the file icon in the upper-left corner of the Visualization Editor screen.
In the screen that opens click/tap the REST API Parameters button.
You will be redirected to the screen in step 2 where you can provide new values to your parameters.
The Method in your REST API data source configuration represents a request used to interact with resources in a REST system. The request generally consists of:
A path to a resource (URL)
An HTTP verb:
GET - to retrieve a specific resource
POST - to create a new resource
PUT - update a specific resource
A Header: allows the client to pass along information about the request
A Body: an optional message (when using POST and PUT methods) containing data
For more information about the Header and Body of a request, please refer to this link.