Guides
Continuous Data Syncs
Guides
Continuous Data Syncs
Continuously sync with APIs, bi-directionally.
This feature is in private beta. Request access on the community.
In this guide, we will sync issues from Github as tickets
. It entails:
- Adding a folder in your repo where your Integration code will live
- Defining a
ticket
data model & configuring the sync - Writing minimal code to fetch issues and transform them into
tickets
โ1. Create your integrations folder
Regardless of your programming language, in your repo, run:
npx nango init && cd nango-integrations # Your new integrations folder
โ2. Configure your Integration
Open the nango.yaml
config file and define a new github-tickets
sync and ticket
model:
integrations:
github-tickets:
provider: github
runs: 'every hour'
returns:
- ticket
models:
ticket:
id: uuid
author: string
author_id: uuid
...
Then run:
npx nango g # Generates the model & scaffolding
โ3. Write your Integration code
Open the github-tickets.ts
which contains the following template:
import { NangoSync, NangoHelper } from '@nangohq/node';
import { ticket } from '@nangohq/models';
class GitHubTicketSync extends NangoSync {
async function fetchData(nango: NangoHelper): { [ticket.name]: [ticket.type] } {
// Integration code goes here.
}
export GitHubSync;
Fill in the fetchData
method with your integration code:
// API requests: handles auth, retries, rate-limiting, pagination and more.
const ghIssues = nango.get('/v1/issues', paginated=true);
// Mapping Github issues to tickets.
const tickets = ghIssues.map(issue => {
ticket.field.id: issue.unique_id,
ticket.field.author: issue.username,
ticket.field.author_id: issue.username_id,
...
});
// Return strongly-typed objects.
return { [ticket.name]: tickets }
Finally, deploy your code to Nango:
npx nango deploy
Thatโs it! When a user authorizes Github with Nango Auth, their issues will sync continuously! Nango provides:
- An SDK & API to access objects (strongly-typed)
- A webhook to get real-time updates (strongly-typed)
- A cache with fresh & highly-available data
- Built-in tooling for easy API requests (pagination, retries, rate-limit handling, transient errors etc.)
- Monitoring & Management console
- Automatic scaling & reliability