What is the WordPress REST API?
The REST API lets other applications talk to WordPress with HTTP requests, and the answer is JSON. The base is /wp-json/. It is used by the block editor, mobile apps and headless front ends (React, Vue).
Terminal output
$ curl -s "http://example.com/wp-json/wp/v2/posts?per_page=1&_fields=id,slug,title" | jq -c .
[{"id":1,"slug":"hello-world","title":{"rendered":"Hello world!"}}]
GETreads,POSTcreates or updates,DELETEremoves.- Public content can be read without a login. Writing needs authentication: cookie with nonce, or application passwords.
- You can add your own routes with
register_rest_route().
See REST API Introduction and Authentication.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |