Referencia

Errores

Esta referencia está en inglés. La navegación y las etiquetas están traducidas.

Errors use standard HTTP status codes and an application/problem+json body (RFC 9457) with a stable code you can switch on.

Error format

400 invalid_query400
{
  "type": "https://yieldsniper.finance/developers/errors#invalid_query",
  "title": "Invalid query",
  "status": 400,
  "code": "invalid_query",
  "detail": "Unknown field \"yield.apy\".",
  "position": 0,
  "request_id": "req_5670f65858310f3c37f932e4"
}
TypeScript
const res = await fetch(url, { headers })
if (!res.ok) {
  const problem = await res.json()
  switch (problem.code) {
    case 'rate_limited':
      await sleep(Number(res.headers.get('Retry-After') ?? 1) * 1000)
      break
    case 'invalid_query':
      console.error(problem.detail, 'at', problem.position)
      break
    default:
      throw new Error(`${problem.code} (${problem.request_id})`)
  }
}

Codes