This repo contains API recipes to get started with Optimizely Feature Experimentation (FX). π©βπ³
We'll walk through some of the most common operations in the lifecycle of an experiment using the Optimizely APIs. π§ͺ
To get started with this API cookbook, first complete the below setup.
If you're not an existing enterprise customer, create a completely free feature flagging account with Optimizely here (no credit card required!).
We'll be using VS Code as a REST client make requests to the Optimizely APIs. Use the below links to install your IDE (integrated development environment) and needed extensions:
- VS Code
- Rest Client (REST Client extension for VS Code)
Follow these steps to get a personal access token to the Optimizely APIs.
Next, we'll setup VS Code so we can make requests to the Optimizely APIs.
Let's create some environment variables for the Optimizely API endpoints and your personal access token that we can reuse across API requests.
In VS Code, create a directory named .vscode
in the root of your project. In this directory, create a file named settings.json
and copy and paste the below into the file. Make sure to replace {{token}}
with your personal access token and {{yourProjectId}}
with your project ID (you can find this in the URL from the app homepage, e.g. https://app.optimizely.com/v2/projects/{{your ProjectId}}/flags/list
):
{
"rest-client.environmentVariables": {
"$shared": {
"flagsUrl": "https://api.optimizely.com/flags/v1",
"baseUrl": "https://api.optimizely.com/v2",
"token": "Bearer {{yourToken}}",
"projectId": {{yourProjectId}}
}
}
}
You can find more information on adding environment variables here.
Now we'll execute some of the most common operations in the lifecycle of an experiment via the Optimizely APIs, including:
- Create a feature flag and flag variables.
- Create variations.
- Create events.
- Create attributes.
- Create audiences.
- Create an experiment.
- Launch the experiment.
- Conclude the experiment.
- Analyze results.
Each of the above sections has its own .rest
file in the requests
directory of this repo. At this point, the directory structure of your p
5733
roject should be as follows:
π¦fx-api-recipes
β£ π.vscode
β β πsettings.json
β£ πrequests
β β£ π1_create_flag.rest
β β£ π2_create_variations.rest
β β£ π3_create_events.rest
β β£ π4_create_attributes.rest
β β£ π5_create_audiences.rest
β β£ π6_create_experiment.rest
β β£ π7_launch_experiment.rest
β β£ π8_conclude_experiment.rest
β β π9_analyze_results.rest
β πreadme.md
To execute the requests, open each .rest
file in VS Code and click the Send Request
link above the request.
For more information on how to send requests using the REST Client extension, see here.