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

@tradebuddyhq/sdk

v1.0.0

Published

TypeScript SDK for the Trade Buddy API

Readme

sdk

TypeScript SDK for the Trade Buddy API

Installation

npm install @tradebuddyhq/sdk

Requires Node.js 18+

Quick Start

import { TradeBuddy } from '@tradebuddyhq/sdk';

const client = new TradeBuddy();

// Create an account
const session = await client.signUp({
  name: 'Jane Doe',
  email: '[email protected]',
  password: 'supersecret',
});

console.log(session.user); // { id, name, email }
console.log(session.token); // bearer token (also stored internally)

// Browse listings (no auth needed)
const listings = await client.getListings();

API Reference

Constructor

const client = new TradeBuddy(config?: TradeBuddyConfig);

| Option | Type | Default | Description | | --------- | -------- | -------------------------------- | ------------------------------------ | | baseUrl | string | https://mytradebuddy.com/api | API base URL | | token | string | - | Restore a previously saved token |

Authentication

signUp(input): Promise<Session>

const session = await client.signUp({
  name: 'Jane Doe',
  email: '[email protected]',
  password: 'supersecret',
});

Creates a new account. The token is stored internally for subsequent calls

signIn(input): Promise<Session>

const session = await client.signIn({
  email: '[email protected]',
  password: 'supersecret',
});

Signs in to an existing account. The token is stored internally

signOut(): Promise<void>

await client.signOut();

Signs out and clears the stored token. Requires authentication

deleteAccount(): Promise<void>

await client.deleteAccount();

Permanently deletes the authenticated user's account. Requires authentication

Listings

getListings(): Promise<Listing[]>

const listings = await client.getListings();

for (const listing of listings) {
  console.log(`${listing.title} - $${listing.price}`);
}

Fetches all public listings. No authentication required

createListing(input): Promise<string>

const listingId = await client.createListing({
  title: 'Calculus Textbook',
  type: 'Sell',
  price: 25,
  category: 'Books',
  condition: 'Good',
  description: 'Used for one semester, minor highlighting.',
});

console.log(`Created listing: ${listingId}`);

Creates a new listing. Requires authentication. Returns the new listing ID

Token Management

client.getToken();          // string | null
client.setToken('abc123');  // manually set a token
client.isAuthenticated();   // boolean

Error Handling

All errors are thrown as TradeBuddyError:

import { TradeBuddy, TradeBuddyError } from '@tradebuddyhq/sdk';

try {
  await client.signIn({ email: '[email protected]', password: 'wrong' });
} catch (err) {
  if (err instanceof TradeBuddyError) {
    console.error(err.message); // human-readable message
    console.error(err.status);  // HTTP status code (if available)
    console.error(err.body);    // raw response body (if available)
  }
}

Types

type ListingType = 'Sell' | 'Donate' | 'Wanted';

type Category =
  | 'Books'
  | 'Electronics'
  | 'Clothing & Accessories'
  | 'School Uniform'
  | 'Sports Equipment'
  | 'Toys'
  | 'Video Games'
  | 'Board Games'
  | 'Furniture'
  | 'Kitchen Items'
  | 'Household Items'
  | 'Jewelry & Watches';

type Condition = 'New' | 'Like New' | 'Good' | 'Fair';

interface User {
  id: string;
  name: string;
  email: string;
}

interface Session {
  user: User;
  token: string;
}

interface Listing {
  id: string;
  title: string;
  type: ListingType;
  price: number;
  category: Category;
  condition: Condition;
  description: string;
}

interface CreateListingInput {
  title: string;
  type: ListingType;
  price: number;
  category: Category;
  condition: Condition;
  description: string;
}