Docs › More › Migrating to 1.0

Migrating to 1.0

1.0 is a clean break from 0.x, with no compatibility aliases. Most apps change four things:

upgrade.ts
// 0.x
import { ZpiClient } from "zpi-sdk";
const client = new ZpiClient({ apiKey: process.env.ZPI_API_KEY });
await client.run("social:instagram", "profile", { username: "instagram" });

// 1.0
import { Zpi } from "zpi-sdk";
const zpi = new Zpi();
await zpi.run("social:instagram/profile", { username: "instagram" });
0.x1.0
new ZpiClient({ apiKey })new Zpi() (reads ZPI_API_KEY)
run("cat:scraper", "endpoint", params)run("cat:scraper/endpoint", params)
timeoutMs, defaultHeaderstimeout, headers
method, pathRest, useMethods(), ZPI_METHODSRemoved: nothing needs the HTTP method any more
stream() yields SseEvent | stringEvery chunk is { data, event?, id?, json() }
bulk items { params: { … } }Items are the params themselves, or a URL string
bulk.status(id), job.jobIdbulk.get(id), job.id
catalog.list({ cat })catalog.list({ category })
ZpiPlanGateError, ZpiBulkNotEnabledErrorZpiPlanError
ZpiInvalidParamsError, ZpiBulkCapError, ZpiIdempotencyErrorZpiValidationError
ZpiExecErrorZpiScraperError
ZpiServerError, ZpiDisabledError, ZpiMethodNotAllowedErrorZpiServiceError
ZpiNetworkError, ZpiAbortErrorZpiConnectionError
parseWebhook(rawBody, { signature, secret })verifyWebhook(request | { body, signature }, { secret })
npx zpi codegen, interface ScraperMapnpx zpi types, interface Endpoints (regenerate)
Default base URL api.zpi.web.idapi.zapi.ink

The full guide, with every option and the reasons behind each change, is MIGRATION.md.

Edit this page on GitHubWas this page helpful? ·