npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wp-api-cli

v0.4.1

Published

CLI for WordPress.org REST API v2

Downloads

16

Readme

CLI for WordPress.org REST API v2

Build status of master branch Code coverage of master branch Code climate of master branch Dependency status of master branch

CLI to help test-drive the WordPress.org REST API.

Installing

  1. WP-API v2 depends on the latest WordPress.org, so download it from Subversion.
  2. Install WP-API plugin from Git and activate it.
    • There are some fixes that I made concerning file uploads and missing metadata, consider using the branch 'tnegri' of my fork if the fixes are not already merged.
  3. Install Node.js.
  4. Install the latest published version of this CLI on your system: npm install --global wp-api-cli.
  5. Update CLI from API description: wp-api-cli update https://yoursite.com.

Authenticating with OAuth 1.0

  1. Install WP-API/OAuth1 from Git to support OAuth authentication, activate it.

  2. Install WP-CLI to generate OAuth keys.

  3. Go to your WordPress installation folder and create a new consumer key and secret for this CLI:

    wp oauth1 add
  4. Authenticate this CLI:

    wp-api-cli authenticate            \
        --oauth_key=CONSUMER_KEY       \
        --oauth_secret=CONSUMER_SECRET
  5. It will ask for an authorization token. Follow the steps on the browser, copy the authorization token and paste it on console.

  6. It will write the OAuth tokens to a file for further use -- this is a sensitive file, make sure to protect it!

  7. When you execute a command, the CLI will look for the file to grab the OAuth tokens, you may set a different file to use with the option --oauth_file.

  8. If you want to remove the OAuth tokens from the file system:

    wp-api-cli logout

Authenticating with HTTP Basic Auth

  1. Install WP-API/Basic-Auth from Git to support HTTP Basic Authentication, activate it.
  2. Use options --http_user and --http_pass with every request you make.

Commands

After installing the CLI, you need to update its definition:

wp-api-cli update https://example.com

After updating, ask for help to see everything available in your site:

wp-api-cli --help

Examples

Show all posts

$ wp-api-cli posts --table --project id,date,title

----------------------------------------------
 | id | date                | title         |
----------------------------------------------
 | 6  | 2015-08-22T20:27:32 | Hello, WP-API |
 | 1  | 2015-08-18T23:09:35 | Hello world!  |
----------------------------------------------

Show a specific post

$ wp-api-cli posts --yaml --id 6 --project id,date,title,content,comment_status

id: 6
date: '2015-08-22T20:27:32'
title:
  rendered: 'Hello, WP-API'
content:
  rendered: |
    <p>Hello, dear WP-API!</p>
comment_status: open

See docs/COMMANDS.md for a full documentation on commands.

Developers

This project is structured as follows:

  1. index.js is the entry point, it executes the main function defined in lib/wp-api-cli.js.
  2. lib/wp-api-cli.js wires everything up.
  3. lib/wp-api.js contains the class that communicates with the REST APIs.
  4. lib/modules.js loads all modules. A module is an object that provides the functionalities of the CLI.
  5. Files in lib/utils are utility functions to make coding easier.

If you want to create a new set of commands, drop a file in lib/modules and load it in modules.js. Full explanation in docs/MODULES.md.

Useful Links

Related Issues and Pull Requests

Issues

Fixes

Features

Project Overview

Overview image of project files