How-to Use The Reddit API in Python

preview_player
Показать описание
Learn how to use the Reddit API in Python, including setup, authorization, and pulling data from subreddits.

Reddit API docs:

🤖 70% Discount on the NLP With Transformers in Python course:

📙 Medium article:

📖 Free link:

Extract from article:

"Reddit is a huge ecosystem brimming with data that is readily available at our very fingertips. As a data-minded person, I wanted to take advantage of this and perform some analysis using this vast repository of open-source data.
Initially, it turned out that getting to grip with Reddit’s API wasn’t as clear-cut as expected — despite being a straightforward process; it can be a little confusing at first.
So, after figuring everything out, I wrote this article — which I hope will help a few of you to get familiar with using the Reddit API in Python. We will cover:
Getting Access
Making Requests
- Reading the Data
- Streaming New Posts
Parameters

Getting Access
First, we need access. Unlike most popular services, the Reddit API was somewhat difficult to figure out initially. There are several steps:
1. Go to App Preferences and click create another app… at the bottom.
2. Fill out the required details, make sure to select script — and click create app.
3. make a note of the personal use script and secret tokens.
4. Request a temporary OAuth token from Reddit. We need our username and password for this.
5. Add headers=headers to every request. The OAuth token will expire after ~2 hours, and a new one will need to be requested.
"

And so on, check it out if you're interested in reading (rather than watching).

🕹️ Free AI-Powered Code Refactoring with Sourcery:
Рекомендации по теме
Комментарии
Автор

Really good tutorial! It has been very useful for my master's thesis. Thanks!

alejandrogouloumis
Автор

I really liked the subtle "to the point" nature of this tutorial.

rexolab
Автор

The single best tutorial anywhere, invaluable information

andrewwakefield
Автор

Thank you for this tutorial, it was very helpful and Yes, I like how he talks.

DeborahRise
Автор

Thanks a lot for this video, James! It really helped me out in getting started on my project.

mimic_here
Автор

Thank you very much for this tutorial! It is very easy to understand and follow.
I am also working on my master thesis and searching ways to scrape more than 1000 posts for my dataset :)

dariyanagashi
Автор

Super video; clear, concise, to the point with working examples. I'm a subscriber!

mufnz
Автор

Thank you so much James! this is so helpful for my master's thesis. lots of love and light to you! <3

prachikarekar
Автор

exactly what I was looking for, thanks a lot for the great tutorial James! :)

pietronickl
Автор

Hi, I don't understand the TOKEN = res.json()["access_token"] ?? seems to be a Keyerror

labinlabs
Автор

this is awesome. no dislikes even 8 months later, impressive!

i got a question. I'm not sure how much you know about the intricacies/policy of how reddit's API can be used. I originally wanted to use it to make a web app and had initialized it as one on my account, but i ran into issues with authorization following your instructions here since you've done a script app. So I made a new app, designating it script this time in registration, and following your instructions worked great. Thing is: I was planning on using Python for the server-side/reddit API interaction and then use something like React purely for the front end (I have more experience in Python so being able to go that route would be great). So I guess what I'm wondering is who is stopping me from designating my app as a script app in the registration but just feeding the info I gather from my script into a React web app?

I guess this all hinges on my assumption that I couldn't use Python and also designate it as a web app, which I could be wrong about.

Hope that's not too confusing, haha. Thanks again for an awesome video.

TheNinjaGingaLife
Автор

I wonder why I get {'error': 'invalid_grant'} when I run this res.json() line

ifeanyindukwe
Автор

Awesome Tutorial! I went back and watched some of your API tutorials playlist as well. Amazing.

theuncommonreddit
Автор

Hey, since Pandas DataFrame.append is deprecated how would you use the concat() function? Simply replacing df.append with pd.concat doesn't work.

Edit: Seems like append still works but will be removed in a future pandas version. It spits out alot of deprecated messages tho.

darkreddust
Автор

Good video. Clear and straight to the point

damianl
Автор

great video, very helpful, my only issue is that it is saying {'error': 'invalid_grant'}, and my grant type is "grant_type": "password", what should I be doing different?

anjaymitalskiff
Автор

Thank you so much, It really helped me a lot!

honsiong
Автор

Gentleman 🎩

You can't imagine the good you've done.
Thanks to you I already understand.
🥇

nicesoundworks
Автор

thanks for video, if i want to collect data based on month or day how to add requests based on time

shivashankarchitumodu
Автор

I appreciate the tutorial! Quick question, would using HasData help to scrape data from multiple subreddits more efficiently?

ChrisGuerrero-ko
welcome to shbcf.ru