Appearance
WordPress REST API
The WordPress REST API at /wp-json/ and the site's application passwords, for the clients that speak WordPress.
kitloom/ · admins: kitloom/, kitloom/
The WordPress REST API on a kitloom site, for headless front ends, mobile apps and agents: / with WordPress's JSON for the core fields, so WordPress clients work for the basics, and application passwords on laravel/sanctum tokens. The admin pages are kitloom/api-filament or kitloom/api-nova.
In the admin it is the WordPress REST API section. A client written for kitloom rather than for WordPress is better served by kitloom/rest-api (the API section, /): its own names and shape, typed filters, a document of itself. Both take the same application passwords.
The root, /, is the site's (kitloom/site): its index lists every module's namespace, and this package is the wp/ one. Other modules answer under the same root in namespaces of their own (kitloom/forms: contact-) without this package.
Routes
| Route | Methods | What |
|---|---|---|
/ | GET | The namespace and its routes (/ itself is the site's index) |
/, / | GET | Shown post types with their rest_ (media is attachment) |
/, / | GET | Shown taxonomies; ?type=post |
/ | GET, POST | posts, pages, any shown type: the list, a new record |
/ | GET, POST/PUT/PATCH, DELETE | One record; DELETE trashes, force=true deletes |
/ | GET, POST | categories, tags, any shown taxonomy (id is the term_) |
/ | GET, POST/PUT/PATCH, DELETE | One term; DELETE trashes (kitloom's term trash — WordPress has none), force=true deletes; each term carries its status |
/, / | GET | The media library, with media_ |
/ | GET | The password's user; context=edit adds username, email, names |
Posts, media, terms and users/ carry meta: the keys declared for them (see Meta), [] when none are.
Lists take page, per_ (10, at most 100), offset, search, include/exclude, slug, order, orderby (date, id, include, title, slug, modified, parent, menu_, author, include_); posts also author/author_, parent/parent_, status (other than publish for editors of the type), after/before/modified_, sticky, and each taxonomy's base with _; terms hide_, parent, post. Answers carry X-, X- and Link; _ narrows them; context=edit adds raw values for those who may edit. Errors are WordPress's: {"code":, also for routes that do not exist under the prefix.
The routes are registered by the package without the web group — no session, no CSRF — under the site's REST root, which matches before the site's fallback route, so / never reaches the site.
Who sees and writes what
A request with no password is a visitor: it sees what is published. A password makes it its user's request: Visibility:: — editors see everything, authors their own drafts too. Writes go through Content\ and Content\ as that user, which refuse what the user's capabilities do not allow (a contributor publishing, an author editing someone else's post). Content filters render content. as the record's page would.
Meta
WordPress shows a record's meta in the REST API only for keys declared with register_ and show_; kitloom does the same with keys declared in kitloom/wp-schema. An application lists its own in config/ — the line functions. had:
php
'meta' => [
['object' => 'post', 'for' => 'book', 'key' => 'isbn', 'type' => 'string', 'description' => 'The ISBN'],
['object' => 'post', 'for' => 'book', 'key' => 'pages', 'type' => 'integer', 'schema' => ['minimum' => 1]],
['object' => 'term', 'for' => 'genre', 'key' => 'colour'],
['object' => 'user', 'key' => 'twitter'],
],A package or a theme yields Kitloom\s (Meta) from a Kitloom\ tagged Registered. A key is declared once for a record: two declarations of isbn for books are an error at once.
- Read: every declared key of the record's type, in
viewandeditcontext ('context' => ['edit']keeps a key for those who may edit), each as its type:string,integer,number,boolean(1/0,yes/noand the rest WordPress and plugins store),array(withschema.) oritems object(withschema.) — arrays from the JSON kitloom writes or what WordPress serialized. A missing key reads as itsproperties default, else'',0,falseornull; a key with'single' => falsereads as the list of its rows. A list reads the meta of all its records in one query._narrows into it.fields=meta. isbn - Write:
{"meta":on POST/PUT/PATCH of a post or a term. Only declared keys are written; others are left out without an error, as in WordPress. Each value is checked against its type and schema ({"isbn": "978- 0"}} enum,minimum/maximum,min/Length max,Length min/Items max,Items formatemail/uri/date-) — a wrong one istime rest_(400) oninvalid_ param meta.nulldeletes a key; a list replaces the rows of a key that is not single. Nothing is written until every key has passed. - Who writes: whoever may edit the record (
edit_,post edit_), unless the key names aterm capability. A protected key (one that starts with_) is shown when declared but written only with acapabilityof its own. A refused key isrest_(403), "Sorry, you are not allowed to edit the isbn custom field."; on a new record, the record is not kept either. On an update the meta is written before the record is saved, so whoever hears it saved reads the new values.cannot_ update
Not here: ACF fields under acf, a schema of the keys (OPTIONS, types/), comments' and other users' meta, and WordPress's footnotes (declare it in config if a block-editor client needs it). Media and users/ are read only, so their meta is too.
Application passwords
The tokens of every API of the site — / and, with kitloom/rest-api, / — made in WordPress REST API → Application passwords. Sanctum tokens of users, stored in personal_ (the package's migration creates it unless Sanctum's is there) as a SHA-256 hash only; the user copies {id}|{secret} once. Clients send it
- as a Bearer token:
Authorization:, orBearer 12|… - with the username or email as Basic auth, the way WordPress clients send application passwords:
curl -.u admin: 12|… https:// example. com/ wp- json/ wp/ v2/ users/ me
Who makes one by hand: whoever works with the site's content or its settings (edit_, or the right to manage everyone's). Anybody else who enters the admin — a staff member who only takes bookings — has passwords too, the ones the mobile app made when they signed in, and sees them under Users → Apps and devices: the phones they are signed in on, each with Sign out. No WordPress REST API section, no password made by hand.
A wrong, expired or revoked password is refused with 401 even where a visitor would be let in. A password is read-only (read) or reads and writes as the user (*); it may expire. It never signs in to the site: the API does not touch the session guard. Application makes, finds and revokes them: a user revokes their own, whoever has manage_ anyone's. Owners are read through the auth user provider the site signs in with (kitloom- names another).
With kitloom/privacy, Tools → Export Personal Data lists the user's passwords — the name, read-only or not, when each was made, last used and runs out — never the password or its hash. Erase Personal Data revokes them all; the account stays, and its owner makes new ones if they want.
Web servers that drop the Authorization header (Apache with CGI/FPM) need it passed on, as WordPress needs: Rewrite.
Settings
| Option | Default | What |
|---|---|---|
rest_ | on | Off — every wp/ route answers rest_ (404); other modules' namespaces stay |
rest_ | every public type | JSON list of post types shown |
rest_ | every public taxonomy | JSON list of taxonomies shown |
rest_ | 120 | Requests a minute per user, or per address without a password; 0 — none. Answers carry X-; over it, rest_ (429) |
Configuration
php artisan vendor: for kitloom-: routes., user_, wrong_ ('10,1': after ten wrong application passwords in a minute an address gets rest_, 429, before any password of it is checked — kitloom/ai's agent address counts with it; '' — no limit), rest_ ('book' => 'books'), per_/max_, privacy. (the personal data export and erasure) and the admin pages (filament., nova.). The prefix (wp-) and CORS are the root's, kitloom-; the pagination headers join cors.. Sanctum's token_ and expiration apply to application passwords.
Tests
From the application that installs the package: php vendor/.