Api Design logo

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.

Overview

Publisherkazdenc
Repositorybuilder-skills
Skill nameapi-design
Stars
46
Forks
5
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by kazdenc on GitHub. Read the source before you install it.

Installation

Install the Api Design AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/kazdenc/builder-skills/tree/main/.claude/skills/dev/frameworks/api-design
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

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
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Api Design in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Api Design on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Api Design is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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

Frequently asked questions

What does the Api Design AI skill do?

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.

Why use Api Design on TypingMind?

Because you install it once and use it with any model. Api Design is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Api Design in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/kazdenc/builder-skills/tree/main/.claude/skills/dev/frameworks/api-design. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Api Design?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Api Design?

As many as you like. As long as a model supports skills, you can use Api Design with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Api Design AI skill free?

Yes. It is published on GitHub by kazdenc under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇