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.x | 1.0 |
|---|---|
| new ZpiClient({ apiKey }) | new Zpi() (reads ZPI_API_KEY) |
| run("cat:scraper", "endpoint", params) | run("cat:scraper/endpoint", params) |
| timeoutMs, defaultHeaders | timeout, headers |
| method, pathRest, useMethods(), ZPI_METHODS | Removed: nothing needs the HTTP method any more |
| stream() yields SseEvent | string | Every chunk is { data, event?, id?, json() } |
| bulk items { params: { … } } | Items are the params themselves, or a URL string |
| bulk.status(id), job.jobId | bulk.get(id), job.id |
| catalog.list({ cat }) | catalog.list({ category }) |
| ZpiPlanGateError, ZpiBulkNotEnabledError | ZpiPlanError |
| ZpiInvalidParamsError, ZpiBulkCapError, ZpiIdempotencyError | ZpiValidationError |
| ZpiExecError | ZpiScraperError |
| ZpiServerError, ZpiDisabledError, ZpiMethodNotAllowedError | ZpiServiceError |
| ZpiNetworkError, ZpiAbortError | ZpiConnectionError |
| parseWebhook(rawBody, { signature, secret }) | verifyWebhook(request | { body, signature }, { secret }) |
| npx zpi codegen, interface ScraperMap | npx zpi types, interface Endpoints (regenerate) |
| Default base URL api.zpi.web.id | api.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? ·