Genesis Arbitrage

Genesis Arbitrage · · 3 min read

API polling

API polling is getting fresh data through repeated requests on a schedule: every N seconds the client asks the server what has changed. Bots and dashboards work this way with a REST API, which never sends anything on its own: each poll is a plain HTTP GET.

Interval and data freshness

Polling faster than the data updates gains nothing: the server returns the same snapshot. In Genesis API, data freshness depends on the plan: the output refreshes every 60 seconds on Trial, 30 on Start, 10 on Pro and 5 on Max, and that value comes in the meta.freshness_sec field. The snapshot build time is in meta.updated_at; the same value in two responses in a row means the second request was wasted.

Hypothetical example: on Trial a bot polls an endpoint every 10 seconds. Of the six requests a minute only one brings new data; the other five repeat the snapshot and still use quota unless the bot sends If-None-Match.

import os
import time
import requests

URL = "https://api.genesisarbitrage.com/v1/arbitrage/spot-spot"
HEADERS = {"X-API-Key": os.environ["GENESIS_API_KEY"]}

while True:
    r = requests.get(URL, headers=HEADERS,
                     params={"min_spread": 1}, timeout=10)
    if r.status_code in (429, 503):
        time.sleep(int(r.headers.get("Retry-After", "5")))
        continue
    r.raise_for_status()
    meta = r.json()["meta"]
    print("pairs:", meta["count"], "snapshot:", meta["updated_at"])
    # polling faster than the plan's refresh step is pointless
    time.sleep(meta["freshness_sec"])

How many calls polling uses

Polling one endpoint every 10 seconds: 2,592,000 ÷ 10 = 259,200 calls in 30 days. The Genesis API quota also covers 30 days.

Plan and quotaInterval = freshnessCalls per endpointEndpoints within quota
Trial, 500K60 s43,20011
Start, 2M30 s86,40023
Pro, 5M10 s259,20019
Max, 10M5 s518,40019

The math ignores 304 responses. On Pro, 19 endpoints every 10 seconds average 1.9 requests per second against a limit of 5. Spread the requests out: 19 requests at once would exceed the limit, and the server would answer with HTTP 429.

Polling, WebSocket and webhooks

MethodWho starts the transferGood for
PollingThe client, on a scheduleData that updates at a known step; any HTTP client will do
WebSocketThe server, over an open connectionA continuous stream of changes: exchange order books and trades
WebhookThe server, with a request to your URLRare events, if you have a public HTTPS endpoint

Genesis API has no WebSocket and no webhooks: data is served over REST, and the plan sets the freshness. Polling at meta.freshness_sec is the standard way to work with it; ways to cut traffic and calls are in How to poll an API without hitting limits.

See also: rate limit, plans and limits in the docs, response format, Genesis API limits.

Questions and answers

How often should I poll Genesis API?

No more often than your plan's meta.freshness_sec: every 60 seconds on Trial, 30 on Start, 10 on Pro and 5 on Max. Polling faster returns the same data.