-
Notifications
You must be signed in to change notification settings - Fork 14
Interfaces and Extensions
wordpress_client
keeps the core API focused by exposing typed request classes and optional convenience extensions.
- Each resource is represented by an interface (e.g.,
PostsInterface
) - Requests are explicit:
ListPostRequest
,RetrievePostRequest
,CreatePostRequest
, etc. - Interfaces mix in operations:
ListOperation<T, R>
,RetrieveOperation<T, R>
,CreateOperation<T, R>
,UpdateOperation<T, R>
,DeleteOperation<R>
final res = await client.posts.list(ListPostRequest(perPage: 20));
final posts = res.asSuccess().data;
To keep call sites concise, many interfaces provide an extensions
helper with common shortcuts.
final post = await client.posts.extensions.getById(123);
final slug = await client.posts.extensions.findBySlug('hello-world');
final all = await client.posts.extensions.listAll(perPage: 50);
Extensions exist for: Posts, Pages, Media, Users, Categories, Tags, Comments, Blocks, Block Types, Templates, Template Parts, Template/Part Revisions, Navigations, Navigation Revisions/Autosaves, Menus, Menu Items, Menu Locations, Widgets, Sidebars, Widget Types, Post Types, Taxonomies, Post Statuses, Themes, Global Styles, Post/Page Revisions, and Settings.
Pro tip: Extensions are just thin wrappers around the typed requestsβmix them with explicit requests as needed.
Every major interface surfaces a query
property that returns a fluent builder. It autoβseeds the correct list request type and exposes common helpers:
final res = await client.posts.query
.withPage(1)
.withPerPage(10)
.withSearch('welcome')
.execute();
Advanced users can mutate the underlying seed via:
final res2 = await client.posts.query
.configureSeed((seed) { seed.context = RequestContext.view; })
.execute();
See also: Usage βΊ Fluent Queries
- π Welcome to our Wiki!
- π Usage
- π Using Custom Requests
- π‘ Authorization
- π Supported REST Methods
- π API Changelog
- π Middlewares
- π« Parallel Requests
- π§© Interfaces & Extensions
- π‘οΈ Error Handling & Responses
- βοΈ Bootstrap & Configuration
- π Events & Statistics
- π Pagination & Finders