Code Monkey home page Code Monkey logo

wordpress_client's Introduction

wordpress_client

Pub Version
Dart Flutter WordPress
Easily interact with the Wordpress REST API. Get support for most common endpoints & CRUD operations.

โœจ Features

  • ๐Ÿ”„ Request Synchronization.
  • ๐Ÿ“ฆ API discovery support.
  • โฒ๏ธ Measures request completion time.
  • ๐Ÿ“ Supports all CRUD operations.
  • ๐ŸŒ Supports all common endpoints.
  • ๐ŸŽจ Custom Requests & Authorization systems.
  • ๐Ÿ” 3 Popular authorization methods.
  • ๐ŸŽฃ Events for preprocessing response operations.

๐Ÿ“– How to Use

1. Setup

Add wordpress_client in your pubspec.yaml:

dependencies:
 wordpress_client: ^8.3.7

๐Ÿ’ก Ensure you get the latest version here.

Import the package where you need:

import 'package:wordpress_client/wordpress_client.dart';

2. Initialization

You can initialize WordpressClient in two methods:

  • Default (Simple Method)
  • Advanced (with Bootstrapper for additional configurations)

Simple Method:

final baseUrl = Uri.parse('https://example.com/wp-json/wp/v2');
final client = WordpressClient(baseUrl: baseUrl);

client.initialize();

๐Ÿ“˜ Learn more about the Advanced Method here.

3. Sending Requests

Example to retrieve 20 recent WordPress posts in ascending order:

final request = ListPostRequest(
  page: 1,
  perPage: 20,
  order = Order.asc,
);

final wpResponse = await client.posts.list(request);

// Dart 3 style
switch (wpResponse) {
    case WordpressSuccessResponse():
      final data = wpResponse.data; // List<Post>
      break;
    case WordpressFailureResponse():
      final error = wpResponse.error; // WordpressError
      break;
}

// or
// wordpress_client style
final result = postsResponse.map(
    onSuccess: (response) {
      print(response.message);
      return response.data;
    },
    onFailure: (response) {
      print(response.error.toString());
      return <Post>[];
    },
);

Refer to the documentation for more request examples.

๐Ÿ”’ Supported Authorization

1. AppPasswordAuth

By the WordPress Team, this method uses basic HTTP authentication where credentials are passed with every request. Details

2. BasicJwtAuth

Developed by Enrique Chavez, it involves JSON Web Token (JWT) authentication where a token is issued and then used in subsequent requests. Details

3. UsefulJwtAuth

By Useful Team, this is another implementation using JWT for authentication purposes. Details

For custom authorization, check the Authorization Wiki.

๐Ÿ“‹ Supported REST Methods

Endpoint Create Read Update Delete
Posts โœ… โœ… โœ… โœ…
Comments โœ… โœ… โœ… โœ…
Categories โœ… โœ… โœ… โœ…
Tags โœ… โœ… โœ… โœ…
Users โœ… โœ… โœ… โœ…
Me โœ… โœ… โœ… โœ…
Media โœ… โœ… โœ… โœ…
Pages โœ… โœ… โœ… โœ…
Application Passwords โœ… โœ… โœ… โœ…
Search - โœ… - -
Post Revisions โŒ โŒ โŒ โŒ
Taxonomies โŒ โŒ โŒ โŒ
Post Types โŒ โŒ โŒ โŒ
Post Statuses โŒ โŒ โŒ โŒ
Settings โŒ โŒ โŒ โŒ

๐Ÿ“ข Custom Response Types

Learn how to implement Custom Requests here.

๐Ÿ“ฃ Feedback

  • ๐Ÿ› For bugs or feature requests, use the issue tracker.
  • ๐Ÿ’ก Contributions are always appreciated. PRs are welcome!

๐Ÿ“œ License

Licensed under MIT.


Support Me:

Buy Me A Coffee

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.