HTTP Fundamentals
API Basics
Preview
HTTP
The methods
| Method | Purpose | Idempotent |
|---|---|---|
| GET | Read data | Yes |
| POST | Create a resource | No |
| PUT | Replace a resource | Yes |
| PATCH | Partial update | No |
| DELETE | Remove a resource | Yes |
Idempotent means repeating the request gives the same result. GET is safe to retry; POST usually creates a new record each time.
Status codes
| Code | Meaning | Example |
|---|---|---|
| 200 | OK | Successful GET |
| 201 | Created | Successful POST |
| 400 | Bad request | Invalid input |
| 401 | Unauthorized | Missing token |
| 403 | Forbidden | No permission |
| 404 | Not found | Unknown endpoint |
| 422 | Unprocessable | Validation failed |
| 500 | Server error | A bug |
Headers
Content-Type: application/json\nAuthorization: Bearer <token>\nAccept: application/jsonTip: Learn the status code ranges: 2xx success, 3xx redirect, 4xx your fault, 5xx the server's fault.
This is a free preview lesson
Enroll in the API Development to unlock every lesson, lesson PDF guides, quizzes and your certificate - and start creating your own pieces today.