{"id":4173,"library":"prawcore","title":"Prawcore","description":"Prawcore is a low-level communication layer designed to be used by PRAW (Python Reddit API Wrapper) version 4 and above. It handles the underlying HTTP requests and authentication mechanisms for interacting with the Reddit API, abstracting away the complexities of direct API communication. The library is actively maintained, currently at version 3.0.2, with releases typically tied to PRAW updates or significant changes in the Reddit API.","status":"active","version":"3.0.2","language":"en","source_language":"en","source_url":"https://github.com/praw-dev/prawcore","tags":["reddit","api-wrapper","http-client","authentication","low-level"],"install":[{"cmd":"pip install prawcore","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required Python version as specified by prawcore's metadata.","package":"python","optional":false}],"imports":[{"symbol":"prawcore","correct":"import prawcore"},{"symbol":"TrustedAuthenticator","correct":"from prawcore import TrustedAuthenticator"},{"symbol":"Requestor","correct":"from prawcore import Requestor"},{"symbol":"ReadOnlyAuthorizer","correct":"from prawcore import ReadOnlyAuthorizer"},{"symbol":"session","correct":"from prawcore import session"}],"quickstart":{"code":"import os\nimport pprint\nimport prawcore\n\n# Ensure these environment variables are set before running:\n# PRAWCORE_CLIENT_ID, PRAWCORE_CLIENT_SECRET\n\nclient_id = os.environ.get('PRAWCORE_CLIENT_ID', '')\nclient_secret = os.environ.get('PRAWCORE_CLIENT_SECRET', '')\nuser_agent = \"YOUR_VALID_USER_AGENT\"\n\nif not client_id or not client_secret:\n    print(\"Error: PRAWCORE_CLIENT_ID and PRAWCORE_CLIENT_SECRET environment variables must be set.\")\n    exit(1)\n\nauthenticator = prawcore.TrustedAuthenticator(\n    prawcore.Requestor(user_agent),\n    client_id,\n    client_secret,\n)\nauthorizer = prawcore.ReadOnlyAuthorizer(authenticator)\nauthorizer.refresh()\n\nwith prawcore.session(authorizer) as session:\n    try:\n        response = session.request(\"GET\", \"/api/v1/user/bboe/trophies\")\n        pprint.pprint(response)\n    except prawcore.exceptions.ResponseException as e:\n        print(f\"API Error: {e.response.status_code} - {e.response.text}\")\n    except prawcore.exceptions.RequestException as e:\n        print(f\"Request Error: {e}\")\n","lang":"python","description":"This example demonstrates how to use prawcore to fetch a user's trophies. It assumes you have created a Reddit script application and set `PRAWCORE_CLIENT_ID` and `PRAWCORE_CLIENT_SECRET` environment variables. Replace 'YOUR_VALID_USER_AGENT' with a unique and descriptive user agent string."},"warnings":[{"fix":"Update your `install_requires` (e.g., `prawcore >=X.Y, <(X+1)` or `prawcore~=X.Y`) and consult the changelog before upgrading to a new major version.","message":"Prawcore explicitly follows semantic versioning where only major versions introduce breaking changes to its public interface. Always pin your major version dependency to avoid unexpected breakages.","severity":"breaking","affected_versions":"<3.0.0, 3.x.x"},{"fix":"Upgrade your Python interpreter to version 3.9 or higher.","message":"Prawcore 3.0.0 dropped support for Python 3.8. Earlier versions also dropped support for Python 3.6 and 3.7. Ensure your Python environment meets the `~=3.9` requirement.","severity":"breaking","affected_versions":"3.0.0+"},{"fix":"Update code referencing `RateLimiter.next_request_timestamp` to use `RateLimiter.next_request_timestamp_ns` instead.","message":"In prawcore 3.0.0, the `RateLimiter` attribute `next_request_timestamp` was removed and replaced with `next_request_timestamp_ns`.","severity":"breaking","affected_versions":"3.0.0+"},{"fix":"Double-check your `client_id`, `client_secret`, `username`, and `password`. Ensure 2FA is disabled on the Reddit account if using password flow, or that refresh tokens are handled correctly for other flows. Also, verify your user agent is unique and descriptive.","message":"Applications frequently encounter `prawcore.exceptions.OAuthException: invalid_grant`. This usually indicates an issue with your OAuth credentials (Client ID, Client Secret, Username, Password) or an active 2FA on the Reddit account preventing script access.","severity":"gotcha","affected_versions":"All"},{"fix":"Verify the Reddit account associated with your credentials has the necessary permissions. Review the specific API endpoint documentation for required scopes and user roles.","message":"Encountering `prawcore.exceptions.Forbidden` (HTTP 403) means the authenticated user lacks permission for the requested action or resource, such as accessing private subreddits or replying to locked content.","severity":"gotcha","affected_versions":"All"},{"fix":"Ensure you are on the latest prawcore version. Implement `try-except` blocks for `prawcore.exceptions.ResponseException` (to check `response.status_code`) and `prawcore.exceptions.RequestException`, and incorporate retry logic with exponential backoff for network-related issues or rate limits.","message":"Older versions of prawcore had issues handling Reddit's rate limits, leading to frequent 429 (Too Many Requests) errors. While newer versions improved this, robust error handling for `prawcore.exceptions.ResponseException` and `prawcore.exceptions.RequestException` is crucial for stable bots.","severity":"gotcha","affected_versions":"All, especially pre-3.0.0"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}