REST API 文档

💡 云策文档标注

概述

本文档介绍了用于简化 WordPress REST API 交互的客户端库,这些库支持多种编程语言,便于外部应用程序连接。但请注意,除 Backbone.js 客户端外,其他库非 WordPress 核心部分,且可能需要额外认证插件。

关键要点

  • 客户端库简化了查询或创建 WordPress REST API 资源的过程,支持多种编程语言。
  • 除 Backbone.js 客户端外,其他库非 WordPress 核心,不一定由 WordPress REST API 团队维护或认可。
  • 从 WordPress 管理界面、主题或插件外部进行认证请求时,需要单独的认证插件。
  • 提供了多种语言的客户端库示例,如 PHP、JavaScript、Ruby、C#/.NET 和 Dart/Flutter。

代码示例

PHP
Requests for PHP is a general purpose HTTP request library. While not specifically designed for the WordPress REST API, it is a great tool for interacting with any HTTP API.
WordPress-PHP-SDK is a PHP SDK for the WordPress REST API, which can be installed using composer.
WordPress-SDK is a Laravel package for the WordPress REST API, which can be installed using composer.
JavaScript
The Backbone.js client is built in to WordPress core and provides Backbone.js models & collections for working with REST API resources.
node-wpapi is an isomorphic JavaScript client library for querying or writing to the REST API using an intuitive chaining syntax. It can be used with Node.js or with client-side JavaScript applications.
ember-wordpress provides a connection between Ember Data and the REST API
Ruby
wp-api-client: a read-only REST API client written in Ruby.
C# / .NET
WordPressPCL: a full REST API client written in C#.
Dart / Flutter
wordpress_client: A library exposing a fluent api to interact with the WordPress REST API.

📄 原文内容

The API can be used from any application by sending basic HTTP requests; however, client libraries simplify the process of querying or creating specific resources. These libraries make it easy to connect an external application to the WordPress REST API using a variety of programming languages.

Aside from the Backbone.js client, these libraries are not part of WordPress core, and are not necessarily maintained or endorsed by the WordPress REST API team.

To perform authenticated requests from outside of the WordPress admin, themes, or plugins, a separate authentication plugin is required.

PHP

Requests for PHP is a general purpose HTTP request library. While not specifically designed for the WordPress REST API, it is a great tool for interacting with any HTTP API.

WordPress-PHP-SDK is a PHP SDK for the WordPress REST API, which can be installed using composer.

WordPress-SDK is a Laravel package for the WordPress REST API, which can be installed using composer.

JavaScript

The Backbone.js client is built in to WordPress core and provides Backbone.js models & collections for working with REST API resources.

node-wpapi is an isomorphic JavaScript client library for querying or writing to the REST API using an intuitive chaining syntax. It can be used with Node.js or with client-side JavaScript applications.

ember-wordpress provides a connection between Ember Data and the REST API

Ruby

wp-api-client: a read-only REST API client written in Ruby.

C# / .NET

WordPressPCL: a full REST API client written in C#.

Dart / Flutter

wordpress_client: A library exposing a fluent api to interact with the WordPress REST API.