Chuck Grimmett

Microblog post

Mark D and I love jq for quick json processing via the command line.

One utility script we use often is generating a list of all sites connected to our account from the WordPress.com API:

curl -sH 'Accept: application/json' -H 'Authorization: Bearer [REDACTED]' https://public-api.wordpress.com/rest/v1.1/me/sites | jq -r '.sites[] | .URL' > sites.txt

A couple helpful tips we’ve found:

  • use -r (raw) to remove quotes around the data.
  • Use | @sh for transforming arrays into space separated strings

We also combine it with sqlite-utils to stuff certain subsets of json data we get back from APIs (like Zoho) into a sqlite database for analysis in Metabase.



Comments

Leave a Reply

Webmentions

If you've written a response on your own site, you can enter that post's URL to reply with a Webmention.

The only requirement for your mention to be recognized is a link to this post in your post's content. You can update or delete your post and then re-submit the URL in the form to update or remove your response from this page.

Learn more about Webmentions.