Skip to content
This repository has been archived by the owner. It is now read-only.
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Interact with a WordPress site remotely using WP API and WP-CLI.


On the server:

On the client:

  • WP-CLI
  • This repository!
  • Composer (you'll already have this if you have WP-CLI)

Setting Up

Step 0: Downloading

After you've cloned this repository down, you'll need to make sure you install the dependencies:

$ composer install

(If you're using WP-CLI's copy of Composer, use ~/.wp-cli/composer.phar install instead.)

Step 1: Creating a Consumer

Once you have WP API and the OAuth server plugins activated on your server, you'll need to create a "consumer". This is an identifier for the application, and includes a "key" and "secret", both needed to link to your site.

To create the consumer, run the following on your server:

$ wp oauth1 add

ID: 4
Key: sDc51JgH2mFu
Secret: LnUdIsyhPFnURkatekRIAUfYV7nmP4iF3AVxkS5PRHPXxgOW

Note the key and secret returned here. You'll need those in a moment.

Step 2: Linking the Client

Time to link the client to your site. These should always be run from the same directory this readme is in, unless you have the client installed globally.

Replace with the site you're running WP API on. You can specify any URL on your site and the API will be automatically discovered from there. However, you should try and keep this URL the same across all commands, as it will help WP CLI run faster.

To link the client, run the following on the client:

$ wp --require=client.php api oauth1 connect --key=sDc51JgH2mFu --secret=LnUdIsyhPFnURkatekRIAUfYV7nmP4iF3AVxkS5PRHPXxgOW
Open in your browser:
Enter the verification code:

Open this up in your browser, log in if needed, and authorize the account. You'll then see an authorization code: Authorization code

Copy and paste this into your terminal, hit enter and you're good to go:

$ wp --require=client.php api oauth1 connect --key=sDc51JgH2mFu --secret=LnUdIsyhPFnURkatekRIAUfYV7nmP4iF3AVxkS5PRHPXxgOW
Open in your browser:
Enter the verification code: BEBMyxKTEKOXCsNqS9Q0r8pC
Key: kJPiCdhE8kIcIUCFGta1oNLE
Secret: FzcSbdsIC0Amuw2ZQuaAQCxVUxQ9X5qytWBbXQF7QzUADnr0

Your client is now linked to your site and account! The key and secret will be displayed if you need them, however WP-CLI will remember your credentials automatically.

Step 3: Doing the Fun Stuff

Time to mess around with the CLI commands! All commands start with wp api, and take the site you want to interact with as the first parameter.

$ wp --require=client.php api user list
| ID | username | name     | email             | roles         |
| 1  | admin    | admin    | | administrator |
| 2  | testuser | testuser |  | subscriber    |

$ wp --require=client.php api user get-current
| ID | username | name  | email             | roles         |
| 1  | admin    | admin | | administrator |


No description, website, or topics provided.



No releases published


No packages published