Posted by & filed under Code Tips.

This came about from needing a way to automatically post to a Pinterest board.

Unlike most social sites, Pinterest doesn’t have a public API to handle auto posting so it took a bit of finagling and a Node.js package called Pin-It Node which does most of the heavy lifting.

var PinIt = require('pin-it-node');
var pinIt = new PinIt({
    username: 'your_pinterest_username',
    password: 'your_pinterest_password'
var settings = {
    boardId: 'Numeric_board_id',
    url: process.argv[2],
    description: process.argv[3],
    media: process.argv[4]
}; , function(err, pinObj) {
    if (err) {

Once the script is in place, you’ll run it like this.

$ node pin-it.js "Pin Title" "This is a description for the pin" "http://example/image.jpg"

You will need the numeric ID for the board you’re posting to. You can either dig through the HTML source to find it or use a tool that I kicked up in an afternoon because I didn’t want to dig through the HTML more than once.

And originally I was looking for a PHP script that would do the same. But since I wasn’t able to find anything that worked, I wound up just running shell_exec to call this script from the PHP file.

4 Responses to “Automatically post to Pinterest”

  1. Palabre

    I think this method doesn’t work ?

    ! ERROR: _pinIt
    [Error: Unknown error occurred while pinning]”

    Any solutions ?

  2. Ryan

    Not sure. Just went and checked, and the board that I’m using it on is still getting updated.

    Did you get the correct board id and include your username and password in the script?

  3. Ryan

    Looks like the 400 in the error message you’re getting is the HTTP status code that Pinterest is returning. 400 is a bad request, which means something is malformed.

  4. Ryan

    Not sure why, but this just stopped working. Don’t know if Pinterest changed something or what happened.

    Instead of kicking I went out looking for a PHP solution since it was running as a WordPress action anyway. Turns out that there are several now, and there weren’t any when I first needed this. So I switched over the PHP and have let it run.


Leave a Reply

Your email address will not be published. Required fields are marked *