Retrieve data from your endpoint with an OpenAPI SDK
Contents
Generate type-safe SDKs for any language from your PostHog endpoints using OpenAPI.
Get your OpenAPI spec
Each endpoint exposes an OpenAPI 3.0 specification:
Terminal
To get the spec for a specific version:
Terminal
Example OpenAPI spec
Here's what an OpenAPI spec looks like for an endpoint called events_by_day:
JSON
Generate a typed client
Use openapi-typescript to generate TypeScript types:
Terminal
Create a typed client:
typescript
Then use it with full type safety:
typescript
Supported generators
OpenAPI Generator supports 50+ languages including:
- TypeScript (fetch, axios, node)
- Python (urllib3, asyncio)
- Go
- Ruby
- Java
- C#
- Rust
- Swift
- Kotlin
See the full list at openapi-generator.tech/docs/generators.