WordPress REST API
===================
Motivation
-----------
Although it has a place, exposing a WordPress instance publicly on the web is not my favorite thing :-) But I like the WordPress backend for easily managing content. Since WordPress has a REST API , it is possible to use it with a custom frontend that consumes the API.
(HTM) WordPress
TL;DR
------
Set permalinks to post name and you can access the API.
Demo
-----
Use this script to get started quickly:
Then point your browser to http://localhost:3000 to see the working instance.
Administration can be done by browsing to http://localhost:3000/wp-admin and use these credentials:
- Some API Endpoints -
- http://localhost:3000/wp-json/
- http://localhost:3000/wp-json/wp/v2/
- http://localhost:3000/wp-json/wp/v2/pages/
- http://localhost:3000/wp-json/wp/v2/posts/
- http://localhost:3000/wp-json/wp/v2/tags/
Retrieving pages
-----------------
- Using curl -
(HTM) curl
Which results in pages.json .
(DIR) pages.json
- Using JavaScript -
How to build this yourself
---------------------------
- Install WordPress with or without SQLite 1
(HTM) SQLite
(DIR) 1
- In WordPress go to wp-admin → Settings → Permalinks
(HTM) wp-admin
(HTM) Settings
(HTM) Permalinks
- Select Post name . Plain won’t work.
Notes
------
----------------------------------
- Unlike a lot of others, I’m a proponent of using SQLite in production, but your mileage may vary. Especially with write-intensive applications. ↩︎
Unlike a lot of others, I’m a proponent of using SQLite in production, but your mileage may vary. Especially with write-intensive applications. ↩︎
(HTM) SQLite
(DIR) ↩︎
(DIR) previous Unfriendly dates
(DIR) next TIL executing commands in Windows explorer
Related
--------
(DIR) SQL injection demo
(TXT) /img/fallback.svg (.svg)
(DIR) My .sqliterc
(TXT) /img/fallback.svg (.svg)
(DIR) [Talk] SQLite <3
(TXT) /img/fallback.svg (.svg)
(DIR) Full-text document indexing - part Ⅰ
(TXT) /img/fallback.svg (.svg)
(DIR) About me
(TXT) /img/fallback.svg (.svg)
(DIR) My SQLite knowledge
(TXT) /img/fallback.svg (.svg)