With 300M active users every month, Pinterest is a potential traffic source to be reckoned with. Often seen as a goldmine for only a specific amount of niches, long gone are the days where Pinterest was only synonym with parenting and cooking bloggers. Nowadays, Pinterest’s community expands far beyond those industries and so whatever niche you are in, it is worth investing some of your time into developing a presence on this social network.
Now, I can relate with the fact we are all full of ideas and will but if there’s one commodity we are all lacking in this day and age, it is, without a doubt, time. And this is why I came up with this article. If there is something I want to do regularly and can automate, you can be sure I will be looking for a way to do so. Eventually, this is what this article is for here.
It does seem so far like Pinterest is not investigating too much on users automating their interactions with their platform and as such, it is in my opinion worth spending some time in letting a considerable amount of the recommended tasks to do on Pinterest on “auto-pilot”.
By compiling tips and tricks for Pinterest users to expand their reach, I came up with multiple Python scripts of automated workflows that follow these recommended guidelines in order for you to easily convert these scripts into apps and schedule them based on your own instincts and proven formula.
The first part of this article is going to be about how to automate common tasks. The second part of this post will be excerpts of workflow scripts ready to be downloaded and used on your own machines to automate your daily interactions on the platform.
Anyway, let’s get into it already.
Setting up the Pinterest Python Library
Fortunately for us, there is a very complete and easy to use Python 3 library for interacting with our Pinterest account. It’s fast, complete and although the documentation is a bit confusing and could benefit from a rewrite, I found and experimented with the most important endpoints for you guys so you don’t have to comb through the Github project page on your own.
The library, adapted and maintained by Borislav Stoilov, is available at this address if you want to dig alone: https://github.com/bstoilov/py3-pinterest
Install the Pinterest python library with the following pip command or you can install it from Github from the link above.
pip install py3-pinterest
Once this is installed, I can start running through the commands we will be using to build our own Pinterest robot in Python.
Login on Pinterest with Python
The first obvious thing we want to do with our program is signing in the account we want to automate. To do so, just follow these simple lines of code:
Your email and your password are two things I trust you know where to find. Your username is simply the name that shows when you visit your own profile. For instance, in the case of this website’s Pinterest account, our username is “martechwithme” because my profile is available at pinterest.com/martechwithme/
Once you are done inputting these information, you can now use the “pinterest” class to use the full power of this library.
Create a Pinterest Pin with Python
There are two ways to create a pin on Pinterest. you can either browse through your computer’s files and save a local image as a pin or you can save images from the internet as a pin.
This library can do both and has a different function for each one of these actions.
In order to save a pin from an image hosted on the internet, you are going to need to use the function “pin” shown below:
I will go over the board_id argument below as it’s easier to explain the last four arguments.
“image_url” is the URL of the image that you are looking to pin. If you’re not sure how to get the exact address of an image, you can right-click on it and choose “Copy Image Address” if you are on Chrome:
The “description” argument is a string argument that represents the description that is going to be associated with the pin. This can be useful to include the keywords you are trying to get this pin ranked for. The description of your pin should not exceed 500 characters.
The “title” argument is, simply put, the title of your pin. This has to stay under 100 characters. Like the description, the title can be used as an opportunity to stuff some of the keywords you are trying to rank for. Just keep it clean, detailed but concise.
Finally, the “link” argument is the address you want to refer the people interest in this specific pin.
Now, we need to specify a board_id. A board_id is a string of numbers that is the unique identifier of every board that has ever been created on Pinterest.
This library has a function to get the boards and their details from any user on the platform. In order to get the name of every one of your boards and the ID associated with them, I wrote this simple function. Just run it with your username as an argument and it should return you a dictionary with every board and their ID.
Once you have the ID of the board you’re interested in saving the pin in that you started to create earlier, just input it under the “board_id” argument as a string, run the function and you should see your new pin appear.
In order to upload an image from your computer and pin it in one of your boards, the function we are going to be using is named “upload_pin” and works as shown:
Simple as that. The only argument that varies is the “image_url” now named “image_path” which is where your image is stored. Bear in mind that Pinterest only accepts .jpg and .png files and that your file should not be larger than 32MB.
How to delete Pinterest Pins in Boards with Python
Let’s say you want to do some cleanup among your Pinterest boards/pins. For this kind of use, this library has the perfect function for it. Called “delete_pin”, it works as shown below:
If you are interested in removing all of the pins you made on a specific board but keep its followers and members, you can use the function I wrote below:
Just feed the Board ID as an argument of the board you are interested in cleaning and this function is going to clean out the whole board out of all of its pins.
Automated Workflow #1: Go through Boards, look for Pins to Repin and Repins based on Board Title
This workflow is a very simple automated process that works in multiple steps as described in this list:
- Login to Pinterest
- Make a list of the User’s Boards
- Go through the boards one by one and
- Search for the Board’s Name and search for this name in Pinterest’s search box
- Randomly pick one of the results to repin
- Repin the pin
- Move to the next board until the last one
In order to not burn out the number of requests one can do per minute, I introduced a random timer between requests.
Here is the code. The purpose of this is to be saved as a .py file and converted into a schedulable application.
If you’re interested in learning more about how to convert your Python scripts into an application and schedule it to run at regulatory intervals, I wrote these two explanatory articles:
This is what I came up with so far. If you are looking to automate specific cases for your own Pinterest actions, I would love for you to get in touch with me and share those ideas. That would allow me to update this article on top of offering you a solution.
I hope you found this useful. If you have any question or comments, I invite you to reach out to me by email or in the comments section down below so I can answer you as fast as I can 🙂