72 lines
4.4 KiB
JSON
72 lines
4.4 KiB
JSON
{
|
|
"type": "API Response Schema",
|
|
"definition": {
|
|
"text": "This node represents the map for the API response. APIs send their data using a JSON object. The children of this node will map this JSON object so that the API Fetcher Bot knows how to extract the data you want.",
|
|
"updated": 1622863829380
|
|
},
|
|
"paragraphs": [
|
|
{
|
|
"style": "Text",
|
|
"text": "The API Map assumes the API Server will respond with string formatted in JSON. This means that the response will be a data structure of nestled objects and arrays. Users will need to map the response format into an API Response Schema by adding children to this node and to this node's children. All these descendants are of the same Node Type API Response Field.",
|
|
"updated": 1622312357188
|
|
},
|
|
{
|
|
"style": "Text",
|
|
"text": "Here is an example of an API's response JSON:",
|
|
"updated": 1622894576735
|
|
},
|
|
{
|
|
"style": "Json",
|
|
"text": "{\n \"status\": {\n \"timestamp\": \"2018-06-02T22:51:28.209Z\",\n \"elapsed\": 10\n },\n \"data\": [\n {\n \"id\": \"1e31218a-e44e-4285-820c-8282ee222035\",\n \"symbol\": \"BTC\",\n \"name\": \"Bitcoin\",\n \"slug\": \"bitcoin\",\n \"profile\": {...},\n \"metrics\": {...}\n }\n ]\n}",
|
|
"updated": 1622894444830
|
|
},
|
|
{
|
|
"style": "Text",
|
|
"text": "The main object is the first set of curly brackets { } enclosing everything. As you can see, underneath that there are two object properties named status and data. Status is an object and contains the header information. Data is an array and holds the actual data we are after. As you API Response Field nodes to your API Response Schema node you will be mapping an API response similar to this one.",
|
|
"updated": 1622894937351
|
|
},
|
|
{
|
|
"style": "Success",
|
|
"text": "When reading documentation, or looking at raw data held in JSON, it is important to remember that curly brackets { } define objects while square brackets [ ] define arrays."
|
|
},
|
|
{
|
|
"style": "Title",
|
|
"text": "API Response Schema Configuration",
|
|
"updated": 1622895860644
|
|
},
|
|
{
|
|
"style": "Subtitle",
|
|
"text": "Properties"
|
|
},
|
|
{
|
|
"style": "List",
|
|
"text": "nodePath: the response from the server might include some header type data in addition to the actual data requested. Since the response is a JSON object, then the actual data might be located somewhere within the structure of that object. This property allows you to declare the path to the actual data requested, so as to jump the header-like information.",
|
|
"updated": 1622864019058
|
|
},
|
|
{
|
|
"style": "Subtitle",
|
|
"text": "Why do We Need to Jump the Header?",
|
|
"updated": 1622864036535
|
|
},
|
|
{
|
|
"style": "Text",
|
|
"text": "In many cases it will be necessary to make several queries to the API Server in order to fetch all the data (think of pagination). Each page of data arrives at a certain location within the response data structure. That location is what we considered the Data Root.",
|
|
"updated": 1622864086051
|
|
},
|
|
{
|
|
"style": "Text",
|
|
"text": "If your Endpoint does not support pagination, it is still a good practice to define which part of the JSON object is the Data Root.",
|
|
"updated": 1622864107476
|
|
},
|
|
{
|
|
"style": "Important",
|
|
"text": "Most Record Properties will be referencing API Response Field nodes that are under the Data Root you defined, but there might be one or two that are not there. Rather these values may be under the response data structure in general, or at a section that could be considered a header. In that case, there is some special steps you need to follow. At the API Response Field Reference node config, you will need to set up a nodePath property as explained below.",
|
|
"updated": 1622864199297
|
|
},
|
|
{
|
|
"style": "Text",
|
|
"text": "Check the API Response Field Reference node for details on how to setup this property.",
|
|
"updated": 1621971441459
|
|
}
|
|
]
|
|
} |