Integrations › TypeScript

Zapi for TypeScript

Typed calls to any source with zpi-sdk. Generate types for the endpoints you call and catch missing inputs at compile time.

LanguageNode 20+, Bun, Denozpi-sdk
  1. 01
    Install zpi-sdk

    Written in TypeScript, with ESM and CommonJS builds and no runtime dependencies.

    npm i zpi-sdk
  2. 02
    Set your API key

    Create a free key in the dashboard. zpi-sdk reads ZPI_API_KEY from the environment, so the key stays out of your code.

    export ZPI_API_KEY="zpi_..."
  3. 03
    Make a typed call

    run() returns the data field of the response. Annotate it with the fields you use and the rest of your code is typed.

    import { Zpi } from "zpi-sdk";
    
    type Profile = { username: string; followerCount: number; videoCount: number };
    
    // Reads ZPI_API_KEY from the environment
    const zpi = new Zpi();
    
    const profile: Profile = await zpi.run("social-media:tiktok-scraper/profile", {
      username: "tiktok",
    });
    console.log(profile.followerCount);
  4. 04
    Check params at compile time

    The zpi CLI finds the zpi.run() calls in your code, reads the live catalogue and writes their inputs to zpi.d.ts. A missing required input is then a compile error, not a runtime 400. Add --all for every source.

    npx zpi types

The response

200 OK
{
  "project": "social-media:tiktok-scraper:profile",
  "data": {
    "username": "tiktok",
    "nickname": "TikTok",
    "verified": true,
    "followerCount": 92400000,
    "videoCount": 1310
  },
  "timestamp": "2026-12-01T07:00:00.000Z"
}

Questions

Do I have to write the types myself?

Not for inputs: npx zpi types writes the params of every endpoint your code calls into zpi.d.ts. Results stay untyped until you annotate the fields you use, since each source returns the site’s own shape.

How are errors typed?

Every failure throws ZpiError or a subclass, such as ZpiAuthError for a bad key or ZpiRateLimitError for a 429. Each one carries code, retryable and requestId.

Does it work with CommonJS?

Yes. zpi-sdk ships both ESM and CommonJS builds and runs on Node.js 20 or newer, Bun, Deno and edge runtimes.

Your first call in a minute.

Free key, every source, and the same JSON shape from anywhere.