How-to Use The Reddit API in Python
James Briggs
Learn how to use the Reddit API in Python, including setup, authorization, and pulling data from subreddits.
Reddit API docs: https://www.reddit.com/dev/api/
🤖 70% Discount on the NLP With Transformers in Python course: https://bit.ly/3DFvvY5
đź“™ Medium article: https://towardsdatascience.com/how-to-use-the-reddit-api-in-python-5e05ddfd1e5c
đź“– Free link: https://towardsdatascience.com/how-to-use-the-reddit-api-in-python-5e05ddfd1e5c?sk=0295f297c1365bee7cc7a32bdff21b61
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:
- Go to App Preferences and click create another app… at the bottom.
- Fill out the required details, make sure to select script — and click create app.
- make a note of the personal use script and secret tokens.
- Request a temporary OAuth token from Reddit. We need our username and password for this.
- 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: https://sourcery.ai/?utm_source=YouTub&utm_campaign=JBriggs&utm_medium=aff ... https://www.youtube.com/watch?v=FdjVoOf9HN4
129295052 Bytes