requests library: one person lookup, a small client that handles the failure responses, and an asynchronous work email lookup that you submit, poll and read. No Forager package is needed, and none is published yet, so requests is the whole dependency list.
1
Install requests and set your credentials
2
Run your first lookup
A person lookup costs 1 credit and takes a LinkedIn public identifier (the slug after The response is one person record. Trimmed, with fictional values:Keep
/in/) or a Forager person_id.first_lookup.py
Response (illustrative)
id: the phone and personal email lookups take it as person_id.3
Handle 403, 429 and running out of credits
raise_for_status() turns every error into the same exception. The cases below need different handling, so wrap the call in a small client:forager_client.py
requests raises on a 2xx with an empty body only when you call .json(), so check resp.content first for those endpoints.4
Submit an async work email lookup
The work email lookup answers
202 at once with a job_id, because verifying an address takes longer than a request should wait. Identify the person by name and company domain, or by LinkedIn public identifier.202 response (illustrative)
5
Poll until the job is terminal
Poll the job result until 5 credits are charged only when
status is completed or failed. Polling is free. While the job is still running the response carries a Retry-After header that says how long to wait.Completed job (illustrative)
result is found. To skip polling, send a webhook_url with the submit request and Forager POSTs the result there. For more than a handful of people, use the bulk lookup instead of a loop of single lookups.Test without spending credits
Mock the HTTP layer in your tests so they never reachapi-v2.forager.ai. With requests, the responses library or unittest.mock.patch("requests.request") is enough: return a 403 to check ForagerAuthError, a 429 then a 200 to check the retry, and a completed job body to check the polling loop.
Next steps
Enrich a CSV of LinkedIn URLs
A complete Python script built on this client.
Choose the right endpoint
Match what you have to the endpoint you need, with each call’s credit cost.
Errors and rate limits
Every documented status code and limit.
Node.js quickstart
The same walkthrough with
fetch.