WordPressPCL 2.1.0

dotnet add package WordPressPCL --version 2.1.0                
NuGet\Install-Package WordPressPCL -Version 2.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WordPressPCL" Version="2.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add WordPressPCL --version 2.1.0                
#r "nuget: WordPressPCL, 2.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install WordPressPCL as a Cake Addin
#addin nuget:?package=WordPressPCL&version=2.1.0

// Install WordPressPCL as a Cake Tool
#tool nuget:?package=WordPressPCL&version=2.1.0                

WordPressPCL

Integration Tests NuGet

This is a portable library for consuming the WordPress REST-API in (almost) any C# application. If you find bugs or have any suggestions, feel free to create an issue.

Documentation

https://wp-net.github.io/WordPressPCL/

Quickstart

WordPress Requirements

Since WordPress 4.7 the REST API has been integrated into the core so there's no need for any plugins to get basic functionality.

If you want to access protected endpoints, there are two authentication options:

  • Authentication using JSON Web Tokens (JWT) (plugin required)
  • Basic Authentication using Application Passwords

Supported JWT Authentication Plugins (install either of the following):

To use Application Passwords for authentication read through:

https://make.wordpress.org/core/2020/11/05/application-passwords-integration-guide/

Including WordPressPCL

The WordPressPCL API Wrapper is avaiable through NuGet:

> Install-Package WordPressPCL

Supported Plattforms

WordPressPCL is built on top of the .NET Standard targeting netstandard version 2.0 - therefore it should work on the following plaforms (and newer):

.NET implementation Version support
.NET and .NET Core 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0
.NET Framework 4.6.1 2, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Mono 5.4, 6.4
Xamarin.iOS 10.14, 12.16
Xamarin.Mac 3.8, 5.16
Xamarin.Android 8.0, 10.0
Universal Windows Platform 10.0.16299, TBD
Unity 2018.1

Quickstart: Using the API Wrapper

// Client construction

//pass the Wordpress REST API base address as string
var client = new WordPressClient("http://demo.wp-api.org/wp-json/");

//or pass the base address as strongly typed Uri
const wpBaseAddress = new Uri("http://demo.wp-api.org/wp-json/");
var client = new WordPressClient(wpBaseAddress);

//or to reuse an HttpClient pass the HttpClient with base address set to api's base address
httpClient.BaseAddress = new Uri("http://demo.wp-api.org/wp-json/")
var client = new WordPressClient(httpClient);

// Posts
var posts = await client.Posts.GetAllAsync();
var postbyid = await client.Posts.GetByIdAsync(id);
var postsCount = await client.Posts.GetCountAsync();

// Comments
var comments = await client.Comments.GetAllAsync();
var commentbyid = await client.Comments.GetByIdAsync(id);
var commentsbypost = await client.Comments.GetCommentsForPostAsync(postid, true, false);

// Plugins
var plugins = await client.Plugins.GetAllAsync(useAuth:true);
var installedplugin = await client.Plugins.InstallAsync("akismet");
var activateplugin = await client.Plugins.ActivateAsync(installedplugin);
var deactivateplugin = await client.Plugins.DeactivateAsync(installedplugin);
var deleteplugin = await client.Plugins.DeleteAsync(installedplugin);

// Authentication
var client = new WordPressClient(ApiCredentials.WordPressUri);

//Either Bearer Auth using JWT tokens
client.Auth.UseBearerAuth(JWTPlugin.JWTAuthByEnriqueChavez);
await client.Auth.RequestJWTokenAsync("username", "password");
var isValidToken = await client.IsValidJWTokenAsync();
  
//Or Basic Auth using Application Passwords
client.Auth.UseBasicAuth("username", "password");

// now you can send requests that require authentication
var response = client.Posts.DeleteAsync(postId);

Supported REST Methods

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

Additional Features

Contribution Guidelines

We're very happy to get input from the community on this project! To keep the code clean we ask you to follow a few simple contribution guidelines.

First, create an issue describing what feature you want to add or what problem you're trying to solve, just to make sure no one is already working on that. That also gives us a chance to debate whether a feature is within the scope of this project.

Second, please try to stick to the official C# coding guidelines. https://msdn.microsoft.com/en-us/library/ms229002(v=vs.110).aspx

Also, make sure to write some tests covering your new or modified code.

In order to run the tests on local machine please refer to the install.md file in the dev directory of the repository. Docker along with docker-compose cli will be required to run the tests.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on WordPressPCL:

Package Downloads
BlazingApple.Blog.Services

Package Description

VEFramework.VEDriversLite.Extensions.WooCommerce

.NET drivers for getting information from and to the WooCommerce instance. It can hanlde also communication with main WordPress database

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on WordPressPCL:

Repository Stars
Webreaper/Damselfly
Damselfly is a server-based Photograph Management app. The goal of Damselfly is to index an extremely large collection of images, and allow easy search and retrieval of those images, using metadata such as the IPTC keyword tags, as well as the folder and file names. Damselfly includes support for object/face detection.
Version Downloads Last updated
2.1.0 10,796 4/4/2024
2.0.2 21,900 9/25/2023
2.0.1 53,191 12/21/2022
2.0.0 96,850 4/12/2022
2.0.0-beta.2 220 3/22/2022
2.0.0-beta 685 3/21/2022
2.0.0-alpha 704 1/27/2022
1.9.0 276,659 4/19/2021
1.8.5 19,605 1/6/2021
1.8.4 1,595 12/26/2020
1.8.2 6,028 11/7/2020
1.7.2 4,827 9/22/2020
1.7.1 81,053 5/11/2020
1.7.0 1,077 5/11/2020
1.6.2 108,815 3/19/2019
1.6.1 9,969 11/15/2018
1.6.0-beta1 1,792 11/8/2018
1.5.1 2,152 10/26/2018
1.5.0 3,949 9/10/2018
1.4.6 1,546 8/23/2018
1.4.5 6,401 6/18/2018
1.4.4 1,711 6/2/2018
1.4.3 1,494 6/2/2018
1.4.2 5,335 4/18/2018
1.4.1 1,507 4/18/2018
1.4.1-alpha 1,524 3/15/2018
1.4.0 3,285 3/9/2018
1.3.3 2,316 1/29/2018
1.3.2 1,643 1/18/2018
1.3.1 1,580 1/10/2018
1.3.0 1,978 10/30/2017
1.3.0-alpha 1,311 10/28/2017
1.2.1 1,547 10/16/2017
1.2.0 1,569 10/7/2017
1.1.1 1,687 9/18/2017
1.1.0 1,520 9/11/2017
1.0.0 1,799 8/9/2017
0.1.9 1,681 6/19/2017
0.1.8 1,634 6/19/2017
0.1.7 1,596 6/1/2017
0.1.6 1,571 5/23/2017
0.1.5 1,490 5/14/2017
0.1.4 1,608 4/30/2017
0.1.2-alpha 1,439 3/14/2017
0.1.1-alpha 1,437 12/7/2016
0.1.0 6,542 8/18/2016
0.0.5 1,568 8/18/2016
0.0.4 1,670 8/4/2016
0.0.3 1,623 8/4/2016
0.0.2 1,617 8/4/2016
0.0.1 2,301 8/4/2016

V2.1.0
- Upgraded dependencies
- Fix GetCurrentUserAsync() naming
- Allow httpclient injection without base address
- Added optional ignoreDefaultPath on CustomRequest methods

V2.0.2
- Support for Plugins
- Support for Statuses in UsersQueryBuilder
- Upgraded Newtonsoft.Json dependency to 13.0.3

V2.0.1
- Upgraded Newtonsoft.Json dependency to 13.0.1

V2.0.0
- Dropped netstandard1.x support
- Added Async-Suffix for all public async methods
- Moved Auth-related functionality to Auth-Sub-Client
- Error handling for WP_DEBUG_DISPLAY
- Moved Settings functionality to Settings-Sub-Client
New Features:
- WordPressClient accepts endpoint also as Uri
- Get total Post count without the actual posts
- Generic JWT and Basic Auth support
     
V1.9.0
- Support for Application Passwords
- Upped netstandard1.1 to netstandard1.3

V1.8.5
- Bugfix for Query Builder, will now append default enum values to query string for easier debugging

V1.8.4
- Bugfix for HttpClient injection

V1.8.2
- Support for JWT Auth Plugin

V1.7.2
- Added support for posts trash status
- Added support for providing httpclient to WordPressClient

V1.7.1
- Added Icon
- Updated License Expression

V1.7.0
- Added optional MIME-Type override for Media upload
- Improved handling of HttpClient headers
- Downgraded JSON.NET dependency to V11.0.1
- Exceptions Refactoring

V1.6.2
- Clean up file stream after upload #166
- Added .kmz & .kml Mime Types #162

V1.6.1
- Fix for #147 where Capabilities might contain strings instead of bool

V1.6.0-beta1
- marking all Meta properties as dynamic as the structure seems to be very volatile

V1.5.1
- Make height & width optional in MediaSizes (#143)

V1.5.0
- Enhanced Error handling
https://github.com/wp-net/WordPressPCL/issues/138

V1.4.6
- Bugfix: Add DefaultValueHandling to Comment Status property

V1.4.5
- Bugfix: Add NullValueHandling to FeaturedMedia property

V1.4.4
- Add Yoast Taxonomy Terms

V1.4.3
- Bugfix: Add default JsonSerzializerSettings, setting MissingMemberHandling to ignore

V1.4.2
- Bugfix: delete requests return bool instead of HTTPResponseMessage

V1.4.1-alpha
- Experimental WordPress.com support (readonly)
- Experimental Descending Threaded Comments support

V1.4.0
- making HttpClient static
- Exceptions will be thrown instead of hiding them
- don't auto-append /wp-json to WordPress Uri

V1.3.3
- Fixing update of Comment.Status

V1.3.2
- Fixing Comment.Status issue

V1.3.1
- added maxDepth option for threaded comments

V1.3.0
- added ToThreaded-method for transforming comments
- pass deserialization settings into HttpHelper class
- Added .netstandard 2.0 support
- upload media directly from file path (.netstandard 2.0 only)

V1.2.1
- added JWT getter & setter methods

V1.2
- added helper method to sort comments for a threaded view
- added method to get all comments for a post id
- fixed some async issues for better performance
- added logout method