{"library":"redditwarp","title":"redditwarp - Reddit API Wrapper","description":"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.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install redditwarp"],"cli":null},"imports":["from redditwarp import Client","from redditwarp import Auth","from redditwarp import errors"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom redditwarp import Client, Auth\nfrom redditwarp.errors import APIError, RateLimitError\n\n# It's highly recommended to use environment variables for sensitive credentials.\n# Set these in your environment: REDDIT_USERNAME, REDDIT_PASSWORD, \n# REDDIT_CLIENT_ID, REDDIT_CLIENT_SECRET\nusername = os.environ.get('REDDIT_USERNAME', 'your_username')\npassword = os.environ.get('REDDIT_PASSWORD', 'your_password')\nclient_id = os.environ.get('REDDIT_CLIENT_ID', 'your_client_id')\nclient_secret = os.environ.get('REDDIT_CLIENT_SECRET', 'your_client_secret')\n\n# For password login flow, a user agent string is also good practice\nuser_agent = 'my_script_name_v1.0 (by /u/your_reddit_username)'\n\ntry:\n    # Authenticate and create a client instance\n    auth = Auth.password_login(\n        username=username,\n        password=password,\n        client_id=client_id,\n        client_secret=client_secret,\n        user_agent=user_agent\n    )\n    client = Client(auth)\n\n    # Fetch the top 5 posts from r/python\n    print('Fetching top 5 posts from r/python...')\n    subreddit_posts = client.p.subreddit.get_top(subreddit='python', limit=5)\n\n    for post in subreddit_posts:\n        print(f\"- {post.title} (Score: {post.score})\")\n\nexcept APIError as e:\n    print(f\"Reddit API Error: {e.code} - {e.message}\")\nexcept RateLimitError:\n    print(\"Rate limit exceeded. Please wait and try again.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}