mcpField
R
rest-api-design

rest-api-design

github.com/secondskyDevelopment240594 installsUpdated 5w ago
Repository

About rest-api-design

A reference guide for developers designing REST APIs, covering resource naming, HTTP methods, status codes, response structures, and query parameters. It also outlines versioning, pagination, and OpenAPI/Swagger documentation practices.

Key features

  1. 01Name resources with nouns and hierarchy
  2. 02Match HTTP methods to operations
  3. 03Choose appropriate status codes
  4. 04Structure responses and pagination
  5. 05Support filtering, sorting, and field selection
  6. 06Document and version APIs

Use cases

  1. 01Plan resource paths and endpoint operations
  2. 02Standardize API errors and success responses
  3. 03Add pagination and query options to collections
  4. 04Prepare API versioning and documentation

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/secondsky/claude-skills --skill rest-api-design

After installing, type/rest-api-designin Claude Code to confirm it loaded.

Details

From the project README

REST API Design

Design RESTful APIs with proper conventions and developer experience.

Resource Naming

# Good - nouns, plural, hierarchical
GET    /api/users
GET    /api/users/123
GET    /api/users/123/orders
POST   /api/users
PATCH  /api/users/123
DELETE /api/users/123

# Bad - verbs, actions in URL
GET    /api/getUsers
POST   /api/createUser
POST   /api/users/123/delete

HTTP Methods

MethodPurposeIdempotent
GETRead resourceYes
POSTCreate resourceNo
PUTReplace resourceYes
PATCHPartial updateYes
DELETERemove resourceYes

Status Codes

CodeMeaningUse For
200OKSuccessful GET, PATCH
201CreatedSuccessful POST
204No ContentSuccessful DELETE
400Bad RequestValidation errors
401UnauthorizedMissing auth
403ForbiddenInsufficient permissions
404Not FoundResource doesn't exist
429Too Many RequestsRate limited

Response Format

{
  "data": {
    "id": "123",
    "type": "user",
    "attributes": {
      "name": "John",
      "email": "[email protected]"
    }
  },
  "meta": {
    "requestId": "req_abc123"
  }
}

Collection Response

{
  "data": [...],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 150,
    "totalPages": 8
  },
  "links": {
    "self": "/api/users?page=1",
    "next": "/api/users?page=2"
  }
}

Query Parameters

GET /api/products?category=electronics    # Filtering
GET /api/products?sort=-price,name        # Sorting
GET /api/products?page=2&limit=20         # Pagination
GET /api/products?fields=id,name,price    # Field selection

Best Practices

  • Use nouns for resources, not verbs
  • Version API via URL path (/api/v1/)
  • Return appropriate status codes
  • Include pagination for collections
  • Document with OpenAPI/Swagger

Comments

Markdown supported