ApiReference
Un endpoint completo a partir de datos: firma, parámetros, solicitud, respuesta y errores, en ese orden. Para páginas hechas desde un archivo OpenAPI.
import ApiReference from '@sypnia/ui/astro/ApiReference.astro'
En esta página
Un endpoint
List rows
GET
/v1/tables/{table}/rows The rows of a table, 20 at a time, newest first.
Parámetros
-
limitintegeropcionalHow many rows, up to 100.Por defecto:
20 -
cursorstringopcionalWhere to go on from.
Solicitud
curl https://data.sypnia.com/v1/tables/orders/rows -H "Authorization: Bearer $SYPNIA_TOKEN" Respuesta200
{ "rows": [{ "id": 1042 }], "next": "c_9f2" } Errores
- 404
table_not_foundThere is no table with that name.
Código
---
// A whole endpoint from data, as an OpenAPI file would give it.
import ApiReference from '@sypnia/ui/astro/ApiReference.astro';
const endpoint = {
method: 'GET', path: '/v1/tables/{table}/rows', title: 'List rows', id: 'list-rows', auth: 'API token (read)',
summary: 'The rows of a table, 20 at a time, newest first.',
params: [{ name: 'limit', type: 'integer', required: false, default: 20, text: 'How many rows, up to 100.' }, { name: 'cursor', type: 'string', required: false, text: 'Where to go on from.' }],
request: { code: 'curl https://data.sypnia.com/v1/tables/orders/rows -H "Authorization: Bearer $SYPNIA_TOKEN"' },
response: { status: 200, code: '{ "rows": [{ "id": 1042 }], "next": "c_9f2" }' },
errors: [{ code: 404, name: 'table_not_found', text: 'There is no table with that name.' }],
};
---
<div class="sy-docs" style="min-height:0;background:none"><ApiReference endpoint={endpoint} /></div> Cuándo usarlo
Úsalo cuando
- Páginas de referencia generadas: un ApiReference por endpoint.
No lo uses cuando
- Páginas escritas a mano: arma tú mismo Endpoint, Params y los ejemplos.
Para todos
- Cada endpoint tiene un título, así aparece en «En esta página».