Skip to main content
The backend SDK lets you interact with the Nango API. It is available on NPM as @nangohq/node.

Instantiate the backend SDK

Install it with your favorite package manager, e.g.:
npm i -S @nangohq/node
Instantiate the Nango class:
import { Nango } from '@nangohq/node';

const nango = new Nango({ secretKey: '<SECRET-KEY>' });
Parameters

Integrations

List all integrations

Returns a list of integrations.
await nango.listIntegrations()
Example Response

Get an integration

Returns a specific integration.
await nango.getIntegration(<INTEGRATION-ID>);
Parameters Example Response

Create an integration

Create a new integration.
await nango.createIntegration(<PROVIDER-ID>, <INTEGRATION-ID>);
Parameters Example Response

Update an integration

Edits an integration (only for OAuth APIs).
await nango.updateIntegration(<PROVIDER-ID>, <INTEGRATION-ID>);
Parameters Example Response

Delete an integration

Deletes a specific integration.
await nango.deleteIntegration(<INTEGRATION-ID>);
Parameters Example Response

Connections

List connections

Returns a list of connections without credentials.
await nango.listConnections();
Parameters Example Response

Get a connection (with credentials)

Returns a specific connection with credentials.
await nango.getConnection();
The response content depends on the API authentication type (OAuth 2, OAuth 1, API key, Basic auth).If you do not want to deal with collecting & injecting credentials in requests for multiple authentication types, use the Proxy (step-by-step guide).
Every time you fetch the connection with this API endpoint, Nango will check if the access token has expired. If it has, it will refresh it.We recommend you always fetch the token just before you use it to make sure it is fresh!
Parameters Example Response

Get connection metadata

Returns a connection’s metadata.
await nango.getMetadata('<INTEGRATION-ID>', 'CONNECTION-ID');
If you know the structure of the metadata, you can specify a type;
interface CustomMetadata {
    anyKey: Record<string, string>;
}
const myTypedMetadata = await nango.getMetadata<CustomMetadata>('<INTEGRATION-ID>', '<CONNECTION-ID>');
Parameters Example Response

Set connection metadata

Set custom metadata for the connection (overrides existing metadata).
await nango.setMetadata('<INTEGRATION-ID>', 'CONNECTION-ID', { 'CUSTOM_KEY1': 'CUSTOM_VALUE1' });
Parameters Response Empty response.

Edit connection metadata

Edit custom metadata for the connection. Only overrides specified properties, not the entire metadata.
await nango.updateMetadata('<INTEGRATION-ID>', 'CONNECTION-ID', { 'CUSTOM_KEY1': 'CUSTOM_VALUE1' });
Parameters Response Empty response.

Delete a connection

Deletes a specific connection.
await nango.deleteConnection('<INTEGRATION-ID>', 'CONNECTION-ID');
Parameters Response Empty response.

Syncs

Get records

Returns the synced data.
import type { ModelName } from '<path-to-nango-integrations>/models'

const records = await nango.listRecords<ModelName>({
    providerConfigKey: '<INTEGRATION-ID>',    
    connectionId: '<CONNECTION-ID>',                
    model: '<MODEL-NAME>'
});
nango.getRecords() is deprecated and will be removed in future releases as it does not support efficient pagination. Please use nango.listRecords() detailed below.
Parameters Example Response

Trigger sync(s)

Triggers an additional, one-off execution of specified sync(s) for a given connection or all applicable connections if no connection is specified.
const records = await nango.triggerSync('<INTEGRATION-ID>', ['SYNC_NAME1', 'SYNC_NAME2'], '<CONNECTION_ID>');
Parameters Response Empty response.

Start schedule for sync(s)

Starts the schedule of specified sync(s) for a given connection or all applicable connections if no connection is specified.
await nango.startSync('<INTEGRATION-ID>', ['SYNC_NAME1', 'SYNC_NAME2'], '<CONNECTION_ID>')
Parameters Response Empty response.

Pause schedule for sync(s)

Pauses the schedule of specified sync(s) for a given connection or all applicable connections if no connection is specified.
await nango.startSync('<INTEGRATION-ID>', ['SYNC_NAME1', 'SYNC_NAME2'], '<CONNECTION_ID>')
Parameters Response Empty response.

Sync status

Get the status of specified sync(s) for a given connection or all applicable connections if no connection is specified.
await nango.syncStatus('<INTEGRATION-ID>', ['SYNC_NAME1', 'SYNC_NAME2'], '<CONNECTION_ID>')
Parameters Response

Override sync connection frequency

Override a sync’s default frequency for a specific connection, or revert to the default frequency.
await nango.updateSyncConnectionFrequency('<INTEGRATION-ID>', 'SYNC_NAME', '<CONNECTION_ID>', '<FREQUENCY>')
Parameters Response

Get environment variables

Retrieve the environment variables as added in the Nango dashboard.
await nango.getEnvironmentVariables();
Parameters No parameters. Response

Actions

Trigger an action

Triggers an action for a connection.
await nango.triggerAction('<INTEGRATION-ID>', '<CONNECTION_ID>', '<ACTION-NAME>', { 'custom_key1': 'custom_value1' });
Parameters Response

Proxy

Proxy - GET requests

Triggers an action for a connection.
const res = await nango.get({
    endpoint: '/endpoint',
    providerConfigKey: '<INTEGRATION-ID>',
    connectionId: '<CONNECTION-ID>',
    baseUrlOverride: 'https://base-url.com'
});
Parameters Response

Proxy - POST requests

Triggers an action for a connection.
const res = await nango.post({
    endpoint: '/endpoint',
    providerConfigKey: '<INTEGRATION-ID>',
    connectionId: '<CONNECTION-ID>',
    baseUrlOverride: 'https://base-url.com'
});
Parameters Response

Proxy - PUT requests

Triggers an action for a connection.
const res = await nango.put({
    endpoint: '/endpoint',
    providerConfigKey: '<INTEGRATION-ID>',
    connectionId: '<CONNECTION-ID>',
    baseUrlOverride: 'https://base-url.com'
});
Parameters Response

Proxy - PATCH requests

Triggers an action for a connection.
const res = await nango.patch({
    endpoint: '/endpoint',
    providerConfigKey: '<INTEGRATION-ID>',
    connectionId: '<CONNECTION-ID>',
    baseUrlOverride: 'https://base-url.com'
});
Parameters Response

Proxy - DELETE requests

Triggers an action for a connection.
const res = await nango.delete({
    endpoint: '/endpoint',
    providerConfigKey: '<INTEGRATION-ID>',
    connectionId: '<CONNECTION-ID>',
    baseUrlOverride: 'https://base-url.com'
});
Parameters Response