The `circle-client` package provides a JavaScript and TypeScript client for interacting with the CircleCI v2 API. It allows developers to programmatically manage CI/CD pipelines, retrieve workflow and job insights, manage contexts and environment variables, and access user and project details. Currently at version `0.2.4`, the library is in a pre-1.0 development phase, which implies that minor versions may introduce breaking changes. It ships with comprehensive TypeScript definitions, offering a strongly-typed interface for API interactions, which significantly enhances developer experience and reduces common API-related errors. Key differentiators include its direct mapping of CircleCI v2 API endpoints to client methods, simplified handling of paginated results through a `Paged<T>` object, and a focus on abstracting the underlying HTTP request complexities, making it easier to integrate CircleCI operations into Node.js applications.
npm install circle-clientVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes the CircleCI client using an API token and demonstrates fetching the current user's details and listing recent project pipelines. It highlights the use of `process.env` for secure token handling and shows how to interact with paginated results.
Always pin to exact versions (e.g., `"circle-client": "0.2.4"`) and review the changelog carefully when updating to new minor versions.
Exercise caution when building critical functionality on 'Preview' endpoints. Monitor the official CircleCI API documentation for updates and be prepared for potential breaking changes.
Ensure your code explicitly accesses `pagedResult.items` to get the array of results and handles `pagedResult.next_page_token` for iterative fetching of subsequent pages.
Store API tokens securely using environment variables (`process.env`), secret management services, or encrypted configuration files. Never hardcode tokens in your application code.
Update your import statements to use ES Module syntax: `import CircleCI from 'circle-client';`. Ensure your `package.json` specifies `"type": "module"` if you are running pure ESM in Node.js, or use a transpiler like Babel or TypeScript.
Remember that `list` methods return a `Paged<T>` object; access results via `response.items`. Always add optional chaining (`?.`) or null checks (`if (item)`) when accessing properties of API response objects, as certain fields might be optional or absent.
Convert your project slug string into the specified array format: `slug: ['github', 'owner', 'repo']`.
No dependency data recorded yet.