Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
W

WordPressPCL

> 编程语言
Open source

This is a portable library for consuimg the WordPress REST-API in (almost) any C# application

357 stars0 likes0 views
WebsiteGitHub

About

This is a portable library for consuimg the WordPress REST-API in (almost) any C# application

WordPressPCL

This is a .NET 10 library for consuming the WordPress REST API in C# applications. 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.

  • WordPress 4.7 or newer

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):

  • JWT Authentication for WP REST API
  • JWT Auth By Useful Team

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

Release Process

WordPressPCL uses GitHub Releases as the source of truth for publishing new package versions.

  1. Update CHANGELOG.md with the release highlights.
  2. Create a GitHub release with a vX.Y.Z tag (or vX.Y.Z-suffix for pre-releases) and GitHub-generated release notes.
  3. Publishing that release triggers the NuGet workflow, which builds and publishes the same version to NuGet.

Runtime Requirement

WordPressPCL 3.0 targets .NET 10 only. Upgrading from 2.x is a breaking change and requires applications and test environments to move to the .NET 10 SDK/runtime before restoring, building, or running tests.

Versioned Reference Docs

  • Version 3.x reference docs
  • Version 2.x reference docs
  • Version 1.x reference docs

Supported Platforms

WordPressPCL 3.0 targets .NET 10 and is intended for applications running on the current .NET platform:

.NET implementation Version support
.NET 10.0

Quickstart: Using the API Wrapper

…

Dependency injection and IHttpClientFactory

For ASP.NET Core and worker services, prefer registering WordPressClient through DI so that HttpClient pooling is managed by IHttpClientFactory.

csharp
using Microsoft.Extensions.DependencyInjection;
using WordPressPCL;

builder.Services
    .AddWordPressClient(
        (services, httpClient) =>
        {
            httpClient.BaseAddress = new Uri(builder.Configuration["WordPress:BaseUrl"]!);
            httpClient.DefaultRequestHeaders.Add("User-Agent", "MyApp/1.0");
        },
        (services, client) =>
        {
            client.Auth.UseBasicAuth(
                builder.Configuration["WordPress:Username"]!,
                builder.Configuration["WordPress:ApplicationPassword"]!);
        });

You can then request WordPressClient anywhere DI is available:

csharp
public sealed class PublishWorker(WordPressClient client)
{
    public Task> GetPostsAsync()
        => client.Posts.GetAllAsync();
}

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
Page Revisions --- yes --- yes
Post Autosaves yes yes --- ---
Page Autosaves yes yes --- ---
Taxonomies --- yes --- ---
Post Types --- yes --- ---
Post Statuses --- yes --- ---
Settings --- yes yes ---
Plugins yes yes yes yes
Themes --- yes --- ---
Search --- yes --- ---
URL Details --- yes --- ---

Notes:

  • Post revisions are available through client.Posts.Revisions(postId).
  • Page revisions are available through client.Pages.Revisions(pageId).
  • Post and page autosaves are available through client.Posts.Autosaves(postId) and client.Pages.Autosaves(pageId).

Endpoint Coverage and Gaps

WordPressPCL currently provides dedicated clients for the most common wp/v2 endpoints:

  • Posts, Pages, Comments, Categories, Tags, Users and Media
  • Taxonomies, Post Types, Post Statuses and Settings
  • Post and page revisions via client.Posts.Revisions(postId) and client.Pages.Revisions(pageId)
  • Post and page autosaves via client.Posts.Autosaves(postId) and client.Pages.Autosaves(pageId)
  • Plugins and Themes
  • Search via client.Search
  • URL details via client.UrlDetails (wp-block-editor/v1/url-details, authentication required)

The standard WordPress REST API reference also includes endpoints that do not yet have first-class wrappers in this library, including:

  • newer block editor endpoints such as block types, blocks, block rendering, templates, template parts and global styles
  • navigation, sidebars, widgets and widget types

You can still work with unsupported standard endpoints, plugin namespaces and site-specific custom endpoints by using CustomRequest.

csharp
// Discover the namespaces and routes exposed by a site
dynamic apiIndex = await client.CustomRequest.GetAsync("", ignoreDefaultPath: true);

// Call a plugin or custom namespace route
dynamic customEndpoint = await client.CustomRequest.GetAsync("wc/v3/products", useAuth: true);

For a fuller endpoint-by-endpoint summary, see docs/v3/endpoint-coverage.md.

Additional Features

  • Authentication using JSON Web Tokens (JWT)
  • HttpResponsePreProcessing: manipulate the API response before deserializing it

Contribution Guidelines

We're very happy to get input from the community on this project! See CONTRIBUTING.md for full details on setting up a development environment, running tests, and submitting pull requests.

In brief:

  • Open an issue before starting work so we can discuss scope and avoid duplicate effort.
  • Follow the Microsoft C# coding guidelines.
  • Add or update tests to cover your change.
  • In order to run the tests locally, refer to the dev/install.md file and use Docker Compose.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C#

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言