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

@surf-ai/sdk

v1.0.5

Published

Surf platform SDK — data API client, server runtime, and database helpers

Readme

@surf-ai/sdk

Surf SDK 1.0 for backend apps, typed Surf data access, and database helpers.

Install

bun add @surf-ai/sdk

Configuration

SDK 1.0 uses a single direct-auth model.

| Env Var | Default | Purpose | | --- | --- | --- | | SURF_API_BASE_URL | https://api.asksurf.ai/gateway/v1 | Full Surf API base URL | | SURF_API_KEY | none | Bearer token used for upstream requests and protected runtime endpoints | | BACKEND_PORT | none | Express server port when createServer({ port }) is not provided |

All upstream SDK requests use:

Authorization: Bearer <SURF_API_KEY>

Subpath exports

| Import | What it provides | | --- | --- | | @surf-ai/sdk/server | createServer(), dataApi | | @surf-ai/sdk/db | dbProvision(), dbQuery(), dbTables(), dbTableSchema(), dbStatus() |

Data API usage

const { dataApi } = require('@surf-ai/sdk/server')

const btc = await dataApi.market.price({ symbol: 'BTC', time_range: '1d' })
const holders = await dataApi.token.holders({
  address: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
  chain: 'ethereum',
})

// Escape hatch for endpoints that do not have a typed helper yet.
const custom = await dataApi.get('market/price', { symbol: 'ETH', time_range: '1d' })

Available categories include:

  • market
  • token
  • wallet
  • onchain
  • social
  • project
  • news
  • exchange
  • fund
  • search
  • web
  • polymarket
  • kalshi
  • prediction_market

Server runtime

const { createServer } = require('@surf-ai/sdk/server')

createServer({ port: 3001 }).start()

createServer() provides:

  • Auto-loading of routes/*.js and routes/*.ts as /api/{name}
  • GET /api/health
  • POST /api/__sync-schema
  • GET/POST/PATCH/DELETE /api/cron
  • POST /api/cron/:id/run
  • Schema sync on startup and when db/schema.js changes

GET /api/health is public.

These runtime endpoints require Authorization: Bearer <SURF_API_KEY>:

  • POST /api/__sync-schema
  • GET /api/cron
  • POST /api/cron
  • PATCH /api/cron/:id
  • DELETE /api/cron/:id
  • POST /api/cron/:id/run

Routes you define in routes/* stay public unless your app adds its own auth.

Example route:

const router = require('express').Router()
const { dataApi } = require('@surf-ai/sdk/server')

router.get('/', async (_req, res) => {
  const data = await dataApi.market.price({ symbol: 'BTC', time_range: '1d' })
  res.json(data)
})

module.exports = router

Database helpers

const { dbProvision, dbQuery, dbTables, dbTableSchema, dbStatus } = require('@surf-ai/sdk/db')

await dbProvision()
const result = await dbQuery('SELECT * FROM users WHERE id = $1', [123], { arrayMode: true })
const tables = await dbTables()
const schema = await dbTableSchema('users')
const status = await dbStatus()

Define tables in db/schema.js and the runtime will provision the database and create missing tables and columns during startup.

Example schema:

const { pgTable, serial, text, timestamp } = require('drizzle-orm/pg-core')

exports.users = pgTable('users', {
  id: serial('id').primaryKey(),
  name: text('name').notNull(),
  email: text('email'),
  created_at: timestamp('created_at', { withTimezone: true }).defaultNow(),
})

1.0 migration notes

  • SURF_API_BASE_URL and SURF_API_KEY are the only supported SDK auth variables.
  • The runtime no longer mounts /proxy/*.
  • The @surf-ai/sdk/react subpath has been removed.
  • Route modules must export the handler directly with module.exports = router.
  • createServer() requires a port from options.port or process.env.BACKEND_PORT.