Registry / http-networking / redditwarp

redditwarp

JSON →
library1.3.0pypypiunverified

redditwarp is a modern, feature-rich Python library designed for interacting with the Reddit API. It provides both synchronous and asynchronous interfaces, robust error handling, and comprehensive model definitions for Reddit objects. Currently at version 1.3.0, the library maintains an active development cycle, releasing updates as needed to track API changes or introduce new features.

pip install redditwarp
INSTALL
IMPORT
SIG · REDDITWARP
R
redditwarp
http-networkingpythonv1.3.0
Install
2.0s avg
Import
Disk
22MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 24.2MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.0s · import 0.000s · 25MB
22MB installed
● package 22MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Client
from redditwarp import Client
from redditwarp import Client

This quickstart demonstrates how to authenticate with Reddit using the password login flow and fetch the top posts from a subreddit. It emphasizes using environment variables for credentials and includes basic error handling for common API issues like rate limits. Remember to replace placeholder values or set environment variables.

import os from redditwarp import Client, Auth from redditwarp.errors import APIError, RateLimitError # It's highly recommended to use environment variables for sensitive credentials. # Set these in your environment: REDDIT_USERNAME, REDDIT_PASSWORD, # REDDIT_CLIENT_ID, REDDIT_CLIENT_SECRET username = os.environ.get('REDDIT_USERNAME', 'your_username') password = os.environ.get('REDDIT_PASSWORD', 'your_password') client_id = os.environ.get('REDDIT_CLIENT_ID', 'your_client_id') client_secret = os.environ.get('REDDIT_CLIENT_SECRET', 'your_client_secret') # For password login flow, a user agent string is also good practice user_agent = 'my_script_name_v1.0 (by /u/your_reddit_username)' try: # Authenticate and create a client instance auth = Auth.password_login( username=username, password=password, client_id=client_id, client_secret=client_secret, user_agent=user_agent ) client = Client(auth) # Fetch the top 5 posts from r/python print('Fetching top 5 posts from r/python...') subreddit_posts = client.p.subreddit.get_top(subreddit='python', limit=5) for post in subreddit_posts: print(f"- {post.title} (Score: {post.score})") except APIError as e: print(f"Reddit API Error: {e.code} - {e.message}") except RateLimitError: print("Rate limit exceeded. Please wait and try again.") except Exception as e: print(f"An unexpected error occurred: {e}")
Debug
Known issues
breakingMajor API changes occurred between `redditwarp` 0.x.x and 1.x.x. If you are migrating from an older 0.x.x version, expect significant changes in import paths, class names (e.g., `AsyncClient` vs `Client`), and method signatures.
fix
Refer to the official `redditwarp` documentation for the 1.x.x series to understand the new API structure. Re-evaluate your import statements and method calls.
affects: 0.x.x to 1.x.x
gotchaIncorrect or missing authentication credentials will lead to `redditwarp.errors.InvalidCredentials` or `redditwarp.errors.APIError` (e.g., HTTP 401 Unauthorized).
fix
Double-check your `REDDIT_USERNAME`, `REDDIT_PASSWORD`, `REDDIT_CLIENT_ID`, and `REDDIT_CLIENT_SECRET`. Ensure the client ID and secret are for the correct Reddit application type (script, web app, etc.) and that the user account exists and has the correct permissions.
affects: All versions
gotchaReddit has strict rate limits. Making too many requests in a short period will result in `redditwarp.errors.RateLimitError` (HTTP 429 Too Many Requests).
fix
Implement proper rate limiting and exponential backoff in your application. The `redditwarp` library doesn't automatically handle backoff, so you must implement it yourself or use `time.sleep()` when catching `RateLimitError`.
affects: All versions
gotchaAttempting to access attributes or methods on a Reddit object (e.g., a `Post` or `Comment`) that do not exist or have not been loaded yet can result in an `AttributeError`.
fix
Consult the `redditwarp` documentation or use `dir(obj)` to inspect available attributes. Some attributes might only be present after specific API calls (e.g., `client.p.comment.get_comment(comment_id)` might fetch more details than a comment obtained from `get_top()`).
affects: All versions
gotcha`redditwarp` supports both synchronous and asynchronous operations. Mixing them without proper `asyncio` context can lead to runtime errors or deadlocks.
fix
If using `Client` (synchronous), stick to synchronous methods. If using `AsyncClient` (asynchronous), ensure your code is running within an `asyncio` event loop and `await` all asynchronous calls.
affects: All versions
Upgrade
Version history
1.3.0latest on PyPI · released Jul 1, 2024
Audit
Dependencies
pythonrequiredRequires Python 3.8 or newer, but less than 4.0.
Agent activity
23 hits · last 30 days
node
22
OpenAI (training)
1
Resources
redditwarp — pip install redditwarp · libregistry