Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/XiaoFaye/WooCommerce.NET
A .NET Wrapper for WooCommerce/WordPress REST API
https://github.com/XiaoFaye/WooCommerce.NET
api-client c-sharp restful-api woocommerce wordpress-api wordpress-plugin
Last synced: 3 months ago
JSON representation
A .NET Wrapper for WooCommerce/WordPress REST API
- Host: GitHub
- URL: https://github.com/XiaoFaye/WooCommerce.NET
- Owner: XiaoFaye
- License: mit
- Created: 2015-01-24T01:25:12.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2023-11-27T09:22:24.000Z (12 months ago)
- Last Synced: 2024-08-01T04:38:42.812Z (3 months ago)
- Topics: api-client, c-sharp, restful-api, woocommerce, wordpress-api, wordpress-plugin
- Language: C#
- Homepage:
- Size: 331 KB
- Stars: 389
- Watchers: 43
- Forks: 216
- Open Issues: 35
-
Metadata Files:
- Readme: Readme.md
- Changelog: Changes.md
- Funding: .github/FUNDING.yml
- License: License.md
Awesome Lists containing this project
README
WooCommerce.NET
======================A Brief Intro
-------------------WooCommerce.NET is a .NET library for calling WooCommerce/WordPress REST API with OAuth/JWT in .NET applications.
* [Visit WooCommerce](http://www.woothemes.com/woocommerce/)
* [Visit WooCommerce REST API DOCS](https://woocommerce.github.io/woocommerce-rest-api-docs/)
* [Visit WordPress REST API DOCS](https://developer.wordpress.org/rest-api/)[![NuGet](https://buildstats.info/nuget/WooCommerceNET)](http://www.nuget.org/packages/WooCommerceNET)
If this project has been helpful for you and you want to support it, please consider [Buying me a coffee](https://www.buymeacoffee.com/YU0SqVyrR):coffee:
**For priority paid support/consulting service, customized REST API development and plugins REST API development, please email to [James (me:sunglasses:)](mailto:[email protected]), thank you!**
Usage (WooCommerce REST API)
-------------------
* [How to use JSON.NET in WooCommerce.NET](https://github.com/XiaoFaye/WooCommerce.NET/wiki/How-to-use-JSON.NET-in-WooCommerce.NET)
* [Specifiy user agent when making requests to WooCommerce](https://github.com/XiaoFaye/WooCommerce.NET/wiki/Specifiy-user-agent-when-making-requests-to-WooCommerce)
* [How to use webRequestFilter and webResponseFilter in WooCommerce.NET](https://github.com/XiaoFaye/WooCommerce.NET/wiki/How-to-use-webRequestFilter-and-webResponseFilter-in-WooCommerce.NET)
* [Use X HTTP MethodOverride header for DELETE PUT](https://github.com/XiaoFaye/WooCommerce.NET/wiki/Use-X-HTTP-MethodOverride-header-for-DELETE-PUT)
* [Handle different types of Meta Value in WC Restful API V2](https://github.com/XiaoFaye/WooCommerce.NET/wiki/Handle-different-types-of-Meta-Value-in-WC-Restful-API-V2)Click to expand/collapse details...
```cs
using WooCommerceNET.WooCommerce.v3;
using WooCommerceNET.WooCommerce.v3.Extension;RestAPI rest = new RestAPI("http://www.yourstore.co.nz/wp-json/wc/v3/", "", "() {
{ "include", "10, 11, 12, 13, 14, 15" },
{ "per_page", "15" } });//Batch add/update/delete
CustomerBatch cb = new CustomerBatch();List create = new List();
create.Add(new Customer()
{
first_name = "first",
last_name = "last",
email = "[email protected]",
username = "firstnlast",
password = "12345"
});List update = new List();
update.Add(new Customer()
{
id = 4,
last_name = "xu2"
});List delete = new List() { 8 };
cb.create = create;
cb.update = update;
cb.delete = delete;var c = await wc.Customer.UpdateRange(cb);
```
Usage (WordPress REST API - JWT/OAuth Authentication)
-------------------
* [How to setup Restful API via JWT Authentication in WordPress](https://github.com/XiaoFaye/WooCommerce.NET/wiki/How-to-setup-Restful-API-via-JWT-Authentication-in-WordPress)
* [How to setup Restful API via OAuth 1.0a in WordPress](https://github.com/XiaoFaye/WooCommerce.NET/wiki/How-to-setup-Restful-API-via-OAuth-1.0a-in-WordPress)Click to expand/collapse details...
```cs
//using JWT
RestAPI rest = new RestAPI("http://www.yourstore.co.nz/wp-json/jwt-auth/v1/token", "", "");//using OAuth
RestAPI rest = new RestAPI("http://www.yourstore.co.nz/wp-json/wp/v2/", "", "");
rest.oauth_token = "";
rest.oauth_token_secret = "";WPObject wp = new WPObject(rest);
//Get all posts
var posts = await wp.Post.GetAll();//Add a post
var p = new Posts()
{
title = "abc",
content = "abc
"
};await wp.Post.Add(p);
//Update post with new values
await wp.Post.Update(123, new { title = "new post" });//Delete a post
await wp.Post.Delete(123);//Upload an image
await wp.Media.Add("imagename.jpg", @"C:\path\to\image\file.jpg");//Create a new user
await wp.Users.Add(new Users()
{
first_name = "test",
last_name = "test",
name = "test",
username = "test123",
email = "[email protected]",
password = "test@12345"
});```