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-connect

v0.2.3

Published

Wordpress REST API module for nodejs

Downloads

28

Readme

wp-connect

Wordpress connect module

Layer to get resources from WordPress using the [developer.wordpress.com/docs/api/](REST API).

API

WPCONN();

Create a new instance of WPCONN. If you wanna a way to get the access token then can use WPOAuth npm module.

var WPCONN = require('wp-connect');
var wpconn = WPCONN();

WPCONN#me();

var WPCONN = require('wp-connect');
var wpconn = new WPCONN('<your token>');

// get the user info
wpconn.me(function(err, user){
  // user info related with the given access token
});

WPCONN#site.id();

Set site identifier

WPCONN#site.info(params, fn);

Get the site information

var WPCONN = require('wp-connect');
var wpconn = new WPCONN('<your token here>');

// get site info
wpconn.site.id('blog.wordpress.com');
wpconn.site.info(function(err, site){
  // site data object
});

WPCONN#site.posts(params, fn);

Get the site posts

wpconn.site.id('blog.wordpress.com');
wpconn.site.posts({ number: 10 }, function(err, posts){
  // posts array
});

WPCONN.site.post.get(id, fn);

Get post site data

// get post data
wpconn.site.post.get(435, params, function(err, post){
  // post data object
});

WPCONN.site.post.getBySlug(slug, params, fn);

Get post site data by the given slug

// get post data
wpconn.site.post.getBySlug('we-are-the-loosers', function(err, post){
  // post data object
});

WPCONN.site.post.add(data, fn);

Add a new post

// post data
var data = {
  "title": "A new post",
  "slug": "a-new-post",
  "content": "<div>The content of the new post</div>"
};

wpconn.site.post.add(data, function(err, new_post){
  // object data of the new post already added
});

WPCONN.site.post.edit(id, data, fn);

Edit a post

wpconn.site.post.edit(321, { title: "new Title !!!" }, function(err, edit_post){
  // the title in edit_post has changed
});

Example

Into example/ folder download the npm dependencies:

$ npm install

... and then run the application

$ node index.js

Test

Create data.json file into test/ folder to can run the tests. You can copy or rename the test/data_example.json file.

{
  "client_id": "<your client_id here>",
  "client_secret": "<your client_secret here>",
  "token": "<your token app here>",

  "public_site": "<a public blog here>",

  "private_site": "<a private blog here>",
  "private_site_id": "<the ID of the private blog>",

  "new_post_data": {
    "title": "New testing post",
    "content": "<div style=\"color: red;\">The content of the new testing post</div>"
  }
}

... and then

$ make

License

MIT – Copyright 2014 Automattic