{"id":15008507,"url":"https://github.com/dreamsoftin/flutter_wordpress","last_synced_at":"2025-04-05T19:13:30.236Z","repository":{"id":34242450,"uuid":"170073166","full_name":"dreamsoftin/flutter_wordpress","owner":"dreamsoftin","description":"Flutter WordPress API","archived":false,"fork":false,"pushed_at":"2023-08-08T14:31:24.000Z","size":788,"stargazers_count":197,"open_issues_count":37,"forks_count":121,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-03-29T18:07:21.423Z","etag":null,"topics":["dart","dartlang","flutter","flutter-plugin","flutter-plugins","wordpress","wordpress-api"],"latest_commit_sha":null,"homepage":"https://pub.dartlang.org/packages/flutter_wordpress","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dreamsoftin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-11T05:30:18.000Z","updated_at":"2025-02-20T20:28:34.000Z","dependencies_parsed_at":"2024-06-21T02:13:39.670Z","dependency_job_id":"5eb56eae-7d3a-4e03-88f4-3b5ba2dbd95f","html_url":"https://github.com/dreamsoftin/flutter_wordpress","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamsoftin%2Fflutter_wordpress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamsoftin%2Fflutter_wordpress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamsoftin%2Fflutter_wordpress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamsoftin%2Fflutter_wordpress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dreamsoftin","download_url":"https://codeload.github.com/dreamsoftin/flutter_wordpress/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247386265,"owners_count":20930619,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dart","dartlang","flutter","flutter-plugin","flutter-plugins","wordpress","wordpress-api"],"created_at":"2024-09-24T19:19:10.520Z","updated_at":"2025-04-05T19:13:30.202Z","avatar_url":"https://github.com/dreamsoftin.png","language":"Dart","readme":"# Flutter Wordpress\n\n[pub.dev](https://pub.dev/packages/flutter_wordpress)\n\nThis library uses [WordPress REST API V2](https://developer.wordpress.org/rest-api/) to provide a way for your application to interact with your WordPress website.\n\n[Tutorial - by Ritesh Sharma](https://medium.com/flutter-community/building-flutter-apps-with-wordpress-backend-part-1-e56414a4a79b)\n\n## Screenshots\n\n\u003cimg src='https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/master/example/images/screenshots/posts.png' height='400'\u003e\n\n## Requirements\n\nFor authentication and usage of administrator level REST APIs, you need to use either of the two popular authentication plugins in your WordPress site:\n\n1. [Application Passwords](https://wordpress.org/plugins/application-passwords/)\n2. [JWT Authentication for WP REST API](https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/) \u003cstrong\u003e(recommended)\u003c/strong\u003e\n\n## Getting Started\n\n### 1. Import library\n\n#### First:\n\nFind your pubspec.yaml in the root of your project and add flutter_wordpress: ^0.2.0 under dependencies:\n\n#### Second:\n\n```dart\nimport 'package:flutter_wordpress/flutter_wordpress.dart' as wp;\n```\n\n### 2. Instantiate WordPress class\n\n```dart\nwp.WordPress wordPress;\n\n// adminName and adminKey is needed only for admin level APIs\nwordPress = wp.WordPress(\n  baseUrl: 'http://localhost',\n  authenticator: wp.WordPressAuthenticator.JWT,\n  adminName: '',\n  adminKey: '',\n);\n```\n\n### 3. Authenticate User\n\n```dart\nFuture\u003cwp.User\u003e response = wordPress.authenticateUser(\n  username: 'ChiefEditor',\n  password: 'chiefeditor@123',\n);\n\nresponse.then((user) {\n  createPost(user);\n}).catchError((err) {\n  print('Failed to fetch user: $err');\n});\n```\n\n### 4. Fetch Posts\n\n```dart\nFuture\u003cList\u003cwp.Post\u003e\u003e posts = wordPress.fetchPosts(\n  postParams: wp.ParamsPostList(\n    context: wp.WordPressContext.view,\n    pageNum: 1,\n    perPage: 20,\n    order: wp.Order.desc,\n    orderBy: wp.PostOrderBy.date,\n  ),\n  fetchAuthor: true,\n  fetchFeaturedMedia: true,\n  fetchComments: true,\n  postType: 'post'\n);\n```\n\n### 5. Fetch Users\n\n```dart\nFuture\u003cList\u003cwp.User\u003e\u003e users = wordPress.fetchUsers(\n  params: wp.ParamsUserList(\n    context: wp.WordPressContext.view,\n    pageNum: 1,\n    perPage: 30,\n    order: wp.Order.asc,\n    orderBy: wp.UsersOrderBy.name,\n    roles: ['subscriber'],\n  ),\n);\n```\n\n### 6. Fetch Comments\n\n```dart\nFuture\u003cList\u003cwp.Comment\u003e\u003e comments = wordPress.fetchComments(\n  params: wp.ParamsCommentList(\n    context: wp.WordPressContext.view,\n    pageNum: 1,\n    perPage: 30,\n    includePostIDs: [1],\n  ),\n);\n```\n\n### 7. Create User\n\n```dart\nFuture\u003cvoid\u003e createUser({@required String email, @required String username, @required String password, @required List\u003cString\u003e roles}) async {\n    await widget.wordPress.createUser(\n      user: wp.User(\n        email: email,\n        password: password,\n        username: username,\n        roles: roles\n      )\n    ).then((p) {\n      print('User created successfully ${p}');\n    }).catchError((err) {\n      print('Failed to create user: $err');\n    });\n  }\n```\n\n### 8. Create Post\n\n```dart\n  void createPost({@required wp.User user}) {\n    final post = widget.wordPress.createPost(\n      post: new wp.Post(\n        title: 'First post as a Chief Editor',\n        content: 'Blah! blah! blah!',\n        excerpt: 'Discussion about blah!',\n        authorID: user.id,\n        commentStatus: wp.PostCommentStatus.open,\n        pingStatus: wp.PostPingStatus.closed,\n        status: wp.PostPageStatus.publish,\n        format: wp.PostFormat.standard,\n        sticky: true,\n      ),\n    );\n\n    post.then((p) {\n      print('Post created successfully with ID: ${p.id}');\n    }).catchError((err) {\n      print('Failed to create post: $err');\n    });\n  }\n```\n\n### 9. create Comment\n\n```dart\n  void createComment({@required int userId, @required int postId}) {\n    final comment = widget.wordPress.createComment(\n      comment: new wp.Comment(\n        author: userId,\n        post: postId,\n        content: \"First!\",\n        parent: 0,\n      ),\n    );\n\n    comment.then((c) {\n      print('Comment successfully posted with ID: ${c.id}');\n    }).catchError((err) {\n      print('Failed to comment: $err');\n    });\n  }\n```\n\n### 10. Update Comment\n\n```dart\nFuture\u003cvoid\u003e updateComment({@required int id, @required int postId, @required wp.User user}) async {\n    await widget.wordPress.updateComment(\n      comment: new wp.Comment(\n        content: \"Comment Updated2!\",\n        author: user.id,\n        post: postId,\n      ),\n      id: id,\n    ).then((c) {\n      print('Comment updated successfully \"$c\"');\n    }).catchError((err) {\n      print('Failed to update Comment: $err');\n    });\n  }\n```\n\n### 11. Update Post\n\n```dart\nFuture\u003cvoid\u003e updatePost({@required int id, @required int userId}) async {\n    await widget.wordPress.updatePost(\n      post: new wp.Post(\n        title: 'First post as a Chief Editor',\n        content: 'Blah! blah! blah!',\n        excerpt: 'Discussion about blah!',\n        authorID: userId,\n        commentStatus: wp.PostCommentStatus.open,\n        pingStatus: wp.PostPingStatus.closed,\n        status: wp.PostPageStatus.publish,\n        format: wp.PostFormat.standard,\n        sticky: true,\n      ),\n      id: id, //\n    ).then((p) {\n      print('Post updated successfully with ID ${p}');\n    }).catchError((err) {\n      print('Failed to update post: $err');\n    });\n  }\n```\n\n### 12. Update User\n\n```dart\nFuture\u003cvoid\u003e updateUser({@required int id, @required String username, @required String email}) async {\n    await widget.wordPress.updateUser(\n      user: new wp.User(\n        description: \"This is description for this user\",\n        username: username,\n        id: id,\n        email: email\n      ),\n      id: id,\n    ).then((u) {\n      print('User updated successfully $u');\n    }).catchError((err) {\n      print('Failed to update User: $err');\n    });\n  }\n```\n\n\n### 13. Delete Comment\n\n```dart\nFuture\u003cvoid\u003e deleteComment({@required int id}) async {\n    await widget.wordPress.deleteComment(id: id).then((c) {\n      print('Comment Deleted successfully: $c');\n    }).catchError((err) {\n      print('Failed to Delete comment: $err');\n    });\n  }\n```\n\n### 14. Delete Post\n\n```dart\n  Future\u003cvoid\u003e deletePost({@required int id}) async {\n    await widget.wordPress.deletePost(id: id).then((p) {\n      print('Post Deleted successfully: $p');\n    }).catchError((err) {\n      print('Failed to Delete post: $err');\n    });\n  }\n```\n\n### 15. Delete User\n\n```dart\n  Future\u003cvoid\u003e deleteUser({@required int id, @required int reassign}) async {\n    await widget.wordPress.deleteUser(id: id, reassign: reassign).then((u) {\n      print('User Deleted successfully: $u');\n    }).catchError((err) {\n      print('Failed to Delete user: $err');\n    });\n  }\n```\n\n### 16. Upload Media\n\n```dart\n  uploadMedia(File image) async {\n  var media = await wordPress.uploadMedia(image).then((m) {\n    print('Media uploaded successfully: $m');\n  }).catchError((err) {\n    print('Failed to upload Media: $err');\n  });\n  int mediaID = media['id'];  \n}\n```\n\n## Future Work\n\n1. Implementing OAuth 2.0 authentication.\n\n## Contributors\n- [Suraj Shettigar](https://github.com/SurajShettigar)\n- [Sachin Ganesh](https://github.com/SachinGanesh)\n- [Harm-Jan Roskam](https://github.com/harmjanr)\n- [Yahya Makarim](https://github.com/ymakarim)\n- [Garv Maggu](https://github.com/GarvMaggu)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdreamsoftin%2Fflutter_wordpress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdreamsoftin%2Fflutter_wordpress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdreamsoftin%2Fflutter_wordpress/lists"}