@miso.ai/server-wordpress
v0.6.6
Published
Miso WordPress API data tools
Readme
Miso Node.js SDK (WordPress)
Setup
Install Node.js.
Install the package locally:
npm i @miso.ai/server-wordpressOr, install the package globally:
npm i -g @miso.ai/server-wordpressOr, use npx to run the commands, which will guide the package installation.
- Initialize a project profile
miso-wp init "b2c-contenthub.com"which will generate a file wordpress.json in the current directory, with content like this:
{
"site": "b2c-contenthub.com",
"utcOffset": 0
}Usage
Help message
miso-wp --helpGet
This command emits infinite stream of posts from the WordPress site.
miso-wp postsYou can specify a limit of posts to emit, or pipe to a head:
miso-wp posts -n 10 # this will be more efficient
miso-wp posts | head -10Get, by ids
Get posts by ids:
miso-wp posts --ids 10001
miso-wp posts --ids 10001,10002Get, with a time range
You can specify a time range:
# The range is always inclusive
miso-wp posts --after 2025-01-01 --before 2025-01-31
miso-wp posts -a 2025-01-01 -b 2025-01-31
miso-wp posts -a 2025-01 -b 2025-02
miso-wp posts -a 2024 -b 2025
miso-wp posts --date 2025-01-15
miso-wp posts -d 2025-01-15
miso-wp posts -d 2025-01
miso-wp posts -d 2025Get posts that are either created or updated in a duration:
miso-wp posts -u 3h # in last 3 hours
miso-wp posts -u 4d # in last 4 days
miso-wp posts -u 5w # in last 5 weeksCount the items
All filters above can be applied:
miso-wp posts -c
miso-wp posts -d 2025 -c
miso-wp posts -d 2025-01 -cGet, with linked resources resolved
There are many linked resources in a post, such as author, categories, tags, etc. In the default mode, those resources are represented by their numberic ids. You can resolve them by:
miso-wp posts --resolveThe resolved content will be put in a _linked field under the post object.
Get, restricting fields retrieved
miso-wp posts --fields id,titleGet, with extra parameters
miso-wp posts --param "order=asc"See WordPress JSON API reference.
Get, with records transformed
Tranform the posts to Miso product records:
miso-wp posts --transformYou can customize the transformation:
miso-wp posts --transform 'path-to/your-transform.js'export default function(post, { defaultTransform }) {
const record = defaultTransform(post);
// do something with the record
return record;
}List all types of entities
miso-wp taxonomiesGetting other types of items
Simply replace posts with other types of items. The term should match the rest_base property in the response of the taxonomies command.
miso-wp categories