wordpress_client 6.3.2 copy "wordpress_client: ^6.3.2" to clipboard
wordpress_client: ^6.3.2 copied to clipboard

outdated

A library written purely in dart to interact with Wordpress REST API in a fluent manner. Supports Authorization as well.

WordpressClient

pub.dev

Dart Flutter WordPress

likes popularity pub points

wordpress_client is a library written purely in Dart to interact with Wordpress REST API in a fluent pattern. This library is a port of WordpressCore library written in C# (also written by me)


Features #

  • Support for 3 widely used authorization methods.
  • Response preprocessor callback support.
  • Provides statistics such as time taken for the request to complete.
  • Support for Custom Requests / Authorization systems.
  • Nullable support.
  • And many more!

Usage #

You can use this library just like any other Dart package.

  • Add wordpress_client as a dependency on pubspec.yaml file on your project root. At the time of this writing, the latest package version is 5.1.0. Do check Package Page to get latest version.
dependencies:
  wordpress_client: {latest}
  • Import the library to your project class in which you want to use the library. Also, it is to note that imports are split between multiple files, this helps to keep Dart auto-completion less cluttered. i.e., All request classes are seperated into another file, same goes for responses. You can utilize Intellisense to import them easily.
import 'package:wordpress_client/wordpress_client.dart';
  • Initializing the client can be done in two ways. It is recommended to initialize WordpressClient once and assign the instance to a variable for later use. State of the properties are stored only in that particular instance of the client.

    • Simple method, Initialize with default values.
    • Advanced method (with Bootstrapper to configure various settings like User Agent, Authorization etc)

Simple method #

WordpressClient client = new WordpressClient('https://www.replaceme.com/', 'wp-json/wp/v2');

You can read about advanced method in Advanced Method wiki page.

  • Now you are ready to send requests to Wordpress REST API. For example, to send request to get the latest 20 posts from your Wordpress site in Ascending order, you can use the following code.:
WordpressResponse<List<Post>?> postsResponse = await client.posts.list(
    WordpressRequest(
      requestData: ListPostRequest()
        ..page = 1
        ..perPage = 20
        ..order = Order.asc,
    ),
  );

WordpressResponse is a class which wraps around the actual result object. It also provides access to statistical data related to the response such as the time taken for the request to complete, status codes, Total number of pages etc.

You can access the response object by calling postsResponse.data. It will be null if the request failed or if the library failed to parse the response.

Supported Authorization methods #

This library has 3 authorization methods currently supported:

For Custom Authorization implementation, Check out Authorization wiki page.

Supported REST Methods #

Create Read Update Delete
Posts yes yes yes yes
Pages --- --- --- ---
Comments yes yes yes yes
Categories yes yes yes yes
Tags yes yes yes yes
Users yes yes yes yes
Me yes yes yes yes
Media yes yes yes yes
Post Revisions --- --- --- ---
Taxonomies --- --- --- ---
Post Types --- --- --- ---
Post Statuses --- --- --- ---
Settings --- --- --- ---

Custom Response Types (Custom Requests) #

Check out Custom Response Types wiki page.

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Contributions #

Contributions are always welcome! If you find any bugs/errors, open an issue describing about it and how to reproduce it. :D meanwhile, PR's for new features/bug fixes are always welcome!

License #

MIT

Buy Me A Coffee

30
likes
0
pub points
80%
popularity

Publisher

verified publisherarunprakashg.com

A library written purely in dart to interact with Wordpress REST API in a fluent manner. Supports Authorization as well.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

cookie_jar, dio, dio_cookie_manager, http_parser, path, synchronized

More

Packages that depend on wordpress_client