PHPackages                             shelob9/jp-wp-rest-api-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. shelob9/jp-wp-rest-api-client

ActiveLibrary[API Development](/categories/api)

shelob9/jp-wp-rest-api-client
=============================

A simple client for working with the WordPress REST API via the WordPress HTTP API

89PHP

Since Nov 5Pushed 11y ago1 watchersCompare

[ Source](https://github.com/Shelob9/jp-wp-api-rest-api-client)[ Packagist](https://packagist.org/packages/shelob9/jp-wp-rest-api-client)[ RSS](/packages/shelob9-jp-wp-rest-api-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

JP WP REST API Client
=====================

[](#jp-wp-rest-api-client)

A simple client for creating and updating posts via the WordPress REST API via the WordPress HTTP API. Most of this code is based on articles I wrote for [Torque](http://torquemag.io/author/joshp/).

Utilizes [Mark Jaquith's WP-TLC-Transients Library](https://github.com/markjaquith/WP-TLC-Transients). Requires WordPress and the [WordPress REST API](http://wp-api.org).

### Installation

[](#installation)

This is not a plugin.

The easy and best way to add it is to add `"shelob9/jp-wp-rest-api-client": "dev-master"` to your site/plugin/theme's composer.json. Include composer autoloader.

Alternatively, add this repo to your site/plugin/theme using a Git Submodule or by employing the dark art of copypasta. Then manually include its file(s). Note: Caching isn't going to work unless you do a composer update or otherwise include [Mark Jaquith's WP-TLC-Transients Library](https://github.com/markjaquith/WP-TLC-Transients).

\###Usage

- Get A Post

```
    //get url string for posts in multiple CPTs with several filters
    $filters = array(
    	'posts_per_page' => 50,
    	'orderby' => 'modified_gmt',
    	'offset' => '10'
    );

    $post_types = array(
    	'post',
    	'page',
    	'book',
    	'author'
    );

    $url = JP_WP_REST_API_Client::posts_url_string( $post_types, $filters );

    //make request
    $response = JP_WP_REST_API_Client::get_json( $url );
```

- Get A Post Leveraging Cache

```
    //get url string for posts in multiple CPTs with several filters
    $filters = array(
    	'posts_per_page' => 50,
    	'orderby' => 'modified_gmt',
    	'offset' => '10'
    );

    $post_types = array(
    	'post',
    	'page',
    	'book',
    	'author'
    );

    $url = JP_WP_REST_API_Client::posts_url_string( $post_types, $filters );

    //make request
    $response = JP_WP_REST_API_Client::get_json_cached( $url );
```

- Get All The Posts Leveraging Cache `$posts = JP\_WP\_REST\_API\_Client::get\_json\_cached( json\_url() );```
- Copy Post From Remote Site To Local Site

```
    $url = 'http://remote_site.com/wp-json/5';

    //get post
    $post = JP_WP_REST_API_Client::get_json( $url );

    //insert to current site
    $new_post_id = JP_WP_REST_API_Client::insert_post_from_json( $post );
```

- Copy Post From Local Site To Remote Site

```
    $url = json_url( 'posts/1' );

    //get post
    $post = JP_WP_REST_API_Client::get_json( $url );

    //make sure we got JSON
    if ( is_string( $post ) ) {
        //setup auth using basic auth
        $auth = 'Basic ' . base64_encode( 'username' . ':' . 'password' );
        $response = JP_WP_REST_API_Client::remote_post( $post, $auth, 'http://remotesite.com/wp-json/posts' );
        if ( ! is_wp_error( $response ) {
            //do something with correct response
        }
    }
```

### License

[](#license)

Copyright 2014 Josh Pollock. Licensed under the terms of the GNU General public license version 2. Please share with your neighbor.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ca938daf3f2a666cd32c7bdb6e30714da6fe0e6cd5012fe4864b18afae43fbcd?d=identicon)[Shelob9](/maintainers/Shelob9)

---

Top Contributors

[![Shelob9](https://avatars.githubusercontent.com/u/1994311?v=4)](https://github.com/Shelob9 "Shelob9 (15 commits)")

### Embed Badge

![Health badge](/badges/shelob9-jp-wp-rest-api-client/health.svg)

```
[![Health](https://phpackages.com/badges/shelob9-jp-wp-rest-api-client/health.svg)](https://phpackages.com/packages/shelob9-jp-wp-rest-api-client)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M452](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
