HW09: Working with APIs due Mon 27 Mar 12:00

This assignment provides practice in working with a variety of APIs from the


In this assignment you will work with at least two separate APIs. First, choose an API that provides fun/interesting information and experiment with it in your browser. There are many sites that list available APIs such as: https://medium.com/@vicbergquist/18-fun-apis-for-your-next-project-8008841c7be9

The goal is to create a script that will grab some random fact/entry/info/something and automatically create a blog post from it. Then it will use the Wordpress API to generate the blog post.

When completed the script should be placed in the /etc/cron.daily directory so it will generate a new blog post each day.

Some Details

To create a new post in the Wordpress API from the command-line you'll need to establish an authentication method. Wordpress' out-of-the-box authentication is pretty limited so I ended up using miniOrange Wordpress REST API Authentication plugin.

I used JWT Authentication and entered a random client secret string. I copied the provided curl command to generate a new token. The resulting token is good for 1 hour (so the command to generate a new token will need to appear in the script—eventually). The generated token is used for subsequent API calls. For example, to see a list of posts you would do this:

curl -H "Authorization: Bearer the-long-token" \

These are some details to keep in mind as you work on this.

  1. The official Wordpress REST API Handbook is here:


  2. You should (manually) create a category which will apply to all blog posts generated by your script.
  3. Also, be sure to specify an author, a title, and content for all blog posts.
  4. To generate a POST request using curl you can do something like this:

    curl -H "authentication-info" -d "param1=x&param2=y" -X POST url

Turning in Your Work

Submit your work in Canvas by renaming your script to have a .txt extension and then uploading it to the homework assignment. Also, make sure your script is working in /etc/cron.daily.