package
Official JavaScript library for the WordPress.com REST API.
npm install wpcomGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Latest published Oct 31, 2025
latest
yuliyan
yuliyan.slavchev@gmail.com
a8c
invoices@automattic.com
blowery
ben@blowery.org
ehg_
chris@ehg.sh
sgomes
mail@sgomes.io
tyxla
tyxla@abv.bg
saroshaga
sarosh.aga@automattic.com
nejclovrencic
nejc.lovrencic@gmail.com
sirbrillig
payton@foolord.com
chriszarate
chris@zarate.org
robersongomes
robersonccgomes@gmail.com
johngodley
johng75@gmail.com
jeherve
jeremy@tagada.hu
daledupreez-a8c
dale@automattic.com
t2dw4t
todd.wright@automattic.com
luismulinari
luis.mulinari@gmail.com
andrea-sdl
andrea.grassi@automattic.com
elazzabi
elazzabi.ahmed@gmail.com
fmfernandes
fernando.fernandes@automattic.com
sirreal
jon.surrell@gmail.com
wwa
volodymyr@wildwolf.name
chihsuan
chihsuan.tw@gmail.com
manzoorwanijk
manzoorwani.jk@gmail.com
msurdi-a8c
matias.emanuel.surdi@automattic.com
newspack-npm
newspack@a8c.com
dsmartg
derek.smart@automattic.com
kthai15
kavin.keratikasama@automattic.com
bgrgicak
berislav.grgicak@gmail.com
robertsreberski_a8c
robert.sreberski@automattic.com
artpi
artur.piszek@gmail.com
gmjuhasz
jugergo@gmail.com
borkweb
borkweb@gmail.com
kat3samsin
kat3samsin@gmail.com
brunobasto
b.basto@gmail.com
dhenridev
douglas.henri@automattic.com
mrmurphy
m@mrmurphy.dev
wpvip-bot
platform+npm@wpvip.com
etobiesen
e.tobiesen@gmail.com
alshakero
omar@omaralshaker.com
arthur791004
arthur791004@gmail.com
dilirity
peter.petrov89@gmail.com
anandnalya
anand.nalya@gmail.com
arcangelinis
anthony.arcangelini@gmail.com
retrofox
rdsuarez@gmail.com
iamchughmayank
mayank.chugh@automattic.com
simison
mikael@ihminen.org
fredrikekelund
fredrik@fredrik.computer
griffithchen
griffith.chen@automattic.com
mdawaffe
michael.d.adams@gmail.com
jboland8
josh.boland@automattic.com
chriskmnds
chriskmnds@gmail.com
oandregal
ola@oandre.gal
galatanovidiu
galatanovidiu@gmail.com
kangzj
kangzjnet@gmail.com
_mirka_
lena@jaguchi.com
aduth
andrew@andrewduthie.com
ebuccelli
emanuele.buccelli@automattic.com
nylen
jnylen@gmail.com
timmyc
timmydcrawford@gmail.com
dmsnell
dennis.snell@automattic.com
samouri
jzfisgreat@gmail.com
Official JavaScript library for the WordPress.com REST API. Compatible with Node.js and web browsers.
Introduce the wpcom dependency into your package.json ...
yarn add wpcom... and then initialize it with your API token (optional).
// Edit a post on a site
const wpcomFactory = require( 'wpcom' );
const wpcomXhrRequest = require( 'wpcom-xhr-request' );
const wpcom = wpcomFactory( '<your-token>', wpcomXhrRequest );
wpcom
.site( 'your-blog.wordpress.com' )
.postsList( { number: 8 } )
.then( ( list ) => {
/*...*/
} )
.catch( ( error ) => {
/*...*/
} );Introduce the wpcom dependency into your package.json ...
npm install --save wpcom... and then initialize it with your API token (optional).
// Edit a post on a site
import wpcomFactory from 'wpcom';
import wpcomXhrRequest from 'wpcom-xhr-request';
const wpcom = wpcomFactory( '<your-token>', wpcomXhrRequest );
wpcom
.site( 'your-blog.wordpress.com' )
.postsList( { number: 8 } )
.then( ( list ) => {
/*...*/
} )
.catch( ( error ) => {
/*...*/
} );Not all requests require a REST API token. For example, listing posts on a public site is something anyone can do.
If you do need a token, here are some links that will help you generate one:
wpcom-oauth-cors:
a client-side WordPress.com OAuth2 library using CORSwpcom-oauth:
a server-side ( Node.js ) WordPress.com OAuth2 librarywpcom-oauth
is probably the easiest way.// Edit a post on a site
import wpcomFactory from 'wpcom';
import wpcomXhrRequest from 'wpcom-xhr-request';
const wpcom = wpcomFactory( '<your-token>', wpcomXhrRequest );
const blog = wpcom.site( 'your-blog.wordpress.com' );
blog
.post( { slug: 'a-post-slug' } )
.update( data )
.then( ( res ) => {
/*...*/
} )
.catch( ( err ) => {
/*...*/
} );You can omit the API token for operations that don't require permissions:
// List the last 8 posts on a site
import wpcomFactory from 'wpcom';
import wpcomXhrRequest from 'wpcom-xhr-request';
const wpcom = wpcomFactory( wpcomXhrRequest );
const blog = wpcom.site( 'your-blog.wordpress.com' );
blog
.postsList( { number: 8 } )
.then( ( list ) => {
/*...*/
} )
.catch( ( error ) => {
/*...*/
} );More pre-made examples are in the examples/ directory.
The token and site vars must be given to testing scripts either using
TOKEN and SITE environment vars respectively or through of a
config.json file into test/ folder like bellow:
{
"site": "<site-id>",
"token": "<token>"
}Run tests:
$ make test-allAlso tests can be filtered using make test FILTER=<filter>:
$ make test FILTER=wpcom.site.postMIT – Copyright 2014 Automattic
Estimated unpacked size across 27 packages.
4.3 MB
Includes dependencies.
^4.4.1
4.4.3
2.3.2
4.3.1
^7.27.1
8.1.2