You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds a "Connection Reuse" section to the API reference overview, plus
two new rows in the Standard Response Headers table for `X-Cache-Status`
and `Alt-Svc`.
For polling clients, TLS handshake (150-200ms on a fresh connection)
dominates per-request latency on api.sharpapi.io — the server itself
returns in ~40-50ms TTFB. Reusing a TLS connection collapses the cost.
The new section explains keep-alive defaults, HTTP/2 multiplexing,
HTTP/3 via Alt-Svc, and points serverless / cold-start callers at
`/api/v1/stream` for real-time data.
ClosesMlaz-code/sharp-api-go#113.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: content/en/api-reference/overview.mdx
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -229,11 +229,45 @@ Every API response includes these headers:
229
229
|`X-RateLimit-Reset`|`1705804800`| Unix timestamp when the rate limit resets |
230
230
|`X-Data-Delay`|`0`| Data delay in seconds (`60` for Free, `0` for paid tiers) |
231
231
|`X-Request-Id`|`req_a1b2c3d4`| Unique request identifier for debugging and support |
232
+
|`X-Cache-Status`|`HIT`| Edge-cache state for this response (`HIT`, `MISS`, `STALE`, `BYPASS`). `STALE` means the edge briefly served slightly outdated content while revalidating against the origin — expected during transient origin slowness, not an error |
233
+
|`Alt-Svc`|`h3=":443"; ma=86400`| Indicates HTTP/3 (QUIC) is available on this host. Clients that opt in skip the TCP + TLS handshake on subsequent connections — see [Connection Reuse](#connection-reuse) below |
232
234
233
235
<Callouttype="info">
234
236
Include the `X-Request-Id` value when contacting support about a specific request.
235
237
</Callout>
236
238
239
+
## Connection Reuse
240
+
241
+
For polling clients, the dominant cost on a *fresh* connection to `api.sharpapi.io` is the TLS handshake — typically 150–200 ms — not the API server itself, which returns in ~40–50 ms once TCP + TLS are up. Reusing a single TLS connection across requests collapses subsequent calls to roughly the server-side TTFB.
242
+
243
+
```bash
244
+
# Fresh connection — first request pays full TCP + TLS:
-**HTTP/1.1 keep-alive is the default** in `curl`, Python `httpx` / `requests.Session()`, `aiohttp`, Node `fetch` / `axios` / `undici`, Go `http.Client`, OkHttp, and most other modern clients. Reuse a single client/session across calls — don't construct a new client per request.
263
+
-**HTTP/2 connection coalescing** multiplexes many concurrent requests over one connection to the same host. Enabled by default in HTTP/2-capable clients.
264
+
-**HTTP/3 (QUIC)** is offered via `Alt-Svc: h3=":443"`. Clients that opt in (`curl --http3`, `httpx[http2,http3]`, Node `undici` with `allowH2: true`) skip the TCP handshake entirely on subsequent connections. Worthwhile for cold-start workloads such as serverless functions.
265
+
-**For real-time data, use streaming.** The [`/api/v1/stream`](/en/api-reference/stream) endpoint keeps a single connection open and pushes deltas as they happen — no per-request handshake at all.
266
+
267
+
<Callouttype="info">
268
+
For a polling client hitting `/api/v1/odds` once per second, the TLS cost amortizes to ~0 after the first request. The 150 ms handshake matters most for serverless / short-lived clients that close the connection between calls.
0 commit comments