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 🙏

© 2026 – Pkg Stats / Ryan Hefner

onerouterjs-sdk

v2.0.5

Published

TypeScript SDK for OneRouter API - Works in any JavaScript runtime

Downloads

149

Readme

OneRouter JavaScript SDK - Quick Guide

TypeScript SDK for OneRouter API - Works in ANY JavaScript Runtime

✨ What's Included

  • 💳 Payments: Create orders, capture payments, process refunds
  • 🔄 Subscriptions: Create, manage, pause/resume subscriptions
  • 🔗 Payment Links: Generate shareable payment links
  • 💰 Payouts: Process vendor payouts
  • 📱 SMS: Send SMS via Twilio integration
  • 📧 Email: Send emails via Resend integration
  • 🛡️ Type Safety: Full TypeScript support with autocomplete
  • 🚀 Any Runtime: Node.js, Deno, Edge functions, browsers

Installation

npm install onerouter-js
# Or
yarn add onerouter-js
# Or
pnpm add onerouter-js

Quick Start

import { OneRouter } from 'onerouter-js';

const client = new OneRouter({ apiKey: 'your_api_key' });

// Create payment
const order = await client.payments.create({
    amount: 500.00,
    currency: 'INR'
});

console.log('✅ Order:', order.transaction_id);
console.log('📋 Checkout:', order.checkout_url);

That's it! Your first payment is created.

Why TypeScript SDK?

| Feature | Python SDK | TypeScript SDK | |----------|-------------|----------------|--------------| | Type Safety | ⚠️ Runtime checks | ✅ Full TypeScript | | Any Runtime | ⚠️ Python 3.8+ required | ✅ Node.js, Deno, Edge functions | | Dependencies | httpx, httpx (heavy) | fetch (lightweight) | | Type Hints | ⚠️ Limited | ✅ Full autocomplete | | Bundle Size | ~10MB (httpx) | <1MB (native fetch) | | Installation | pip install | npm install | npm install |

Quick Example

1. Create Payment

const order = await client.payments.create({
    amount: 500.00,
    currency: 'INR',
    receipt: 'order_123'
});

console.log('Order ID:', order.transaction_id);
console.log('Checkout URL:', order.checkout_url);

2. Get Payment Details

const details = await client.payments.get(order.transaction_id);
console.log('Status:', details.status);
console.log('Provider:', details.provider);
console.log('Amount:', details.amount);

3. Create Subscription

const subscription = await client.subscriptions.create({
    plan_id: 'plan_monthly_99',
    customer_notify: true,
    total_count: 12
});

console.log('Subscription:', subscription.subscription_id);
console.log('Plan:', subscription.plan_id);
console.log('Cycle:', subscription.current_cycle);

4. Create Payment Link

// Create Razorpay payment link
const razorpayLink = await client.paymentLinks.create({
    amount: 1000,
    description: "Product Purchase",
    provider: "razorpay",
    environment: "test"
});
console.log('Razorpay Checkout:', razorpayLink.checkout_url);

// Create PayPal payment link
const paypalLink = await client.paymentLinks.create({
    amount: 10,
    description: "Credit Purchase",
    provider: "paypal",
    environment: "test"
});
console.log('PayPal Checkout:', paypalLink.checkout_url);

6. Send Email

const emailResult = await client.email.send({
    to: "[email protected]",
    subject: "Welcome to OneRouter!",
    html_body: "<h1>Welcome!</h1><p>Thank you for signing up.</p>",
    text_body: "Welcome! Thank you for signing up."
});

console.log('✅ Email sent:', emailResult.email_id);
console.log('📧 Status:', emailResult.status);

7. Handle Error

try {
    const order = await client.payments.create({ amount: 500.00, currency: 'INR' });
} catch (error) {
    if (error.name === 'AuthenticationError') {
        console.error('❌ Invalid API key');
    } else if (error.name === 'RateLimitError') {
        console.error('⚠️ Rate limit exceeded. Retry later');
    } else {
        console.error('❌ Error:', error.message);
    }
}

Platform Examples

Next.js API Route

// app/api/payments/route.ts
import { NextRequest, NextResponse } from 'next/server';
import { OneRouter } from '@onerouter/sdk';

const client = new OneRouter({ apiKey: process.env.ONEROUTER_API_KEY! });

export async function POST(request: NextRequest) {
    const { amount, currency } = await request.json();

    const order = await client.payments.create({
        amount,
        currency: currency || 'USD'
    });

    return NextResponse.json(order);
}

Edge Function (Vercel/Cloudflare)

// pages/api/pay.ts (Edge function)
import { OneRouter } from '@onerouter/sdk';

export default async function handlePayment(request: Request) {
    const { amount, currency } = await request.json();

    const order = await client.payments.create({
        amount,
        currency: currency || 'USD'
    });

    return Response.json(order);
}

Serverless Function (AWS Lambda)

// lambda/payments.js (AWS Lambda)
import { OneRouter } from '@onerouter/sdk';

export const handler = async (event) => {
    const { amount, currency } = JSON.parse(event.body);

    const order = await client.payments.create({
        amount,
        currency
    });

    return {
        statusCode: 200,
        body: JSON.stringify(order)
    };
};

Ready!

This TypeScript SDK is production-ready for any JavaScript runtime! It includes full TypeScript support for payments, subscriptions, SMS, and email functionality.