Skip to content

MaintenanceThe former company search endpoint goes into maintenance on November 9Migration guide

SDKs // Python // Guides

Client options

Last verified

Configure the Reverse Contact Python client with timeouts, retries, custom httpx connections, shared options, application metadata and debug logging.

ReverseContact and AsyncReverseContact accept these keyword-only constructor options.

ArgumentDefaultMeaning
api_keyRC_API_KEYYour API key
base_urlRC_BASE_URL, then https://api.reversecontact.comAPI origin
timeout90Seconds per HTTP attempt, or an httpx.Timeout
max_retries4Retries after the first attempt
default_headersnoneHeaders added to every request
http_clienta client the SDK createsYour own httpx.Client or httpx.AsyncClient, for a proxy or connection pool settings
sleeptime.sleep or asyncio.sleepFunction used for retry and polling delays. Async clients require an awaitable
clocktime.monotonicMonotonic clock used for polling deadlines
app_infonone{"name": ..., "version": ...} of your integration, added to the User-Agent

Close the client when you are done, with a with block or client.close(). If you pass an http_client, close that client yourself. Use client.with_options() to change options in a copy that shares the connection pool.

Debug logging is off by default. Set RC_LOG=debug before creating the client, or set the reversecontact logger to logging.DEBUG. The logs show the method, path, status, attempt, retry delay and request id. They never show the API key, the request body or the query values.

Python SDK

Client options

import logging
import os

from reversecontact import ReverseContact

logging.basicConfig()
logging.getLogger("reversecontact").setLevel(logging.DEBUG)

with ReverseContact(
    api_key=os.environ["RC_API_KEY"],
    timeout=120.0,
    max_retries=2,
    app_info={"name": "my-crm-sync", "version": "1.4.0"},
) as client:
    fast = client.with_options(timeout=30.0, max_retries=0)
    print(fast.usage.retrieve().quotas)

The package also exports its models, such as Person and Company, and the request and response models of every operation in reversecontact.types.

Copy options without a new pool

client.with_options() accepts api_key, base_url, timeout, max_retries, default_headers, app_info, sleep and clock. Options you omit keep their existing values. Additional default_headers merge with the current headers.

The returned client uses the original HTTP pool. Closing the copy leaves that pool open. Keep the original client open while using its copies.

Read client.base_url for the configured API origin, without a trailing slash. API methods accept per-request timeout, max_retries and headers. Wait helpers have overall deadline controls, described in Timeouts and cancellation.

max_retries must be a non-negative integer. Invalid values raise ReverseContactError. See Install and configure to create a client and Async client to manage async connections.

Return to the Python SDK overview.

FAQ

How do I change the Python SDK API base URL?

Pass base_url to the client. Without an explicit value, the SDK reads RC_BASE_URL, then defaults to https://api.reversecontact.com.

Does with_options create a new connection pool?

client.with_options() shares the original pool and returns a client with copied options. Closing the copy leaves the shared pool open.

How do I enable Python SDK debug logs?

Set RC_LOG=debug before creating the client or set the reversecontact logger to logging.DEBUG. Logs omit API keys, request bodies and query values.

Can I supply my own httpx client?

Pass an httpx.Client to ReverseContact or an httpx.AsyncClient to AsyncReverseContact using http_client. Close the supplied client yourself.