The Boclips API Client is a JavaScript/TypeScript library designed to provide frontend applications with a structured interface for interacting with the Boclips API. Currently at version 113.5.2, this client likely follows a rapid release cadence, indicated by its high major version number, suggesting frequent updates aligned with backend API evolution. A key differentiator is its robust testing strategy leveraging Pact for contract testing, which generates contracts against a mock HTTP layer and then verifies them against the staging API gateway. This ensures client-backend compatibility without relying solely on brittle end-to-end integration tests. The library also includes a `FakeBoclipsClient` implementation, offering an in-memory test client that simplifies integration testing for consumer applications by removing the need for HTTP mocks. Users are expected to provide their own configured Axios instance, including authentication, to the client.
npm install boclips-api-clientVerified import paths — ran on the pinned version, not inferred.
Demonstrates the initialization of the `ApiBoclipsClient` with an Axios instance and how to access a sub-client to fetch data.
Ensure your `axios.create()` call includes headers for authentication or uses Axios interceptors to inject authorization tokens before passing the instance to `ApiBoclipsClient.initialize()`.
Always review the package's `CHANGELOG.md` or release notes when upgrading to a new major version. Test your application thoroughly against new client versions, especially after API updates.
If encountering issues like 'Invalid hook call' or strange dependency errors, try `pnpm unlink boclips-api-client` and install a published version. Ensure all dependencies of the linked package are also hoisted correctly or use tools like `yalc` for more robust local package linking scenarios.
Ensure you are using `import { ApiBoclipsClient } from 'boclips-api-client';` for modern JavaScript/TypeScript applications. Avoid `const ApiBoclipsClient = require('boclips-api-client');`.Verify that your `axiosInstance` is correctly configured with `Authorization` headers (e.g., `Bearer` token) before passing it to `ApiBoclipsClient.initialize`. Ensure your authentication token is valid and refreshed if necessary.
Ensure that `await ApiBoclipsClient.initialize(axios, prefix)` completed successfully and returned a valid client object. Check that the `prefix` is correct and the API is accessible. Verify that the sub-client (e.g., `collectionsClient`) actually exists in the current version of the library.