An isomorphic JavaScript client for the WordPress REST API, enabling query-builder-style requests from Node.js or browser environments. Current stable version is 1.2.2, with a release cadence of major versions every few years. Key differentiators: built for the official WordPress REST API (WordPress 5.0+), supports auto-discovery, custom routes, media uploads, pagination, and embedding. Unlike generic HTTP clients, wpapi provides fluent methods for posts, comments, categories, tags, and custom post types, with built-in authentication support (Basic Auth, OAuth, nonces).
npm install wpapiNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic CRUD operations: fetching categories, creating a post with auth, and updating a post by ID.
Ensure your WordPress site runs version 5.0 or later. For older versions, use the WP REST API plugin and check compatibility.
Call `.get()` or similar at the end: `site.posts().get()` returns a Promise.
Use `site.posts().embed().get()` instead of `site.posts().get().embed()`.
Use dedicated setter methods: `site.posts().perPage(10).get()` instead of `site.posts().param('per_page', 10).get()`.Always set auth on the instance: `new WPAPI({ endpoint, username, password })` or call `site.auth({ username, password })`.Run `npm install --save wpapi` and ensure import/require path is correct: `import WPAPI from 'wpapi'`.
Correct usage: `const site = new WPAPI({ endpoint: 'https://example.com/wp-json' }); site.posts().get();`Provide `username` and `password` in the constructor or use `.auth()` method. Ensure the user has appropriate capabilities.
For single item requests, use `.id(123).get()` to get a post by ID, which returns an object with `id`.
No dependency data recorded yet.