HTTP API
Overview of the Statsig HTTP API for retrieving feature gate, experiment, and dynamic config values and logging events directly without an SDK.
While you can use this HTTP API directly, Statsig strongly recommends using an official SDK for your programming language whenever possible. SDKs offer better performance, automatic error handling, and type safety. They also provide a more idiomatic integration with your codebase. Only use this HTTP API directly if no SDK exists for your language or if you have a specific use case that requires direct API access.
Before calling the server APIs, complete the following steps:
Create a free account on Statsig
Create a free account on the Statsig sign-up page.An account gives you access to the Statsig Console, where you can manage your Feature Gates, Dynamic Configs, and Experiments. You can also invite others to collaborate on your Statsig projects so they can interact with your gates and configs.
Get an API key from the Statsig Console
Every API request requires an API key. There are two types of API keys you can use with the HTTP API:
- Server-side secret Key: Use only from secure servers, and never expose in client-side code.
- Client-SDK Key: Safe to embed in mobile apps and front-end web apps.
If you're working with server-side logic or sensitive data, use the Server-side secret Key. If you're in doubt or working with public-facing code, use the Client-SDK Key.
Issue API requests
The API runs on HTTPS. Authenticate using the
statsig-api-keyheader. All API requests use the POST method, and you pass parameters as a JSON object in the request body.Why POST? Even for fetching data, Statsig uses POST to ensure secure and flexible transmission of user-specific data (e.g., configurations or experiment results).
Statsig automatically logs exposure events whenever you call the APIs. These exposure events help attribute downstream events to experiments or feature gates, and Statsig uses them to calculate metrics like analytics lift.
Was this helpful?