rest-api

REST API design with HTTP methods and status codes. Use for web APIs.

7 stars

Best use case

rest-api is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

REST API design with HTTP methods and status codes. Use for web APIs.

Teams using rest-api should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/rest-api/SKILL.md --create-dirs "https://raw.githubusercontent.com/G1Joshi/Agent-Skills/main/skills/architecture/rest-api/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/rest-api/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How rest-api Compares

Feature / Agentrest-apiStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

REST API design with HTTP methods and status codes. Use for web APIs.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# REST API

Representational State Transfer (REST) is the architectural style for distributed hypermedia systems. It relies on stateless, client-server, cacheable communications protocols (mostly HTTP).

## When to Use

- **Public APIs**: The universal standard; easiest for 3rd parties to consume.
- **Simple Resource Access**: Perfect for CRUD (Create, Read, Update, Delete) operations.
- **Caching**: When you need to leverage HTTP caching (CDNs, Browsers).

## Quick Start

```typescript
// Express.js Example
app.get("/users/:id", async (req, res) => {
  const user = await db.find(req.params.id);
  if (!user) return res.status(404).json({ error: "Not Found" });

  // HATEOAS (Hypermedia As The Engine Of Application State) - optional but "True REST"
  res.json({
    ...user,
    links: {
      self: `/users/${user.id}`,
      orders: `/users/${user.id}/orders`,
    },
  });
});
```

## Core Concepts

### Resources

Everything is a resource identified by a URI (`/users/123`).

### HTTP Verbs

Use verbs to define actions, not URIs.

- `GET /orders` (List)
- `POST /orders` (Create)
- `PATCH /orders/1` (Update partial)
- `DELETE /orders/1` (Remove)

### Statelessness

Each request must contain all information necessary to understand the request. The server accepts no session state.

## Common Patterns

### Filtering, Sorting, Pagination

Standard query params: `?sort=-created_at&limit=10&page=2&status=active`.

### Versioning

- URI Versioning: `/v1/users` (Most common).
- Header Versioning: `Accept: application/vnd.myapi.v1+json`.

## Best Practices

**Do**:

- Use proper **HTTP Status Codes** (200 OK, 201 Created, 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 500 Server Error).
- Use **Snake Case** (`user_id`) in JSON responses (standard convention) or camelCase if consistent with JS ecosystem.
- Implement **Rate Limiting** to protect resources.

**Don't**:

- Don't use GET for state-changing operations.
- Don't return 200 OK for errors (e.g., `{ "error": "failed" }` with status 200).
- Don't expose database IDs if possible (use UUIDs).

## Troubleshooting

| Error                        | Cause                                  | Solution                                             |
| :--------------------------- | :------------------------------------- | :--------------------------------------------------- |
| `405 Method Not Allowed`     | Sending POST to a GET-only endpoint.   | Check HTTP verb.                                     |
| `415 Unsupported Media Type` | Sending XML when JSON expected.        | Set `Content-Type: application/json`.                |
| `CORS Error`                 | Browser blocking cross-origin request. | Set `Access-Control-Allow-Origin` headers on server. |

## References

- [Restful API Design (Microsoft)](https://learn.microsoft.com/en-us/azure/architecture/best-practices/api-design)
- [Richardson Maturity Model](https://martinfowler.com/articles/richardsonMaturityModel.html)