8000 first draft of all requests · optimizely/fx-api-cookbook@4e41bac · GitHub
[go: up one dir, main page]

Skip to content

Commit 4e41bac

Browse files
first draft of all requests
1 parent aea73f8 commit 4e41bac

File tree

7 files changed

+219
-1
lines changed

7 files changed

+219
-1
lines changed

.DS_Store

6 KB
Binary file not shown.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
./sa.demo.api.calls.har
21
.vscode/*

requests/5_create_audiences.rest

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// -------------------------------------------------------------------------- //
2+
// Create audiences. //
3+
// -------------------------------------------------------------------------- //
4+
5+
POST {{baseUrl}}/audiences
6+
Content-Type: application/json
7+
Authorization: {{token}}
8+
9+
{
10+
"conditions": "[\"and\",[\"or\",[\"or\",{\"name\":\"is_logged_in\",\"value\":false,\"match_type\":\"exact\",\"type\":\"custom_attribute\"}]]]",
11+
"name": "Anonymous Users",
12+
"project_id": 26592390574
13+
}
14+
###
15+
POST {{baseUrl}}/audiences
16+
Content-Type: application/json
17+
Authorization: {{token}}
18+
19+
{
20+
"conditions": "[\"and\",[\"or\",[\"or\",{\"name\":\"is_logged_in\",\"value\":true,\"match_type\":\"exact\",\"type\":\"custom_attribute\"}]]]",
21+
"name": "Authenticated Users",
22+
"project_id": 26592390574
23+
}
24+
###
25+
POST {{baseUrl}}/audiences
26+
Content-Type: application/json
27+
Authorization: {{token}}
28+
29+
{
30+
"conditions": "[\"and\",[\"or\",[\"or\",{\"name\":\"days_since_last_order\",\"type\":\"custom_attribute\",\"match_type\":\"le\",\"value\":14}]]]",
31+
"name": "Recent Purchasers",
32+
"project_id": 26592390574
33+
}
34+
###
35+
POST {{baseUrl}}/audiences
36+
Content-Type: application/json
37+
Authorization: {{token}}
38+
39+
{
40+
"conditions": "[\"and\",[\"or\",[\"or\",{\"name\":\"region_state\",\"type\":\"custom_attribute\",\"value\":\"CA\"}]]]",
41+
"name": "California Visitors",
42+
"project_id": 26592390574
43+
}
44+
###
45+
POST {{baseUrl}}/audiences
46+
Content-Type: application/json
47+
Authorization: {{token}}
48+
49+
{
50+
"conditions": "[\"and\",[\"or\",[\"or\",{\"name\":\"is_mobile_user\",\"value\":true,\"match_type\":\"exact\",\"type\":\"custom_attribute\"}]]]",
51+
"name": "Mobile Web Users",
52+
"project_id": 26592390574
53+
}
54+
###
55+
POST {{baseUrl}}/audiences
56+
Content-Type: application/json
57+
Authorization: {{token}}
58+
59+
{
60+
"conditions": "[\"and\",[\"or\",[\"or\",{\"name\":\"is_mobile_app\",\"value\":true,\"match_type\":\"exact\",\"type\":\"custom_attribute\"}]]]",
61+
"name": "Mobile App Users",
62+
"project_id": 26592390574
63+
}
64+
###
65+
POST {{baseUrl}}/audiences
66+
Content-Type: application/json
67+
Authorization: {{token}}
68+
69+
{
70+
"conditions": "[\"and\",[\"or\",[\"or\", {\"value\": true,\"type\": \"custom_attribute\",\"name\": \"is_qa\"}]],[\"or\",[\"or\",{\"name\":\"qa_team\",\"type\":\"custom_attribute\",\"value\":\"1\"}]]]",
71+
"name": "QA Team 1",
72+
"project_id": 26592390574
73+
}
74+
###
75+
POST {{baseUrl}}/audiences
76+
Content-Type: application/json
77+
Authorization: {{token}}
78+
79+
{
80+
"conditions": "[\"and\",[\"or\",[\"or\", {\"value\": true,\"type\": \"custom_attribute\",\"name\": \"is_qa\"}]],[\"or\",[\"or\",{\"name\":\"qa_team\",\"type\":\"custom_attribute\",\"value\":\"2\"}]]]",
81+
"name": "QA Team 2",
82+
"project_id": 26592390574
83+
}

requests/6_create_experiment.rest

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// ---------------------------------------------------------------------------- //
2+
// Create experiment. //
3+
// ---------------------------------------------------------------------------- //
4+
5+
// Hypothesis: showing the number of items left in stock on the PDP page will increase add to cart.
6+
// Goal Metric(s): add to cart rate.
7+
// Audience(s): Everyone
8+
// Ramp Percentage: 100%
9+
// Metrics: add_to_cart
10+
// Distribution Mode: manual
11+
// Variations: off (33%), On Show Amounts (33%), On Show Amounts Red (33%)
12+
13+
//TODO: Fix url
14+
PATCH {{flagsUrl}}/projects/{{projectId}}/flags/{{flagKey}}/environments/production/ruleset
15+
Content-Type: application/json
16+
Authorization: {{token}}
17+
18+
[
19+
{
20+
"op": "add",
21+
"path": "/rules/stock_message_test",
22+
"value": {
23+
"key": "stock_message_test",
24+
"name": "Stock Message Test",
25+
"type": "a/b",
26+
"distribution_mode": "manual",
27+
"percentage_included": 10000,
28+
"metrics": [
29+
{
30+
"aggregator": "unique",
31+
"display_title": "add_to_cart",
32+
"event_id": 25259131694,
33+
"event_type": "custom",
34+
"scope": "visitor",
35+
"winning_direction": "increasing"
36+
}
37+
],
38+
"variations": {
39+
"off": {
40+
"key": "off",
41+
"name": "Off",
42+
"percentage_included": 3333
43+
},
44+
"on_show_amounts": {
45+
"key": "on_show_amounts",
46+
"name": "On Show Amounts",
47+
"percentage_included": 3333
48+
},
49+
"on_show_amounts_red": {
50+
"key": "on_show_amounts_red",
51+
"name": "On Show Amounts Red",
52+
"percentage_included": 3334
53+
}
54+
},
55+
"audience_conditions": []
56+
}
57+
},
58+
{
59+
"op": "replace",
60+
"path": "/rule_priorities/0",
61+
"value": "stock_message_test"
62+
},
63+
{
64+
"op": "add",
65+
"path": "/rule_priorities/1",
66+
"value": "td"
67+
}
68+
]
69+

requests/7_launch_experiment.rest

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// -------------------------------------------------------------------------- //
2+
// Launch experiment. //
3+
// -------------------------------------------------------------------------- //
4+
5+
// ------------------------------- Enable Flag ------------------------------ //
6+
7+
POST https://api.app.optimizely.com/flags/projects/25276451226/flags/inventory_on_pdp/environments/production/ruleset/enabled
8+
Authorization: {{token}}
9+
10+
11+
12+
###
13+
14+
// ---------------------------- Launch Experiment --------------------------- //
15+
16+
//TODO: test url
17+
PATCH {{flagsUrl}}/projects/25276451226/flags/inventory_on_pdp/environments/production/ruleset
18+
Content-Type: application/json
19+
Authorization: {{token}}
20+
21+
[{"op":"replace","path":"/rules/stock_message_test/enabled","value":true}]

requests/8_conclude_experiment.rest

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# ---------------------------------------------------------------------------- #
2+
# Conclude experiment. #
3+
# ---------------------------------------------------------------------------- #
4+
5+
PATCH {{flagsUrl}}/projects/{{projectId}}/flags/{{flagKey}}/environments/production/ruleset
6+
Content-Type: application/json
7+
Authorization: {{token}}
8+
9+
[{"op":"replace","path":"/rules/stock_message_test/enabled","value":false}]

requests/9_analyze_results.rest

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// -------------------------------------------------------------------------- //
2+
// Analyze results. //
3+
// -------------------------------------------------------------------------- //
4+
5+
// ----------- Get All Experiments in Project => Get Experiment Key ---------- //
6+
7+
GET {{flagsUrl}}/projects/{{projectId}}/rules?rule_types=a/b,mab&archived=false&environments=production&per_page=100
8+
Content-Type: application/json
9+
Authorization: {{token}}
10+
11+
// Grab the relevant experiment key from the response, if you don't already have it (e.g., stock_message_test).
12+
13+
###
14+
15+
// ------------------------- Get Experiment Reports ------------------------- //
16+
GET {{flagsUrl}}/projects/{{projectId}}/environments/production/reports?sort=key:asc&archived=false
17+
Content-Type: application/json
18+
Authorization: {{token}}
19+
20+
// Grab the relevant report key for the experiment of interest (e.g., stock_message_test_W9PHyDfYDiGdoqwuU9ANR4)
21+
22+
###
23+
24+
// -------------------- Get Individual Experiment Report -------------------- //
25+
GET {{flagsUrl}}/projects/{{projectId}}/environments/production/reports/{yourReportKey}
26+
Content-Type: application/json
27+
Authorization: {{token}}
28+
29+
// Grab the relevant experiment results ID from the end of the fetch_results_ui_url key in the response
30+
31+
// ------------------------- Get Experiment Results ------------------------- //
32+
33+
// Add the experiment results from the previous response ID to the URL below.
34+
35+
GET {{baseUrl}}/experiments/{yourExperimentResultsId}/results
36+
Content-Type: application/json
37+
Authorization: {{token}}

0 commit comments

Comments
 (0)
0