Logo di Api Design

Api Design

Community
kazdenc
api-design

RESTful API design conventions covering URL structure, HTTP methods, error formats, pagination, versioning, and authentication patterns. Use when designing, reviewing, or implementing APIs. Triggers on API design, endpoint structure, REST conventions, or backend architecture tasks.

Panoramica

Autorekazdenc
Repositorybuilder-skills
Nome della skillapi-design
Stelle
46
Fork
5
File inclusi
Solo istruzioni
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da kazdenc su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Api Design in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/kazdenc/builder-skills/tree/main/.claude/skills/dev/frameworks/api-design
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Nuova skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella nella cartella delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/kazdenc/builder-skills.git /tmp/builder-skills
mkdir -p .claude/skills
cp -r /tmp/builder-skills/.claude/skills/dev/frameworks/api-design .claude/skills/api-design
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Api Design in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Api Design non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Api Design non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

API Design

Apply these conventions when designing, reviewing, or implementing RESTful APIs. Consistency matters more than cleverness — follow the patterns below.

URL Structure

Use nouns for resources, not verbs. Resources are things, not actions.

RuleCorrectIncorrect
Plural nouns/users, /orders/user, /getOrders
Nouns, not verbsPOST /usersPOST /createUser
Kebab-case for multi-word/line-items/lineItems, /line_items
Nest for relationships (max 2 levels)/users/:id/orders/users/:id/orders/:orderId/items/:itemId
Flat when parent is obvious/orders/:orderId/items/users/:userId/orders/:orderId/items

Query Parameters

Use query parameters for filtering, sorting, searching, and pagination. Never encode these in the URL path.

GET /users?status=active&sort=-created_at&limit=20&cursor=abc123
GET /orders?user_id=42&min_total=100&fields=id,status,total
ParameterConventionExample
FilterField name as key?status=active&role=admin
SortField name, prefix - for descending?sort=-created_at,name
Searchq parameter?q=john
Field selectionfields comma-separated?fields=id,name,email
Paginationcursor or offset/limit?cursor=abc&limit=20

HTTP Methods

MethodPurposeIdempotentRequest BodySuccess CodeResponse Body
GETRetrieve resource(s)YesNo200Resource or collection
POSTCreate a new resourceNoYes201Created resource
PUTReplace a resource entirelyYesYes200Updated resource
PATCHPartially update a resourceNo*Yes200Updated resource
DELETERemove a resourceYesNo204No body

*PATCH is not inherently idempotent but can be implemented as such. Treat it as non-idempotent by default.

Key rules:

  • GET must never mutate state. Ever.
  • PUT replaces the entire resource — omitted fields are removed or reset to defaults.
  • PATCH updates only the fields included in the body.
  • POST to a collection creates a new resource. Return the created resource with its id.
  • DELETE should succeed silently if the resource is already gone (idempotent).

Status Codes

Use the most specific appropriate code. Don't return 200 for everything.

2xx — Success

CodeMeaningUse When
200 OKRequest succeededGET, PUT, PATCH success
201 CreatedResource createdPOST success — include Location header
204 No ContentSuccess, no bodyDELETE success, or PUT/PATCH when no body is needed

4xx — Client Error

CodeMeaningUse When
400 Bad RequestMalformed requestInvalid JSON, missing required fields, validation failures
401 UnauthorizedNot authenticatedMissing or invalid authentication token
403 ForbiddenAuthenticated but not allowedUser lacks permission for this action
404 Not FoundResource doesn't existID not found, or route doesn't exist
405 Method Not AllowedWrong HTTP methodPOST to a read-only resource
409 ConflictState conflictDuplicate creation, version mismatch
422 Unprocessable EntitySemantic validation failureValid JSON, but business rules violated
429 Too Many RequestsRate limit exceededInclude Retry-After header

5xx — Server Error

CodeMeaningUse When
500 Internal Server ErrorUnexpected failureUnhandled exception — log it, don't leak details
502 Bad GatewayUpstream failureA dependency returned an invalid response
503 Service UnavailableTemporarily downMaintenance or overload — include Retry-After

Error Format

Return errors in a consistent shape. Every error response uses this structure:

json
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Request body failed validation.",
    "details": [
      { "field": "email", "message": "Must be a valid email address." },
      { "field": "age", "message": "Must be at least 18." }
    ]
  }
}
FieldTypeRequiredDescription
error.codestringYesMachine-readable error code (UPPER_SNAKE_CASE)
error.messagestringYesHuman-readable summary
error.detailsarray | objectNoField-level errors, additional context

Rules:

  • Always return the same top-level { error: { ... } } shape for all error responses.
  • Use code for programmatic handling (clients switch on it), message for display.
  • Never expose stack traces, internal paths, or database errors in production.
  • Include a request_id in error responses (or top-level meta) for debugging.

Pagination

Cursor-Based (Preferred)

Use cursor-based pagination by default. It handles inserts/deletes gracefully and scales to large datasets.

Request:

GET /users?limit=20&cursor=eyJpZCI6MTAwfQ

Response:

json
{
  "data": [ { "id": 101, "name": "Ada" }, { "id": 102, "name": "Bob" } ],
  "pagination": {
    "next_cursor": "eyJpZCI6MTAyfQ",
    "has_more": true
  }
}
FieldDescription
next_cursorOpaque string — encode whatever your DB needs (usually last ID)
has_moreBoolean — tells client whether to fetch again

Offset-Based (When Needed)

Use offset pagination only when users need to jump to arbitrary pages (admin tables, search results).

Request:

GET /users?offset=40&limit=20

Response:

json
{
  "data": [ { "id": 41, "name": "Ada" } ],
  "pagination": {
    "offset": 40,
    "limit": 20,
    "total": 523
  }
}

Warning: Offset pagination degrades on large datasets (DB must skip offset rows). Never use for infinite scroll.

Authentication

Bearer Tokens (Preferred for User Auth)

Pass tokens in the Authorization header:

Authorization: Bearer eyJhbGciOiJSUzI1NiIs...
  • Use short-lived access tokens (15 min–1 hr) with refresh tokens.
  • Validate tokens on every request. Don't cache validation results.
  • Return 401 for missing/expired tokens, 403 for insufficient permissions.

API Keys (For Server-to-Server)

Pass API keys in a custom header or as a query parameter (header preferred):

X-API-Key: sk_live_abc123def456
AspectRecommendation
Where to sendX-API-Key header (preferred) or Authorization: ApiKey <key>
Key formatPrefix with environment: sk_live_, sk_test_
StorageHash keys server-side, never store plaintext
RotationSupport multiple active keys for zero-downtime rotation

When to Use Each

ScenarioAuth Method
Browser/mobile app user sessionsBearer token (OAuth 2.0 / JWT)
Server-to-server integrationAPI key
Third-party developer accessOAuth 2.0 with scopes
Internal microservicesmTLS or signed JWTs

Versioning

URL Versioning (Preferred)

Prefix major versions in the URL path:

GET /v1/users
GET /v2/users
  • Version only when you introduce breaking changes.
  • Run old versions in parallel during migration. Set a sunset date and communicate it.
  • Non-breaking additions (new optional fields, new endpoints) do not require a version bump.

Header Versioning (Alternative)

Accept: application/vnd.myapi.v2+json

Use header versioning when URL versioning creates routing complexity or you need fine-grained version control. URL versioning is simpler for most cases.

What Counts as a Breaking Change

BreakingNot Breaking
Removing a field from a responseAdding a new optional field to a response
Renaming a fieldAdding a new endpoint
Changing a field's typeAdding a new optional query parameter
Removing an endpointAdding a new enum value (if clients handle unknown)
Making an optional field requiredImproving error messages

Rate Limiting

Include rate-limit headers in every response so clients can self-regulate:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 742
X-RateLimit-Reset: 1702483200
HeaderDescription
X-RateLimit-LimitMax requests allowed in the window
X-RateLimit-RemainingRequests remaining in current window
X-RateLimit-ResetUnix timestamp when the window resets

When the limit is exceeded, return:

json
{
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Too many requests. Retry after 30 seconds.",
    "details": {
      "retry_after": 30
    }
  }
}

Return 429 Too Many Requests with a Retry-After header (in seconds).

Anti-Patterns

Avoid these. When you see them in a codebase, flag or refactor.

Anti-PatternProblemDo Instead
Verbs in URLs/getUsers, /deleteOrderUse HTTP methods: GET /users, DELETE /orders/:id
Deep nesting (3+ levels)/users/:id/orders/:oid/items/:iid/reviewsFlatten: /order-items/:iid/reviews
200 for errorsClient can't distinguish success from failure by statusUse appropriate 4xx/5xx codes
GET for mutationsBreaks caching, prefetching, crawlersUse POST, PUT, PATCH, DELETE
Plural/singular inconsistency/user/1 but /ordersAlways use plural: /users/1, /orders
Returning arrays at rootVulnerable to JSON hijacking, can't add metadataWrap in { "data": [...] }
Leaking internal errorsStack traces, SQL errors in responsesReturn generic message, log details server-side
Ignoring Accept headersClient can't negotiate content typeRespect Accept or return 406
Custom status codesClients won't understand themStick to standard HTTP status codes
Inconsistent error shapesSome errors return { message }, others { error }Use one error shape everywhere

Domande frequenti

Cosa fa la skill IA Api Design?

RESTful API design conventions covering URL structure, HTTP methods, error formats, pagination, versioning, and authentication patterns. Use when designing, reviewing, or implementing APIs. Triggers on API design, endpoint structure, REST conventions, or backend architecture tasks.

Perché usare Api Design su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Api Design è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Api Design in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/kazdenc/builder-skills/tree/main/.claude/skills/dev/frameworks/api-design. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Api Design?

Qualsiasi modello che colleghi in TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Api Design?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Api Design: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Api Design è gratuita?

Sì. È pubblicata su GitHub da kazdenc con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, modelli o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇