This project provides a Python wrapper for the PullPush Reddit API using FastAPI. It offers a convenient way to interact with the PullPush Reddit API and includes interactive documentation.
- Easy-to-use wrapper for PullPush Reddit API
- Interactive API documentation using Swagger UI
- Endpoints for:
- Searching comments
- Searching submissions
- Getting comment IDs
- Can be used as a standalone server or integrated into other Python applications
- Python 3.7+
- FastAPI
- Uvicorn
- Pydantic
-
Clone this repository:
git clone https://github.com/yourusername/pullpush-api-wrapper.git cd pullpush-api-wrapper
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
To run the API wrapper as a standalone server:
uvicorn pullpushapi:app --reload
The server will start at http://localhost:8000
. You can access the interactive documentation by navigating to http://localhost:8000/docs
in your web browser.
To use the API wrapper in your Python application:
-
Copy the
pullpushapi.py
file to your project directory. -
Import the necessary components in your script:
from main import app, search_comments, search_submissions, get_comment_ids
from fastapi import FastAPI
from fastapi.testclient import TestClient
# Create a test client
client = TestClient(app)
# Now you can use the API functions directly
def get_top_comments(subreddit, limit=10):
response = client.get(f"/reddit/search/comment/?q=&subreddit={subreddit}&size={limit}&sort=desc")
return response.json()
# Example usage
top_comments = get_top_comments("AskReddit")
for comment in top_comments['data']:
print(f"Author: {comment['author']}, Score: {comment['score']}")
This approach allows you to use the API wrapper functions directly in your code, making requests to the real PullPush Reddit API.
The API wrapper provides the following endpoints:
GET /reddit/search/comment/
: Search for commentsGET /reddit/search/submission/
: Search for submissionsGET /reddit/comment/ids/
: Get comment IDs for a submission
Each endpoint corresponds to a function in the pullpushapi.py
file that you can use directly in your code.
Contributions are welcome! Please feel free to submit a Pull Request.
In future releases, we plan to:
- Add asynchronous support for better handling of concurrent requests
This project is not affiliated with or endorsed by Reddit, Inc. It is an unofficial wrapper for the PullPush Reddit API. Use responsibly and in accordance with PullPush's terms of service.