Every app speaks four verbs. WordPress does too. The REST API is already answering at /wp-json/ on every site you have ever built. In this module you learn to read it: which route does what, why a write returns 401, and why DELETE does not really delete.
| Course | WordPress REST API Course ยท Module 1 of 9 ยท Stage 1 "Read the API" |
| Learn | Routes and endpoints, the four verbs of CRUD on wp/v2, query parameters, pagination headers and real core error codes |
| How | 4 short lessons on wp/v2/posts, requests you run with curl against your local site, interview questions after every lesson |
Four verbs, one resource
flowchart LR
C["POST /wp/v2/posts<br/>Create ยท 201"] --> R["GET /wp/v2/posts/123<br/>Read ยท 200"]
R --> U["PUT /wp/v2/posts/123<br/>Update ยท 200"]
U --> D["DELETE /wp/v2/posts/123<br/>Delete ยท trash"]
classDef get fill:#ebf3fb,stroke:#61affe,color:#1e293b
classDef post fill:#e8f6f0,stroke:#49cc90,color:#1e293b
classDef put fill:#fff5ea,stroke:#fca130,color:#1e293b
classDef del fill:#feebeb,stroke:#f93e3e,color:#1e293b
class C post
class R get
class U put
class D del
CRUD is the grammar, endpoints are sentences. Once you read one resource, you read them all.
Before โ after
| Before | After Module 1 |
|---|---|
| "The API is somewhere in WordPress" | /wp-json/ index: every namespace and route on the site |
| A 401 looks like a bug | 401 rest_cannot_create: write requests need auth |
| "I deleted it" โ it is in the trash | DELETE trashes; force=true deletes for good |
| Loading all posts at once | per_page, page, X-WP-Total, X-WP-TotalPages |
You'll be able to answer
- What is the difference between a route and an endpoint in the WordPress REST API?
- Which HTTP methods does WordPress accept for an update?
- What does DELETE /wp/v2/posts/{id} do without force=true?