What monitors do
A monitor watches Tako data for a condition. When the condition occurs, Tako records a firing and posts a signed request to each notification channel on the monitor.- Base URL:
https://tako.com/api/ - Auth: every endpoint on this page takes your API key in the
X-API-Keyrequest header. Create a key in the Tako console. - Rate limits: the monitors and notification channels endpoints allow 120 calls per minute, and 20,000 per day, per user.
GET /v1/sports/gamesallows 60 calls per minute, and 5,000 per day. If you get a429, wait for the time in itsRetry-Afterheader when it has one. Otherwise, back off with jittered exponential retry. - Limits: by default, you can hold 1 active monitor and 2 notification channels. Tako counts these limits per user, not across an account. A
LIMIT_REACHEDresponse’slimitgives your cap. - Endpoints:
Minimal working example
This script monitors AAPL for a 3% daily rise, as in the Overview. It creates a channel and a monitor, then reads the monitor back. It needscurl and jq, and a TAKO_API_KEY environment variable. Replace the URL with an https endpoint that you control.
Notification channels
A notification channel is anhttps endpoint that Tako posts firings to. Create the channel before the monitor that uses it.
The
201 response is the only response that holds secret. Tako signs every delivery to the channel with it. See Verify the signature. If you lose the secret, delete the channel and create a new one.
Tako pauses a channel after 2 consecutive failed deliveries, and sets its status_reason to delivery_failures. Monitors that post to a paused channel keep recording firings, and no one receives them. To resume the channel, fix the endpoint, then send PATCH /v1/notification_channels/{id} with {"status": "active"}.
Monitor types
CallGET /v1/monitor_types before you create a monitor. The response is the authoritative list, and each item holds these fields:
The response also holds
firing_enabled. While it’s false, the environment accepts monitors and evaluates none of them.
stocks.pct_change and stocks.new_52w_extreme are state alerts. If you create one while its condition already holds, the next price update fires it. stocks.crosses does the same when the price has already crossed your level. On a delayed feed, that update arrives as late as the feed’s delay. crypto.crosses, forex.crosses, and sports.odds_crosses work the other way: if the price or the line has already reached your level, the create fails.Create a monitor
POST /v1/monitors takes these fields:
Check the resolved subject
Tako resolves your parameters to one subject when you create the monitor, and never resolves them again. Every monitor response holds that subject insubject. Check it before you rely on the monitor.
parameters comes back in the form that you send, with names as Tako resolved them. A ticker that you sent as aapl reads back as AAPL, with the exchange that Tako picked. A crypto monitor reads back its asset as a coinmarketcap_id, whichever name you created it with.
Handle a rejected create
A400 response holds an error_type:
Name a sports subject
Sports monitors take ids fromGET /v1/sports/games. Each row’s id is a game_id, and its home.id and away.id are team ids.
This script monitors every 49ers win, as in the Overview. It finds the 49ers’ team id, pauses the AAPL monitor to free the active monitor slot, then creates a sports.game_result monitor that follows the team. CHANNEL_ID is a channel that you created, and MONITOR_ID is the AAPL monitor from the Minimal working example.
league, team, status, from, and to. A row whose source is schedule_table comes from a schedule without a live feed, and a monitor rejects its ids.
For sports.game_start, sports.game_result, and sports.score_event, the ids combine this way:
game_idalone watches the whole game, and each firing reports both sides.team_idalone follows that team’s games as they come.game_idandteam_idtogether watch one team’s side of one game.
Receive a delivery
Each delivery is aPOST with a JSON body and these headers: webhook-id, webhook-timestamp, and webhook-signature. Tako follows the Standard Webhooks specification. For the full body, the verification code, and the payload fields for each type, see Webhook deliveries.
A receiver needs to do these things, in order:
- Verify
webhook-signatureagainst the raw request bytes, with the channel’s secret. Reject awebhook-timestampmore than 5 minutes from the current time. - Skip a
webhook-idthat you’ve already stored. Every retry of one delivery sends the same id. - Store the body, and respond with a
2xxwithin 10 seconds. - Do the slow work after you respond.
408, a 429, a 5xx, or no response, Tako retries it 5 times over about 4 hours. Tako doesn’t retry any other status, and doesn’t follow redirects. For the retry schedule, see How Tako retries.
Check a monitor that hasn’t fired
Read the monitor withGET /v1/monitors/{id}. last_evaluated_at says when Tako last evaluated it, and last_evaluation_outcome says what that evaluation found:
For every outcome, see the
last_evaluation_outcome schema in Get a monitor.
If the monitor is paused, status_reason says why: fired_once, expired, completed, or unloadable. It’s null when you paused the monitor yourself.
Check deliveries
GET /v1/monitors/{id}/firings lists the monitor’s firings, newest first. Each firing holds deliveries, with one entry for each channel:
The
deliveries list covers the last 30 days. Tako removes a firing that’s older than its type’s lookback window.
Change or remove a monitor
PATCH /v1/monitors/{id} changes two fields, and nothing else:
status: setpausedto stop evaluating the monitor, oractiveto resume it. Ifactive_untilhas passed, resuming returns400.channel_ids: replace the monitor’s channels with this list.
Common mistakes
Errors
A400, 401, or 404 returns { "error_message": "...", "error_type": "..." }. A 429 returns { "detail": "..." }.