Menu
API Reference
createClient(options)
Creates a WordPress REST API client.
Options:
baseURL: string— base URL of your WordPress site’s REST API root (e.g.https://example.com/wp-json)auth?: { username: string; password: string }— JWT credentials (requires JWT Auth plugin on the server)
Returns: WordPressClient
Client methods
All methods return a promise that resolves with the typed response.
client.posts.list(params?)
GET /wp/v2/posts. Returns PaginatedResponse<WPPost>.
client.posts.get(id)
GET /wp/v2/posts/:id. Returns WPPost.
client.pages.list(params?)
GET /wp/v2/pages. Returns PaginatedResponse<WPPage>.
client.pages.get(id)
GET /wp/v2/pages/:id. Returns WPPage.
client.users.me()
GET /wp/v2/users/me (authenticated). Returns WPUser.
client.auth.login({ username, password })
Authenticates and stores the JWT token for subsequent requests.
client.auth.logout()
Clears the stored JWT token.