This package provides a TypeScript/JavaScript client for interacting with the Kalshi API, automatically generated from an OpenAPI specification. It leverages `axios` for HTTP requests and is currently at version 3.13.0. The client supports both Node.js and browser environments, as well as ES5 and ES6 language levels, and CommonJS and ES6 module systems. As a generated client, its release cadence typically follows updates to the underlying Kalshi OpenAPI specification, meaning the client API surface can change with new spec versions. A key differentiator is its comprehensive type definitions, enabling robust development in TypeScript projects and providing compile-time safety for API interactions. It primarily targets the `https://api.elections.kalshi.com/trade-api/v2` endpoint.
npm install kalshi-typescriptVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes the Kalshi client with an API key and fetches a list of existing API keys, demonstrating basic authentication and API interaction.
Consult the Kalshi API documentation and the generated client's `docs/` folder for updated API endpoint and data model information. Regenerate local client if maintaining a fork.
Always use environment variables (e.g., `process.env.KALSHI_API_KEY`), a secure configuration management system, or dedicated secret management services to store and retrieve API keys, especially in production environments.
Ensure the `basePath` in your `Configuration` object matches the target Kalshi API environment (e.g., `https://api.elections.kalshi.com/trade-api/v2` for production). Verify this against the official Kalshi API documentation.
Verify that your `KALSHI_API_KEY` environment variable is correctly set and contains a valid, active API key from your Kalshi account. Ensure it has the necessary permissions for the API endpoint you are trying to access.
Wrap your API calls in a `try-catch` block and inspect the `error.response` object for details on the HTTP status code and error message. Ensure your API key is valid and the request parameters are correct.
Check the `kalshi-typescript` documentation (especially the `docs/` folder) for the correct method name and signature. Ensure your `kalshi-typescript` package is up-to-date with the latest version from npm.