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

@codex-data/sdk

v2.0.1

Published

The Codex SDK for JavaScript/Typescript. It provides generated types and convenient ways to access the graphql api.

Readme

Codex SDK

This package exists to help you develop on top of the Codex API (https://docs.codex.io).

It provides generated TypeScript types and convenient methods to access the GraphQL API with full type safety.

[!NOTE] We've changed our name from Defined to Codex.

You will see references to our previous company name, Defined, while we make the switch to Codex.

Features

  • 🚀 Fully Typed: Generated TypeScript types for all GraphQL operations
  • 📦 Tree Shakeable: ESM support with optimized bundle size
  • 🔄 Real-time: WebSocket subscriptions support
  • 🛠 Developer Friendly: Comprehensive examples and documentation

Installation

| Package Manager | Command | | ----------------------------- | ----------------------------- | | npm | npm install @codex-data/sdk | | yarn | yarn add @codex-data/sdk | | pnpm | pnpm add @codex-data/sdk |

Usage

Follow one of the examples in the examples directory, or simply run.

Fetch a token.

import { Codex } from "@codex-data/sdk";

const sdk = new Codex(MY_API_KEY);

sdk.queries
  .token({
    input: {
      address: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
      networkId: 56,
    },
  })
  .then(console.log);

Use your own GraphQL selections

import { Codex } from "@codex-data/sdk";

const sdk = new Codex(process.env.CODEX_API_KEY || "");

// Using the raw GraphQL client
sdk
  .send<{ getNetworks: Array<{ id: string; name: string }> }>(
    `
  query GetNetworks {
    getNetworks { id name }
  }
`,
    {},
  )
  .then((res) => {
    console.log("Networks: ", res.getNetworks);
  });

Subscribe to real-time data

import { Codex } from "@codex-data/sdk";

const sdk = new Codex(process.env.CODEX_API_KEY || "");

// Subscribe to price updates
sdk.subscriptions.onPriceUpdated(
  {
    address: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
    networkId: 56,
  },
  (result) => {
    if (result.data) {
      console.log("Price updated:", result.data.onPriceUpdated);
    }
  },
);

Development

Prerequisites

  • Node.js >= 17.5.0
  • pnpm (recommended) or npm/yarn
  • curl for fetching the GraphQL schema

Building from Source

# Install dependencies
pnpm install

# Build the SDK
pnpm run build

Running Examples

All examples require a Codex API key. Get your API key at docs.codex.io.

Simple Example

Basic usage with inline GraphQL queries:

cd examples/simple
pnpm install
CODEX_API_KEY=your_api_key pnpm run dev

Codegen Example

Shows how to use GraphQL Code Generator for fully typed queries:

cd examples/codegen
pnpm install
pnpm run codegen
CODEX_API_KEY=your_api_key pnpm run dev

Next.js Example

Full-stack example with a Next.js application:

cd examples/next
pnpm install
NEXT_PUBLIC_CODEX_API_KEY=your_api_key pnpm run dev

Package Structure

The SDK is built with modern tooling and provides both CommonJS and ESM builds:

@codex-data/sdk/
├── dist/
│   ├── index.js      # CommonJS entry point
│   ├── index.mjs     # ESM entry point
│   ├── index.d.ts    # TypeScript definitions
│   └── sdk/          # SDK implementation
├── README.md
└── package.json

Contributing

We welcome contributions! Please feel free to submit a Pull Request.

Development Scripts

  • pnpm run build - Build the SDK for production
  • pnpm run test - Run the test suite
  • pnpm run lint - Lint the codebase
  • pnpm run clean - Clean build artifacts

Releasing

Publishing Beta Versions

For testing releases before making them public:

  1. Update the version in package.json to a beta version:

    "version": "2.0.0-beta.0"
  2. Publish to the beta tag:

    pnpm run publish:beta
  3. Test the beta version:

    npm install @codex-data/sdk@beta

Users installing without the @beta tag will continue to receive the latest stable version.

Publishing Production Releases

  1. Update the version in package.json to a production version:

    "version": "2.0.0"
  2. Publish to the latest tag:

    pnpm run publish:latest

Note: The prepublishOnly script automatically runs the full build before publishing, ensuring the package is always built before release.

Upgrading to 2.0.0+

There are a few breaking changes in 2.0.0 that you need to be aware of.

Imports

Before

import { Codex } from "@codex-data/sdk";
import { TokenRankingAttribute, RankingDirection } from "@codex-data/sdk/dist/sdk/generated/graphql";

After

import { Codex, TokenRankingAttribute, RankingDirection } from "@codex-data/sdk";

Before

import { Codex, GraphQL } from "@codex-data/sdk";

const [quoteToken, setQuoteToken] = useState<GraphQL.QuoteToken>(GraphQL.QuoteToken.Token0);

After

import { Codex, QuoteToken } from "@codex-data/sdk";

const [quoteToken, setQuoteToken] = useState<QuoteToken>(QuoteToken.Token0);

onLaunchpadTokenEventBatch

Before

const unsubscribeFn = codex.subscriptions.onLaunchpadTokenEventBatch(
  {
    networkId: networkId
  }
)

After

const unsubscribeFn = codex.subscriptions.onLaunchpadTokenEventBatch(
  {
    input: {
      networkId: networkId
    }
  }
)