Recipes
Copy. Paste. Ship.
End-to-end snippets for the workflows we hear about most. Drop them into your editor, swap your key in, and you've got a working integration.
Shown with a partner key. Trading your own account? Use your personal API path and send only Authorization: Bearer <your token>.
Example
Market screener
Page through every contest in a league and surface the markets with real depth behind them.
screener.ts
// No SDK yet — fetch is the client.
const BASE = "https://pulse.bettoredge.com/v1/your-slug";
const key = { "x-api-key": process.env.PULSE_API_KEY };
let cursor;
const liquid = [];
do {
const qs = new URLSearchParams({ league_id: "1", limit: "100" }); // ids from /leagues
if (cursor) qs.set("cursor", cursor);
const page = await (await fetch(BASE + "/markets/available?" + qs, { headers: key })).json();
for (const contest of page.contests) {
for (const market of contest.markets) {
// market.liquidity is already the sum of every line under it.
if (market.liquidity > 5000) {
liquid.push({
contest: contest.title,
market: market.description,
liquidity: market.liquidity,
});
}
}
}
cursor = page.next_cursor;
} while (cursor);
console.log(liquid.length + " markets over $5k");Example
Take the best price
Read a line, take it, and check what actually happened — the part most integrations get wrong.
place.ts
import os, requests
BASE = "https://pulse.bettoredge.com/v1/your-slug"
key = {"x-api-key": os.environ["PULSE_API_KEY"]}
# 1. Read the board and pick a line. Never construct an order_context_hash.
contests = requests.get(
BASE + "/markets/available", params={"event_id": "138847"}, headers=key
).json()["contests"]
side = contests[0]["markets"][0]["sides"][0]
if not side["lines"]:
raise SystemExit("nothing offered on this side yet")
line = side["lines"][0] # best price first
# 2. Place it. The token decides whose account is used, not your key.
res = requests.post(
BASE + "/orders/place",
json={
"order_context_hash": line["order_context_hash"],
"price": line["price"],
"amount": 10,
},
headers={**key, "authorization": "Bearer " + player_token},
)
# 3. 200 = accepted. A refusal is a 4xx with a code you can branch on.
if not res.ok:
err = res.json()["error"]
if err["code"] == "LOCATION_REQUIRED":
raise SystemExit("ask the player to open the BettorEdge app and confirm their location")
raise SystemExit(err["code"] + ": " + err["message"])
# Accepted is not filled: an order that does not match immediately RESTS, and partial
# fills are normal. Follow it on the stream (order.filled) or with order activity.
print(res.json()["order"])