npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

dodo-sync

v0.3.1

Published

Sync Dodo Payments data with your database

Downloads

419

Readme

Dodo Payments Sync Engine

Seamlessly sync your Dodo Payments data with your own database.

Database Support

We currently support MongoDB and PostgreSQL.

We are actively working on expanding support for:

  • Databases: Clickhouse, Snowflake, and others.
  • Pipelines: ETL pipelines, Realtime sync.

If you'd like to contribute a new database integration, please submit a Pull Request (PR).

Usage

You can use dodo-sync via the CLI or programmatically in your Code.

1. CLI Usage

Installation

npm install -g dodo-sync
# OR
bun add -g dodo-sync

Running the CLI

Interactive Mode: Simply run the command without arguments to start the interactive setup wizard.

dodo-sync

Manual Mode: Pass arguments directly to skip the wizard.

dodo-sync -i [interval] -d [database] -u [database_uri] --scopes [scopes] --api-key [api_key] --env [environment]

Examples:

# MongoDB
dodo-sync -i 600 -d mongodb -u mongodb://mymongodb.url --scopes "licences,payments,customers,subscriptions" --api-key YOUR_API_KEY --env test_mode

# PostgreSQL
dodo-sync -i 600 -d postgres -u postgresql://user:password@localhost:5432/mydb --scopes "licences,payments,customers,subscriptions" --api-key YOUR_API_KEY --env test_mode

Arguments

| Argument | Shorthand | Description | Type | Required | Example | | :--- | :--- | :--- | :--- | :--- | :--- | | --interval | -i | Sync interval in seconds. | number | No | 600 | | --database | -d | Database type. | "mongodb" | "postgres" | Yes | mongodb | | --database-uri | -u | Connection URI for the database. | string | Yes | mongodb://... | | --scopes | | Data entities to sync (comma-separated). | string | Yes | payments,customers | | --api-key | | Your Dodo Payments API Key. | string | Yes | dp_live_... | | --env | | Environment target. | "live_mode" | "test_mode" | Yes | test_mode | | --rate-limit | --rl | Rate limit in requests per second. | number | No | 10 |


2. Code Usage

Installation

npm install dodo-sync
# OR
bun add dodo-sync

Example: Automatic Sync (Interval-based)

import { DodoSync } from 'dodo-sync';

const syncDodoPayments = new DodoSync({
    interval: 60, // Sync every 60 seconds
    database: 'mongodb',
    databaseURI: process.env.MONGODB_URI, // e.g., 'mongodb://localhost:27017'
    scopes: ['licences', 'payments', 'customers', 'subscriptions'],
    dodoPaymentsOptions: {
        bearerToken: process.env.DODO_PAYMENTS_API_KEY,
        environment: 'test_mode' // or 'live_mode'
    }
});

// Initialize connection
await syncDodoPayments.init();

// Start the sync loop
syncDodoPayments.start();

Example: Manual Sync

import { DodoSync } from 'dodo-sync';

const syncDodoPayments = new DodoSync({
    database: 'mongodb',
    databaseURI: process.env.MONGODB_URI,
    scopes: ['licences', 'payments', 'customers', 'subscriptions'],
    dodoPaymentsOptions: {
        bearerToken: process.env.DODO_PAYMENTS_API_KEY,
        environment: 'test_mode'
    }
});

// Initialize connection
await syncDodoPayments.init();

// Trigger a single sync operation
await syncDodoPayments.run();

Example: PostgreSQL

import { DodoSync } from 'dodo-sync';

const syncDodoPayments = new DodoSync({
    interval: 60,
    database: 'postgres',
    databaseURI: process.env.POSTGRES_URI, // e.g., 'postgresql://user:password@localhost:5432/mydb'
    scopes: ['licences', 'payments', 'customers', 'subscriptions'],
    dodoPaymentsOptions: {
        bearerToken: process.env.DODO_PAYMENTS_API_KEY,
        environment: 'test_mode'
    }
});

await syncDodoPayments.init();
syncDodoPayments.start();

Constructor Options

| Option | Type | Description | Required | | :--- | :--- | :--- | :--- | | database | "mongodb" | "postgres" | Name of the database to use. | ✅ | | databaseURI | string | Connection string for the database. | ✅ | | scopes | string[] | Array of entities to sync (e.g., ["payments", "customers"]). | ✅ | | dodoPaymentsOptions | object | Dodo Payments SDK options (API key, environment). See types. | ✅ | | interval | number | Time in seconds between automatic syncs. Required for .start(), optional for .run(). | ❌ | | rateLimit | number | Number of requests per second. | ❌ |

Important Info

[!IMPORTANT] MongoDB: A database named dodopayments_sync will be automatically created on your database server. All sync data will be stored there. This database name is currently fixed and cannot be changed.

PostgreSQL: Tables (Subscriptions, Payments, Licenses, Customers) will be created in the database specified in your connection URI. Data is stored as JSONB.