Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arunprakashg/wordpress_client
A powerful and easy-to-use WordPress REST API client for Dart & Flutter.
https://github.com/arunprakashg/wordpress_client
dart dart-library flutter hacktoberfest hacktoberfest2021 wordpress
Last synced: 18 days ago
JSON representation
A powerful and easy-to-use WordPress REST API client for Dart & Flutter.
- Host: GitHub
- URL: https://github.com/arunprakashg/wordpress_client
- Owner: ArunPrakashG
- License: mit
- Created: 2021-07-09T14:45:38.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-09-08T17:17:43.000Z (4 months ago)
- Last Synced: 2024-10-19T07:53:15.041Z (3 months ago)
- Topics: dart, dart-library, flutter, hacktoberfest, hacktoberfest2021, wordpress
- Language: Dart
- Homepage:
- Size: 741 KB
- Stars: 34
- Watchers: 3
- Forks: 13
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
## 🚀 Features
- 📦 API discovery support.
- ⏲️ Measures request completion time.
- 📝 Supports all CRUD operations.
- 🌐 Supports all common endpoints.
- 🎨 Custom Requests & Authorization systems.
- 🔐 3 Popular authorization methods.
- 📦 Third party Database integration.
- 🔧 Middlewares for request & response operations.
- 🎣 Events for preprocessing response.
- 🚀 Execute requests in Parallel.## Future
If you find any functionality which you require is missing from the package and you are not able to work it out using built in options like raw requests etc, then please share the functionality in details as a comment here: https://github.com/ArunPrakashG/wordpress_client/discussions/55
## 📦 Installation
Add `wordpress_client` to your `pubspec.yaml`:
```dart
dependencies:
wordpress_client: ^8.5.3
```> 💡 Ensure you get the [latest version here](https://pub.dev/packages/wordpress_client).
Then run `flutter pub get` to install the package.
## 🔧 Usage
Import the package where you need:
```dart
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:**
```dart
final baseUrl = Uri.parse('https://example.com/wp-json/wp/v2');
final client = WordpressClient(baseUrl: baseUrl);
```> 📘 Learn more about the [Advanced Method here](https://github.com/ArunPrakashG/wordpress_client/wiki/Usage#-advanced-method).
### **3. Sending Requests**
Example to retrieve 20 recent WordPress posts in ascending order:
```dart
final request = ListPostRequest(
page: 1,
perPage: 20,
order = Order.asc,
);final response = await client.posts.list(request);
// Dart 3 style
switch (response) {
case WordpressSuccessResponse():
final data = response.data; // List
break;
case WordpressFailureResponse():
final error = response.error; // WordpressError
break;
}// or
// using map method to handle both success and failure
final result = response.map(
onSuccess: (response) {
// response is a WordpressSuccessResponse>print(response.message);
return response.data;
},
onFailure: (response) {
// response is a WordpressFailureResponse
print(response.error.toString());
return [];
},
);// or
// you can cast to a state directly; this will throw an error if the response is of the wrong type
final result = response.asSuccess(); // or response.asFailure();
```Refer to the [documentation](https://github.com/ArunPrakashG/wordpress_client/wiki/Usage) 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](https://make.wordpress.org/core/2020/11/05/application-passwords-integration-guide/)
### 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](https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/)
### 3. **UsefulJwtAuth**
By Useful Team, this is another implementation using JWT for authentication purposes. [Details](https://github.com/usefulteam/jwt-auth)
> For custom authorization, check the [Authorization Wiki](https://github.com/ArunPrakashG/wordpress_client/wiki/Authorization).
## 📋 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](https://github.com/ArunPrakashG/wordpress_client/wiki/Using-Custom-Requests).
## 🤝 Feedback & Contributing
- 🐛 For bugs or feature requests, use the [issue tracker][tracker].
- 💡 Contributions are always appreciated. PRs are welcome!## 📄 License
This project is [MIT](https://github.com/ArunPrakashG/wordpress_client/blob/master/LICENSE) licensed.
---
If you find this package helpful, consider supporting the development:[![Buy Me A Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/arunprakashg)
[tracker]: https://github.com/ArunPrakashG/wordpress_client/issues