One response format for thousands of endpoints
Why every hoshime endpoint answers with data and meta, RFC 9457 errors and opaque cursors, and the naming rules that make code portable across platforms.
An API that wraps hundreds of sources has a choice: pass each source’s shape through, or pick one shape and translate everything into it. Passing through is cheaper to build. It is also why most scraping APIs feel like a pile of unrelated APIs behind one key.
hoshime picks one shape. This post is about what it is and why.
The envelope
Every public data endpoint answers with two keys:
{
"data": { "id": "dQw4w9WgXcQ", "title": "…" },
"meta": { "requestId": "req_…", "platform": "youtube", "endpoint": "video", "cached": false, "fetchedAt": "2026-11-06T15:41:53Z", "units": 1 }
}
data is the thing you asked for: an object, or an array for a list. It is never null. meta is everything about the call: what it was, when the source was read, whether it came from the cache, and what it billed. Keeping those apart means your code never has to guess whether count is a field of the item or of the response.
Errors you can branch on
Errors are RFC 9457 problem details with a stable code. detail is for people and may change; code never does. A 400 also lists each bad parameter, so a form, or an AI agent, can point at the field that was wrong.
The codes are few on purpose: invalid_parameter, not_found, rate_limited, upstream_error, upstream_blocked, timeout. Retry the last four. Do not retry the first two.
Names that mean the same thing everywhere
The part that took the most work is the field names. Every platform calls things differently: play_count, views, viewCount, stats.plays. hoshime has one rule per kind of value:
- counts end in
Countand are integers - times end in
Atand are RFC 3339 strings - ids are strings, because some do not fit a JSON number
- money is a decimal string with a currency, so no digit is lost
- every key is always present, with
"",0ornullwhen the source does not say
On top of the rules sit common shapes: a Video is a video on YouTube, TikTok, bilibili or Dailymotion, with the same fields. A Ticker is a ticker on Binance, Bitstamp or Indodax.
Checked, not hoped for
Rules in a style guide drift. These are checked twice: every endpoint’s declared type is checked when the code builds, and every live answer is checked by the daily health check, which flags answers with bad data as failures. The OpenAPI document is generated from the same types, so the docs describe the JSON the API actually sends.
The payoff is simple: write the code for one endpoint, and it mostly works for the next one.