Skip to content
api-designer logo

API Designer

api-designer

Design RESTful or GraphQL APIs with proper conventions. Creates endpoint specifications, request/response schemas, and documentation. Use when user says 'design API', 'endpoints', 'REST', 'GraphQL', or 'API spec'.

SKILL.md

Full skill instructions

API Designer

You are an expert at designing clean REST and GraphQL APIs.

When To Use

  • User says "Design the API", "What endpoints do we need?"
  • User asks to "Create API spec"
  • New feature requires API endpoints
  • Refactoring existing API

Inputs

  • Feature requirements
  • Data models involved
  • Authentication requirements

Outputs

  • API specification (OpenAPI/​Swagger or markdown)
  • Endpoint documentation
  • Example requests/​responses

REST Conventions

ActionMethodEndpointResponse
ListGET/​resources200 + []
Get oneGET/​resources/:id200 or 404
CreatePOST/​resources201 + object
UpdatePUT/​PATCH/​resources/:id200 + object
DeleteDELETE/​resources/:id204 or 404

Workflow

1. Identify Resources

What entities does this feature involve?

2. Define Operations

CRUD? Custom actions?

3. Design URLs

  • Use nouns, not verbs
  • Nest appropriately
  • Plural for collections

4. Define Request/​Response

  • Fields, types
  • Required vs optional
  • Pagination for lists

5. Error Handling

Standard error format, appropriate status codes.

6. Document

OpenAPI spec or markdown.

URL Design

Good

GET    /​users
GET    /​users/​123
POST   /​users
PUT    /​users/​123
DELETE /​users/​123

GET    /​users/​123/​posts
POST   /​users/​123/​posts

Bad

GET    /​getUser/​123       # verb in URL
GET    /​user/​123          # singular
POST   /​users/​create      # redundant
GET    /​users?action=delete  # wrong method

Standard Error Format

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid input",
    "details": [
      {"field": "email", "message": "Invalid email format"}
    ]
  }
}

Status Codes

CodeWhen
200Success
201Created
204No Content (deleted)
400Bad Request (validation)
401Unauthorized (not logged in)
403Forbidden (no permission)
404Not Found
409Conflict
500Server Error

Pagination

{
  "data": [...],
  "pagination": {
    "page": 1,
    "per_page": 20,
    "total": 100,
    "total_pages": 5
  }
}

Or cursor-based:

{
  "data": [...],
  "next_cursor": "abc123",
  "has_more": true
}

OpenAPI Spec Template

openapi: 3.0.0
info:
  title: API Name
  version: 1.0.0

paths:
  /​resources:
    get:
      summary: List resources
      responses:
        '200':
          description: Success
          content:
            application/​json:
              schema:
                type: array
                items:
                  $ref: '#/​components/​schemas/​Resource'

components:
  schemas:
    Resource:
      type: object
      properties:
        id:
          type: string
        name:
          type: string

GraphQL

When to Use GraphQL vs REST

Use GraphQLUse REST
Complex data relationshipsSimple CRUD
Mobile apps (reduce over-fetching)Caching critical
Multiple clients need different dataSimpler tooling
Nested data in single requestFile uploads

Schema Design

type User {
  id: ID!
  email: String!
  name: String
  posts: [Post!]!
  createdAt: DateTime!
}

type Post {
  id: ID!
  title: String!
  content: String!
  author: User!
  published: Boolean!
}

type Query {
  user(id: ID!): User
  users(first: Int, after: String): UserConnection!
  post(id: ID!): Post
}

type Mutation {
  createUser(input: CreateUserInput!): User!
  updateUser(id: ID!, input: UpdateUserInput!): User!
  deleteUser(id: ID!): Boolean!
}

input CreateUserInput {
  email: String!
  name: String
}

input UpdateUserInput {
  email: String
  name: String
}

Naming Conventions

ElementConventionExample
TypesPascalCaseUser, BlogPost
FieldscamelCasecreatedAt, firstName
QueriescamelCase, nounuser, users, post
MutationscamelCase, verb+nouncreateUser, updatePost
InputsPascalCase + InputCreateUserInput

Pagination (Relay-style)

type UserConnection {
  edges: [UserEdge!]!
  pageInfo: PageInfo!
  totalCount: Int!
}

type UserEdge {
  node: User!
  cursor: String!
}

type PageInfo {
  hasNextPage: Boolean!
  hasPreviousPage: Boolean!
  startCursor: String
  endCursor: String
}

# Query
query {
  users(first: 10, after: "cursor123") {
    edges {
      node { id name }
      cursor
    }
    pageInfo { hasNextPage endCursor }
  }
}

Error Handling

type MutationResult {
  success: Boolean!
  message: String
  errors: [FieldError!]
}

type FieldError {
  field: String!
  message: String!
}

# Or use union types
union CreateUserResult = User | ValidationError | AuthError

Resolvers (Code-first with Python)

from ariadne import QueryType, MutationType

query = QueryType()
mutation = MutationType()

@query.field("user")
def resolve_user(_, info, id):
    return db.get_user(id)

@query.field("users")
def resolve_users(_, info, first=10, after=None):
    return db.paginate_users(first, after)

@mutation.field("createUser")
def resolve_create_user(_, info, input):
    return db.create_user(**input)

N+1 Problem (Use DataLoaders)

from ariadne import load_schema_from_path
from graphql import GraphQLResolveInfo

# BAD: N+1 queries
@query.field("users")
def resolve_users(_, info):
    users = db.get_users()
    for user in users:
        user.posts = db.get_posts_for_user(user.id)  # N queries!
    return users

# GOOD: DataLoader
from aiodataloader import DataLoader

async def batch_load_posts(user_ids):
    posts = await db.get_posts_for_users(user_ids)
    return [posts.get(uid, []) for uid in user_ids]

posts_loader = DataLoader(batch_load_posts)

@query.field("user")
async def resolve_user_posts(user, info):
    return await posts_loader.load(user.id)

GraphQL Anti-Patterns

  • Deeply nested queries without limits
  • No query complexity limits (DoS risk)
  • Exposing database IDs directly
  • Not using input types for mutations
  • Returning null for errors instead of error types

REST vs GraphQL Decision

FactorRESTGraphQL
Learning curveLowerHigher
CachingBuilt-in HTTPManual
Over-fetchingCommonSolved
Under-fetchingCommonSolved
File uploadsNativeNeeds workaround
Real-timeWebSocket separateSubscriptions built-in

Default to REST unless you have specific GraphQL needs.


Anti-Patterns

  • Verbs in URLs (/​getUser, /​createOrder)
  • Inconsistent response formats
  • Missing pagination on list endpoints
  • No versioning strategy
  • Different error formats per endpoint
  • Not documenting auth requirements

Keywords

API, REST, endpoints, design API, OpenAPI, Swagger, routes, GraphQL, schema, query, mutation

More Security skills

supabase logo
Security

supabase

Handles the full Supabase workflow from schema changes to deployment, with built-in security guardrails that catch common traps like RLS...

2.7K 308.9K
View

Comprehensive guides and best practices for Neon Serverless Postgres, covering setup, connection methods, authentication, and platform APIs.

98 216.2K
View

Guide for setting up and using Firebase Authentication. Use this skill when the user's app requires user sign-in, user management, or secure data access using auth rules.

462 163.8K
View

A skill to evaluate how secure Firestore security rules are. Use this when Firestore security rules are updated to ensure that the generated rules are extremely secure and robust.

462 127.7K
View

Official skill for integrating Firebase AI Logic (Gemini API) into web applications. Covers setup, multimodal inference, structured output, and security.

462 125.1K
View

Complete Better Auth server and client setup with database adapters, session management, plugins, and security configuration.

222 118.2K
View

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".

31.9K 116.1K
View
cloudflare logo
Security

cloudflare

Complete Cloudflare platform integration with decision trees for compute, storage, AI, networking, security, and infrastructure-as-code.

3K 110.7K
View

Run Azure compliance and security audits with azqr plus Key Vault expiration checks. Covers best-practice assessment, resource review, policy/compliance validation, and security posture checks. WHEN: compliance scan, security audit, BEFORE running azqr (compliance cli tool), Azure best practices, Key Vault expiration check, expired certificates, expiring secrets, orphaned resources, compliance assessment.

253 103K
View
gws-gmail logo
Security

gws-gmail

Send, read, and manage Gmail messages, drafts, labels, and account settings.

31.2K 78.9K
View

Comprehensive website auditing across 230+ rules in 21 categories including SEO, performance, security, and accessibility.

94 72.3K
View
gws-shared logo
Security

gws-shared

Shared authentication, CLI syntax, and output formatting patterns for gws Google Workspace commands.

31.2K 63.4K
View

Security AI tools

StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
GeoSpy logo
Security

GeoSpy

GeoSpy: Pricing, Features, FAQs, and Alternatives for AI Teams

Free
View

Detect AI-generated voices to protect against audio fraud.

Paid
View

Ensure Your Content's Originality with AI Plagiarism Checker

Freemium
View
Img Upscaler logo
Security

Img Upscaler

Upscale images by 400% without quality loss

Freemium
View
AICheatCheck logo
Security

AICheatCheck

Accurately Detect AI-Generated Content with TheChecker.AI

Free
View
D
Security

Detect GPT

Chrome extension that detects and flags AI-generated content

Free
View