A Cycle API client for the Web/NodeJS
This is an auto-generated API client based on the OpenAPI Spec for Cycle. Please do not open any PRs for the generated code under /src/generated. If you have any questions on what changes are made in the latest version, please refer to the spec above.
This client utilizes openapi-typescript to generate the type definitions for our client. The client itself is a pre-built openapi-fetch client for convenience.
Every request should be typesafe, and only endpoints described in the spec will be valid in Typescript as the first parameter to GET
, POST
, PATCH
, or DELETE
npm i @cycleplatform/api-client-typescript
import { client } from "@cycleplatform/api-client-typescript";
const client = getClient({
apiKey: "<your-api-key>",
hubId: "<your-hub-id>",
});
const resp = await client.GET("/v1/containers/{containerId}", {
params: {
path: {
containerId: "<container-id>",
},
},
});
console.log(resp.data, resp.error);
In some cases it may be necessary to override the default URL of https://api.cycle.io
. For example, if you are running a custom Cycle core, your API endpoint will be different than the default.
import { client } from "@cycleplatform/api-client-typescript";
const baseUrl = "https://api.my-company.cycle.io";
const client = getClient({
baseUrl,
apiKey: "<your-api-key>",
hubId: "<your-hub-id>",
});
const resp = await client.GET("/v1/containers/{containerId}", {
params: {
path: {
containerId: "<container-id>",
},
},
});
console.log(resp.data, resp.error);
git submodule update --recursive --remote
To build a local copy of this client, run npm run build:lib
to create a ./dist
folder with the necessary files.
npm run test:ts && npm run test