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

synthra-x402

v1.0.2

Published

Synthra API SDK using x402 and Algorand USDC

Downloads

361

Readme

synthra-x402

The official SDK for interacting with the Synthra API Marketplace. This SDK automatically handles x402-avm payments (L402 protocol) using prepaid USDC on the Algorand blockchain.

It allows human developers and autonomous AI agents to consume premium APIs without manually managing cryptocurrency payments or transaction signing.

Installation

npm install synthra-x402

For Human Developers (Browser)

If you are building a web application, you can initialize the client using the user's active wallet provider (e.g., Pera Wallet, Defly, etc.). The SDK will automatically prompt the user to approve USDC payments when required.

import { createSynthraClient } from 'synthra-x402/client'

// Assuming you are using @txnlab/use-wallet
const { activeAccount, signTransactions } = useWallet();

const client = createSynthraClient({
  network: 'testnet', // or 'mainnet'
  payTo: 'CREATOR_ALGORAND_ADDRESS_HERE',
  priceUsdc: 0.10, // Cost per request
  signer: {
    address: activeAccount.address,
    signTransactions: async (txns, indexesToSign) => {
      return signTransactions(txns, indexesToSign);
    }
  }
});

// Just fetch normally! The SDK handles the 402 payment flow under the hood
const response = await client.fetch('https://api.weather.in/cities');
const data = await response.json();

For Autonomous Agents (Node.js)

Agents can consume APIs entirely autonomously by signing the USDC payment with their own private key. No human intervention is needed.

import { createSynthraClient } from 'synthra-x402/client'
import algosdk from 'algosdk';

const secretKey = Buffer.from(process.env.AGENT_PRIVATE_KEY, "base64");
const address = algosdk.encodeAddress(secretKey.slice(32));

const agentClient = createSynthraClient({
  network: 'testnet', // or 'mainnet'
  payTo: 'CREATOR_ALGORAND_ADDRESS_HERE',
  priceUsdc: 0.10,
  signer: {
    address,
    signTransactions: async (txns, indexesToSign) => {
      return txns.map((txn, i) => {
        if (indexesToSign && !indexesToSign.includes(i)) return null;
        const decoded = algosdk.decodeUnsignedTransaction(txn);
        return algosdk.signTransaction(decoded, secretKey).blob;
      });
    }
  }
});

// The agent can now consume external APIs from the marketplace autonomously
const response = await agentClient.fetch('https://api.weather.in/cities');
const data = await response.json();

Protecting your own APIs (Express.js Middleware)

You can also use this package to easily protect your own Express.js API endpoints and monetize them on the Synthra Marketplace.

import express from 'express';
import { synthraApiAuth } from 'synthra-x402/server';

const app = express();

// Protect the endpoint requiring 0.10 USDC per request
app.use("/api/premium", synthraApiAuth({
  network: "testnet",
  priceUsdc: 0.10,
  payTo: "YOUR_ALGORAND_WALLET_ADDRESS"
}));

app.get("/api/premium", (req, res) => {
  res.json({ secret: "This data was paid for using x402!" });
});

app.listen(8080);

How it works (Prepaid Tokens)

  1. You use the synthra-x402 SDK to make a request to a marketplace endpoint.
  2. The server responds with a 402 Payment Required invoice.
  3. The SDK intercepts the response and automatically handles purchasing a prepaid token (Macaroon) via your wallet or private key.
  4. You only pay network fees ONCE. Subsequent requests simply mathematically decrement your token budget off-chain, enabling thousands of requests per second with zero blockchain latency.