RocketReach Python Library

2.1.8 · active · verified Thu Apr 16

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

import rocketreach
import os

# Ensure your RocketReach API key is set as an environment variable
api_key = os.environ.get('ROCKETREACH_API_KEY', '')

if not api_key:
    print("Warning: ROCKETREACH_API_KEY environment variable not set. Quickstart may fail.")
    print("Please set it: export ROCKETREACH_API_KEY='your_api_key'")
else:
    try:
        # Initialize the RocketReach Gateway
        rr = rocketreach.Gateway(api_key=api_key)

        # Example 1: Get account details
        account_result = rr.account.get()
        if account_result.is_success:
            print("Account details:", account_result.account)
        else:
            print("Failed to retrieve account details:", account_result.error)

        # Example 2: Search for a person (Note: This operation consumes lookup credits)
        # Replace 'Google' and 'Software Engineer' with your target criteria
        print("\nAttempting a person search (consumes credits)...")
        person_search_query = rr.person.search().filter(
            current_employer='Google',
            current_title='Software Engineer'
        )
        search_results = person_search_query.execute()

        if search_results.is_success:
            print(f"Found {len(search_results.people)} matching people:")
            for person in search_results.people:
                emails_display = ', '.join([e.value for e in person.emails]) if person.emails else 'No email'
                print(f"  - Name: {person.name}, Title: {person.current_title}, Company: {person.current_employer}, Emails: {emails_display}")
        else:
            print("Failed to perform person search:", search_results.error)

    except Exception as e:
        print(f"An unexpected error occurred: {e}")

view raw JSON →