Skip to main content

Installing & instantiating the node SDK

Install it with your favorite package manager, e.g.:
Instantiate the Nango class:

Auth

Retrieve API credentials

Nango stores API credentials in connections objects. Retrieve a connection with:
The nango.getConnection() method returns the necessary information authenticate API requests:
  • OAuth 2: fresh access token
  • OAuth 1: token & token secret
  • API key: API key
  • Basic: username and password
Example Response
If you do not want to deal with collecting & injecting credentials in API requests for multiple authentication types, use the Proxy.
Please check the REST API reference for an example response and the full list of returned fields.
For OAuth 2, always fetch the latest access token from Nango before you run an API request, as we refresh tokens if needed. Caching tokens on your side could lead to failed requests.

List all connections for a user

This returns you all connections of a specific user (i.e. Connection ID):

List all connections

Returns a list of minimalistic connection objects. This can be helpful if you need to check whether a user has setup a specific integration. Note that the list does not contain any access credentials and fetching it also does not refresh the access tokens of any connections. Please check the REST API reference for an example response and the full list of returned fields.

Delete a connection

This will throw an exception if the delete call is not successful.

Set, update or fetch custom Metadata

Nango lets you store custom metadata on the Connection. updateMetadata updates existing Metadata for the connection by merging with any existing Metadata. setMetadata overrides any existing Metadata for the connection.
If you know the structure of the metadata, you can specify a type for it when retrieving;

Retrieve integration details

Use this method to retrieve all the details Nango stores on a specific integration:
Please check the REST API reference for an example response and the full list of returned fields.

Sync

Proxy

Some APIs are not yet fully-configured to work with the Proxy and require you to indicate the base URL.You can check if your API contains the proxy.base_url field in the providers.yaml configuration file.If not, you need to add a baseUrlOverride field in your call to the Proxy as follow:
Feel free to contribute the proxy.base_url field to any API in the providers.yaml public file, or reach out on the Slack community to ask us to do it.
To execute proxy requests, use:
The base URL should already be set for you for each API, but you can override with the baseUrlOverride field.Some APIs don’t have a default base URL (because it hasn’t been configured in Nango or they have multiple ones). You can check this by looking at the proxy.base_url field in the providers.yaml configuration file. Feel free to contribute this field or reach out on the Slack community to ask us to do it.
There are also convenience methods available: nango.get({}), nango.post({}), nango.patch{{}} and nango.delete({}). Return value
When you call the proxy, Nango creates the API request to the external API and runs it for you (possibly with retries).
The response from the external API is passed back to you exactly as Nango gets it:
  • Response code
  • Response headers
  • Response body
For the node SDK, Nango returns an Axios response object.

Trigger syncs

You can trigger specific sync(s) for a connection:
To trigger all syncs for a connection, just pass in an empty array:

Start/pause syncs

Starts or pauses the continuous execution of specified sync(s) for a given connection.

Sync status

Returns the status of syncs given an integration, sync names, and an optional connection id

Read synced data

nango.getRecords() is deprecated and will be removed in future releases as it does not support efficient pagination. Please use nango.listRecords() detailed below.
To read synced data from Nango, use listRecords:
By default, this returns an array of objects in the data model that you queried with some metadata about each record.
If you are using the Nango webhooks, you can use the timestamp you get from the webhook for the delta parameter. The value from the next_cursor property can be used with the cursor parameter to get the next page of results. If there are no more results, the next_cursor will be null.

Trigger an action

To trigger an action, use:
This will return whatever the action script is configured to return.

Get environment variables

To get the environment variables from a sync script, you can use getEnvironmentVariables:

Override a sync’s frequency for a specific connection

To override a sync’s frequency for a specific connection, or revert to the default frequency, use: