Skip to main content

REST API

Overview

A REST API is an application programming interface that conforms to the constraints of REST (representational state transfer) architectural style and allows for interaction with RESTful web services.

REST APIs work by fielding requests for a resource and returning all relevant information about the resource, translated into a format that clients can easily interpret (this format is determined by the API receiving requests). Clients can also modify items on the server and even add new items to the server through a REST API.

tip

The REST API source support batch syncs.

\

Info tab

You can find the parameters in the Info tab below (Image 1).

Values

ParameterDescriptionExample
TitleMandatory. Input a name for your data syncREST API to Cinchy
DescriptionOptional. Add in a description for your sync. There is a 500 character limit in thie field.
VariablesOptional. Review our documentation on Variables here for more information about this field.
PermissionsData syncs are role based access systems where you can give specific groups read, write, execute, and/or all of the above with admin access. Inputting at least an Admin Group is mandatory.

Source tab

Mandatory and optional parameters for the Source tab are outlined below (Image 2).

ParameterDescriptionExample
SourceMandatory. Select your source from the drop down menu.REST API
HTTP MethodMandatory.This will be either GET or POST.
API Response FormatMandatory. Use this field to specify a response format of the endpoint. Currently, the Connections UI only supports JSON responses.JSON
Records Root JSONPathMandatory. Specify the JSON path for the results. The root of a JSON object is $. If the top-element of the response is an array, Cinchy places the array under a "data" key in a new JSON object. See Best practices for more info.$.data, $, $.ResponseObject
Path to IterateThe path to select an array of records for capturing elements inside. A record is created for each element which you can use as the input in a source schema. The path is relative to the root JSONPath.
API Endpoint URLMandatory. API endpoint, including URL parameters like API keyhttps://www.quandl.com/api/v3/datatables/CLS/IDHP?fx\_business\_date=2024-01-01\&api\_key=@API\_KEY
Next Page URL JSONPathSpecify the path for the next page URL. This is only relevant for APIs that use cursor pagination

Best practices

Retrieve nested fields

To get fields in a nested array, you can either set the nested array as the root, or you can use Path to Iterate to expand the array.

Examples

Here is a sample JSON response:

{
"groupId": 111,
"users": [
{
"userID": 1,
"name": "Jack"
},
{
"userID": 2,
"name": "Jill"
}
]
}

Records Root JSONPath: $.users Schema:

  • $.userId for ID
  • $.name for Name
info

You can't reference "groupId" as it's one level above the specified root scope.

JSON array handling

Use $.data in Records Root JSONPath if the API returns a top-level JSON array.

Examples

Here is a sample JSON response:

[
{
"name": "John Doe",
"age": 21
},
{ "name": "Jane Doe", "age": 21 }
]

Records Root JSONPath: $.data

Schema:

  • $.name for Name
  • $.age for Age

Path to Iterate

Use Path to Iterate to expand and target nested keys within the array. This only applies if the records within an array are objects.

If the record within the path to iterate is an array, each item within the array gets placed under an "item" key in a new JSON object.

Example

For example, here is a sample JSON response:

{
"name": "John",
"transactions": [{ "transactionId": 1 }, { "transactionId": 2 }]
}

In this example, we want to iterate over the "transactions" array and capture the records for "transactionid" and assign them to the "Transaction ID" column, and then add the parent "name" key to a Name column .

Records Root JSONPath: $ Path to iterate: $.transactions

Schema:

  • $.name for Name
  • $.transactions.id for Transaction ID

Next steps

Resources

Auth Request

For more information, see the page about auth requests.

Request Headers

For more information, see the page about request headers.

Body

You are able to use this section to add body content.

Pagination

A pagination block is mandatory. Review the documentation here for more on pagination blocks.

Retry Configuration

Retry Configuration automatically retries HTTP Requests on failure based on a defined set of conditions. This provides a mechanism to recover from transient errors, such as network disruptions or temporary service outages.

caution

Note: the maximum number of retries is capped at 10.

To set up a retry specification:

  1. Under the REST API source tab, select API Specification > Retry Configuration

  2. Select your Delay Strategy.

  • Linear Backoff: Defines a delay of approximately n seconds where n = current retry attempt.
  • Exponential Backoff: A strategy where every new retry attempt is delayed exponentially by 2^n seconds, where n = current retry attempt.
    • Example: you defined Max Attempts = 3. Your first retry is going to be in 2^1 = 2, second: 2^2 = 4, third: 2^3 = 8 sec.

3. Input your Max Attempts. The maximum number of retries allowed is 10.

  1. Define your Retry Conditions. You must define the conditions under which a retry should be attempted. For the Retry to trigger, at least one of the "Retry Conditions" has to evaluate to true.
info

Retry conditions are only evaluated if the response code isn't 2xx Success.

Each Retry Condition contains one or more "Attribute Match" sections. This defines a regex to evaluate against a section of the HTTP response. The following are the three areas of the HTTP response that can be inspected:

  • Response Code
  • Header
  • Body

If there are multiple "Attribute Match" blocks within a Retry Condition, all have to match for the retry condition to evaluate to true.

caution

Note that the Regex value should be entered as a regular expression. The Regex engine is .NET and expressions can be tested by using this online tool. In the below example, the Regex is designed to match any HTTP 5xx Server Error Codes, using a Regex value of 5[0-9][0-9].

For Headers, the format of the Header string which the regex is applied against is {Header Name}={Header Value}. For example "Content-Type=application/json".

;;