# HTTP Grpc

> HTTP & gRPC Deep Understanding

- Skill: `modbender/http-grpc` (Agent Skill)
- Install (CLI): `npx skillmds@latest add modbender/http-grpc`
- Raw SKILL.md: https://api.skillmd.com/api/skills/modbender/http-grpc/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: modbender (https://skillmd.com/u/modbender)
- Updated: 2026-09-21
- Page: https://skillmd.com/skills/modbender/http-grpc

---

# HTTP & gRPC Deep Understanding

## REST Best Practices

### URL Design
```
GET    /api/v1/users          → List
POST   /api/v1/users          → Create
GET    /api/v1/users/:id      → Read
PATCH  /api/v1/users/:id      → Update
DELETE /api/v1/users/:id      → Delete
```

### Status Codes
| Code | Usage |
|------|-------|
| 200 | Success |
| 201 | Created |
| 204 | No Content |
| 400 | Bad Request |
| 401 | Unauthorized |
| 403 | Forbidden |
| 404 | Not Found |
| 409 | Conflict |
| 422 | Validation Error |
| 429 | Rate Limited |
| 500 | Server Error |

## gRPC vs REST

| Aspect | REST | gRPC |
|--------|------|------|
| Format | JSON | Protocol Buffers |
| Speed | Medium | Fast |
| Browser Support | Native | Requires gRPC-Web |
| Streaming | Limited | Full support |
| Code Gen | OpenAPI | Built-in |

## Idempotency

```typescript
// Idempotent POST with idempotency key
app.post('/payments', async (req, res) => {
  const idempotencyKey = req.headers['idempotency-key']
  
  // Check if already processed
  const existing = await cache.get(`idempotency:${idempotencyKey}`)
  if (existing) return existing
  
  // Process payment
  const result = await processPayment(req.body)
  
  // Cache result
  await cache.set(`idempotency:${idempotencyKey}`, result, { ttl: 86400 })
  
  return result
})
```

## Checklist

- [ ] Use proper HTTP methods
- [ ] Return correct status codes
- [ ] Implement idempotency for mutations
- [ ] Version API from v1
- [ ] Document with OpenAPI

