REST API Basics: Resources, Routes, and CRUD

Core REST API patterns for resource-oriented URLs, nested resources, and standard CRUD request examples.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Resource-oriented routes
List a collection
GET /users

# Fetch a list of users.

Create a resource
POST /users

# Create a new user in the collection.

Fetch a single resource
GET /users/{userId}

# Read one user by identifier.

Replace a resource
PUT /users/{userId}

# Replace the full representation.

Partially update a resource
PATCH /users/{userId}

# Modify only selected fields.

Delete a resource
DELETE /users/{userId}

# Remove one user.

Nested child resource
GET /users/{userId}/orders

# Access a child collection under a parent resource.

Subresource details
GET /users/{userId}/settings

# Read a related settings object.

## Route shape examples
Prefer nouns over verbs
Prefer:  POST /invoices
Avoid:   POST /createInvoice

# Model the resource, not the action name.

Use plural collection names
Prefer:  /users
Avoid:   /user

# Keep collection naming consistent.

Use stable path identifiers
GET /users/123
GET /orders/ord_456

# Put stable IDs in the path.

Represent actions carefully when needed
POST /payments/{paymentId}/refunds

# Use an action subresource only for non-CRUD workflows.

Recommended next

No recommendations yet.