{"id":9282,"library":"rocketreach","title":"RocketReach Python Library","description":"The `rocketreach` Python library provides official bindings for the RocketReach API, allowing programmatic access to its extensive database of professional contact information, including emails, phone numbers, and social links. It is actively maintained, with version 2.1.8 currently available, and facilitates tasks such as lead generation, sales prospecting, and data enrichment.","status":"active","version":"2.1.8","language":"en","source_language":"en","source_url":"https://github.com/rocketreach/rocketreach_python","tags":["API client","contact data","lead generation","sales prospecting","data enrichment"],"install":[{"cmd":"pip install rocketreach","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"symbol":"Gateway","correct":"from rocketreach import Gateway"},{"symbol":"GatewayConfig","correct":"from rocketreach import GatewayConfig"},{"symbol":"GatewayEnvironment","correct":"from rocketreach import GatewayEnvironment"},{"note":"While 'from rocketreach import *' works, it's generally discouraged in production code due to potential name collisions. Prefer explicit imports or 'import rocketreach' and qualify names.","wrong":"from rocketreach import *","symbol":"rocketreach","correct":"import rocketreach"}],"quickstart":{"code":"import rocketreach\nimport os\n\n# Ensure your RocketReach API key is set as an environment variable\napi_key = os.environ.get('ROCKETREACH_API_KEY', '')\n\nif not api_key:\n    print(\"Warning: ROCKETREACH_API_KEY environment variable not set. Quickstart may fail.\")\n    print(\"Please set it: export ROCKETREACH_API_KEY='your_api_key'\")\nelse:\n    try:\n        # Initialize the RocketReach Gateway\n        rr = rocketreach.Gateway(api_key=api_key)\n\n        # Example 1: Get account details\n        account_result = rr.account.get()\n        if account_result.is_success:\n            print(\"Account details:\", account_result.account)\n        else:\n            print(\"Failed to retrieve account details:\", account_result.error)\n\n        # Example 2: Search for a person (Note: This operation consumes lookup credits)\n        # Replace 'Google' and 'Software Engineer' with your target criteria\n        print(\"\\nAttempting a person search (consumes credits)...\")\n        person_search_query = rr.person.search().filter(\n            current_employer='Google',\n            current_title='Software Engineer'\n        )\n        search_results = person_search_query.execute()\n\n        if search_results.is_success:\n            print(f\"Found {len(search_results.people)} matching people:\")\n            for person in search_results.people:\n                emails_display = ', '.join([e.value for e in person.emails]) if person.emails else 'No email'\n                print(f\"  - Name: {person.name}, Title: {person.current_title}, Company: {person.current_employer}, Emails: {emails_display}\")\n        else:\n            print(\"Failed to perform person search:\", search_results.error)\n\n    except Exception as e:\n        print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"This quickstart initializes the RocketReach client using an API key from an environment variable, then demonstrates fetching account details and performing a basic person search. Be aware that person searches consume lookup credits on your RocketReach account."},"warnings":[{"fix":"Monitor your RocketReach account's credit usage. The library's `rr.account.get()` method can fetch remaining lookups. Understand the pricing model before running extensive queries.","message":"RocketReach API lookups consume credits from your account. Be mindful of usage, especially when performing bulk operations or iterative searches, as this can lead to unexpected charges.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For non-blocking operations: `result = rr.person.lookup(person_id=123, block=False)`. Then, periodically call `rr.person.checkStatus(person_id=result.person.id)` until the status is complete.","message":"The default `person.lookup()` method is blocking, meaning it will poll the API until contact information is found or the lookup times out. For asynchronous workflows, pass `block=False` and use `checkStatus()` manually.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Implement a retry mechanism with exponential backoff for API calls. Check the error message for `Retry-After` headers if provided, or simply wait a few seconds before retrying.","message":"The RocketReach API has a rate limit (e.g., 250 requests per minute). Exceeding this limit will result in a `429 Too Many Requests` status code.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update your local Git configurations for any forks or clones to track the `main` branch: `git branch -m master main; git fetch origin; git branch -u origin/main main; git remote set-head origin -a`","message":"The default branch of the `rocketreach/rocketreach_python` GitHub repository switched from `master` to `main` on 2025/08/13. This affects how you clone or pull updates if you are tracking the default branch.","severity":"breaking","affected_versions":"Repository usage, not library functionality"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install the library using pip: `pip install rocketreach`","cause":"The 'rocketreach' Python package has not been installed in your current environment.","error":"ModuleNotFoundError: No module named 'rocketreach'"},{"fix":"Verify your `ROCKETREACH_API_KEY` environment variable or the API key passed to `rocketreach.Gateway()` is correct. Ensure it matches the environment (production or sandbox) you intend to use. You can generate/view your API key on the RocketReach website in your API settings.","cause":"The API key configured for the `Gateway` client is incorrect, expired, or missing. This can also occur if you try to use a production key in the sandbox environment or vice-versa.","error":"rocketreach.errors.RocketReachAPIError: Invalid API Key provided."},{"fix":"Add `import rocketreach` at the top of your Python script. If using specific classes like `Gateway`, use `from rocketreach import Gateway`.","cause":"You are trying to use objects or functions from the `rocketreach` library without importing it first.","error":"NameError: name 'rocketreach' is not defined"},{"fix":"Ensure the `Gateway` object is properly initialized with a valid API key. For instance, `rr = rocketreach.Gateway(api_key=os.environ.get('ROCKETREACH_API_KEY', ''))` should be correctly configured. Double-check method names like `account.get()` or `person.search()` against the documentation.","cause":"This typically happens if the `rocketreach.Gateway` object itself was not correctly initialized (e.g., due to a missing API key) and thus returned `None` or an incomplete object, or if you're trying to access a non-existent method/service.","error":"AttributeError: 'NoneType' object has no attribute 'get' (or 'search')"}]}