Use the RedditAPI to get more freelance customers [Part 1]

Nico Curti
4 min readMar 6, 2021

After months of freelancing, I realized most of my work came from word of mouth, and subreddits that were active enough to use as an outreach method (slavelabour, forhire, designjobs, jobit, and a few more).

To the moon!

The problem with this method is that when browsing those subreddits, you often have to either keep refreshing the page when you’re looking for new gigs on each URL or build a custom URL that shows you all of them. Still, having to open the browser, type in the subreddit, refreshing and then clicking to see what’s each job about is kind of troublesome. This is why I built a Reddit bot that takes each gig proposal submission on those subreddits and then sends me a message on discord in real-time. I’ll show you how I did it!

Before Starting

First, we need to get access to the RedditAPI. To do this, go to this link and on the bottom of the page, click “create another app” and fill in the details.

Creating New Application

Make sure to select script, since this will be the kind of application we will be running. You don’t need to fill in the about URL either, but that’s a nice to have.

After filling the details, submit and you should see something like the following, make sure to copy the secret and personal use script.

Appliation Created

Lastly, we have to decide on what language to code our bot. In this case, I choose Python because of PRAW (Python Reddit API Wrapper), which as its name implies is just a wrapper for the API that makes it easier to manipulate the data that comes from their servers. PRAW supports Python 3.6+. The recommended way to install PRAW is via pip.

In your directory, run:

pip install --upgrade praw

Kickstarting the bot

Now it’s the time to get our hands dirty. Create a new .py file and copy the following:

import prawreddit = praw.Reddit(
client_id='g4TmsKeGFgZBRQ', client_secret='54rkFSzoFDHIWUuNVXCagSdAqcG4Pg',
user_agent='newBot')

This will log us in to use the API. As you may have noticed, client_id is the person use script tag, user_agent is our app name, and client_secret is…well, our secret.

So great! We have accessed the interface and now we can start telling her what to do.

Pulling job offers from the API

First of all, let’s analyze the documentation. PRAW gives us the Reddit instance which includes a lot of classes, but we will be focusing on .subreddit, which can make us point to one or several subreddits on the page. To do this, add the following snippet to your code:

subreddit = reddit.subreddit('slavelabour+designjobs+hireawriter+jobbit')new_posts = subreddit.new(limit=10)

Now you can guess what this does. It pulls all the data from those subreddits, and pulls the first 10 sorted by new. You can check this by adding a print(new_posts) to confirm everything is running smoothly (recommended).

subreddit = reddit.subreddit('slavelabour+designjobs+hireawriter+jobbit')new_posts = subreddit.new(limit=10)

Note: saw how I selected multiple subreddits? Just add a “+” with no spaces in between.

Great, let's go onto the next step. We will be using a for statement to check in real-time (subreddit.stream) the submissions made into those subreddits, which satisfy a certain requirement (in this case, they must have “hiring” or “task” in their title) and then print it into the console. The code that comes afterward will help filter by subreddit and help us when we do our discord integration, or with any other webhook you may want to use to get notified (telegram, whatsapp, etc).

for submission in subreddit.stream.submissions():
questions = [“hiring”, “task”]
normalized_title = submission.title.lower()
for question_phrase in questions:
if question_phrase in normalized_title:
print(submission.title)
if question_phrase in questions[0]:
if submission.subreddit == “designjobs”:
#Do something...
elif question_phrase in questions[1]:
if submission.subreddit == “slavelabour”:
#Do something...

Now lets try it out!

python3 forhireScraper.py

You should see something like this (without the heroku stuff):

Example of BOT running

Conclusion

RedditAPI is such an useful tool for many times of businesses, and freelancing is not an exception. Main problem is that so far the only wrapper I found out about what PRAW (let me know in the comments if you know any good JS integration!) and it might be a problem when integrating into your existing platforms.

For the part 2, wwe will be covering the discord webhooks integrations so you can get the notifications properly, and have something like the following:

Discord Integration Example

With this, you will be able to access the gigs with just a click as soon as they appear, which helps a lot to get more customers. If you have any questions, feel free to contact me, thanks for reading and stay tuned for the part 2!

--

--

Nico Curti

I write about what I learn and what im grateful for in life.