This article explains the Get data from REST APIs block in App Design.
Note: This block can pull data from any REST-based API that supports HTTP GET or POST methods and that accepts and returns JSON Payloads.
Also note that the API response should be a JSON Object. It cannot be a JSON Array or a string or a number.
Help video
Use Cases
Getting Master data from company's existing APIs to fetch information of Customers, Employees, Vendors, Projects etc.
Querying/filtering the Master data based on values entered by the end-user on Clappia.
Getting live information of Currency exchange, weather etc from public APIs as part of the Clappia apps.
Editing the Block
Click on the block and start editing on the panel that appears on the right side.
Label
This is what appears as the label for the REST API block to the end user.
Server URL
REST API endpoint of the Server from where data needs to be pulled. Sample Server URL - https://apiv2.clappia.com/public/xx/getProjectById
The URL can be dynamic also. Type @ to see a list of all variables of the app.
Method Type
HTTP Method Type that the API works on. Choose from one of GET or POST.
Query String
Optional Query String that the API accepts. We can pass any variables from the current Clappia app to the query string arguments. Type @ to see a list of all variables of the app. The query String should follow the pattern - ?parameter1=value1¶meter2=value2& . . .
Headers
Headers in JSON format. Used to send attributes like API Keys, Content Type etc to the REST API.
Request JSON
Optional. JSON Payload for the API. Applicable only if Method Type is POST. This also accepts variables from the Clappia App. Type @ to see a list of all variables of the app.
Note: This should be a valid JSON. New line characters should not be present in the JSON.
Select fields from the API Response
This block assumes that the API Response is a JSON object. It cannot be an Array or a String or a Number. So let's say following is response of a GetCityByName API-
Now when the Clappia user enters the city name and fetches the city data from this API, we need to map the API Response to fields on Clappia. Let's say that we need only the city_name, state_name and is_state_capital fields in the Clappia App. So we enter the exact names of these three fields in the section.
Now when we save the details, we will see three new read-only fields created in the app. We can now change the labels of these fields.
FAQs
Try our free plan
It will answer many more questions within just 15 minutes.