Black Friday tra 20 giorni: i Suoi clienti potranno pagare? -25 % il 1° anno e configurazione offerta, fino al 30 novembreVedi l’offerta →
Integrazione
Client npm ufficiale: creare scenari, paginare, Idempotency-Key e Retry-After.
Ottenere la mia chiave APIContratto OpenAPI
Documento completo, senza autenticazione, da passare al Suo generatore di client.
Pacchetto npm @pathly/sdk (monorepo, createChain per una Chain). Client HTTP senza pesanti dipendenze di runtime: Idempotency-Key, Retry-After, paginazione con cursore. Il pacchetto npm pathly-sdk 0.1 accetta httpChain su createScenario, senza helper.
Passi PATHLY_API_TOKEN al costruttore PathlyClient. URL di base predefinito: https://api.pathlyhq.com. Per uno smoke post-deploy, combini questo SDK con la GitHub Action (run-scenario) o un job curl su /v1.
Installare, Ping e Chain
npm i @pathly/sdk
export PATHLY_API_TOKEN=sp_…
import { PathlyClient } from "@pathly/sdk";
const client = new PathlyClient({ token: process.env.PATHLY_API_TOKEN });
const ping = await client.createScenario({
name: "Checkout",
url: "https://www.example.com/cart",
intervalSec: 300,
expectText: "Your cart",
});
const chain = await client.createChain({
name: "Login then /me",
intervalSec: 300,
hops: [
{ name: "Login", method: "POST", url: "https://api.example.com/login", assertStatus: 200 },
{ name: "Me", method: "GET", url: "https://api.example.com/me", assertStatus: 200 },
],
});
console.log(ping.id, chain.id);Elencare con paginazione
for await (const row of client.paginate((cursor) => client.listScenarios({ cursor }))) {
console.log(row.id, row.name);
}ESM one-liner (CI)
node --input-type=module -e "import { PathlyClient } from '@pathly/sdk'; const c=new PathlyClient({ token: process.env.PATHLY_API_TOKEN }); console.log(await c.listScenarios());"