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 this HTTP API is available for direct use, 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 there isn't an SDK available 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
An API key is required in every API request. There are two types of API keys you can use with the HTTP API:
- Server-side secret Key: Used only from secure servers and should never be exposed 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 is built on HTTPS. Authenticate using the
statsig-api-keyheader. All API requests use the POST method, and parameters are passed 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 are used to calculate metrics like analytics lift.
Was this helpful?