API setup
Jobs
Bulk email work runs as a job. Start it, poll it until it ends, then read its results a page at a time.
Start a job
Find emails in bulk and Verify emails answer 202 with the job, already running. Its id starts with its type, find_ or verify_. Send an Idempotency-Key so a retried start never makes a second job.
Poll until it ends
Call Get a job with limit=0 every 5 to 10 seconds: it answers the status, progress and counts without results. status is running until it ends as done, cancelled or failed.
import os, time
import requests
base = "https://app.leadlayer.com/v1"
headers = {"x-api-key": os.environ["LEADLAYER_KEY"]}
job_id = "JOB_ID" # data.id from Verify emails or Find emails in bulk
while True:
job = requests.get(f"{base}/jobs/{job_id}", headers=headers, params={"limit": 0}).json()["data"]
if job["status"] != "running":
break
time.sleep(8)
results, offset = [], 0
while True:
page = requests.get(f"{base}/jobs/{job_id}", headers=headers, params={"limit": 1000, "offset": offset}).json()["data"]
results += page["results"]
if not page["results_page"]["has_more"]:
break
offset += 1000Read the results
Results come in input order, limit at a time (up to 1,000) from offset. results_page gives total results in all, and has_more while a later page has some. You can read results while the job runs; unfinished ones show as pending.
- Verify
- Text that is not an address is dropped and repeats are checked once, so
indexcounts after those drops. Match results to your input byemail - Find
indexis the person's place in what you sent. A person with no name or no company isskipped, free
Credits
A job holds credits when it starts: 1 per person to look up, or 0.25 per address this account has not checked in the last 30 days. The plan's free verifications for the month are used first, and only the rest is held. Answers are charged as they arrive (credits.charged). When the job ends, what the hold did not use comes back. Cancel a job stops it and gives back the rest at once.