LINKEDIN PROFILE API

How to Enrich a Batch of LinkedIn Profile URLs via an API

A complete Python script that reads a CSV of LinkedIn profile URLs, enriches them with the batch API, and writes an enriched CSV with name, role and status.

By Surender Kumar, GTM Engineer, ProfileHunt · Published · 9 min read

Also in: Español · Português (Brasil) · Deutsch · Français · 简体中文 · हिन्दी · العربية · বাংলা · Русский · Bahasa Indonesia · اردو · 日本語 · मराठी · Tiếng Việt · తెలుగు · Hausa · Türkçe · தமிழ் · 한국어

How to Enrich a Batch of LinkedIn Profile URLs via an API

To enrich a batch of LinkedIn profile URLs through an API, read the URLs from your file, send them to a batch endpoint in groups of 100, wait for each group to finish, and write the returned fields back next to the original rows. This guide gives you the whole job as one Python script: a CSV of profile URLs goes in, and the same CSV comes out with name, headline, location, current role, followers, activity date and a status column added.

The script uses the ProfileHunt batch endpoint. For the endpoint itself (request shape, every status, credit rules, error codes), the batch LinkedIn profile API reference is the source. This post is about the job around it.

Key takeaways

  • CSV in, CSV out. The script keeps every original column and adds 11 enriched columns, so the file drops straight back into a sheet or CRM import.
  • 100 URLs per batch, one request each. A list of 2,000 URLs is 20 batch requests, far inside the limit of 60 requests a minute.
  • Order does the mapping. results[i] belongs to urls[i], so no fuzzy matching is needed to put data back on the right row.
  • You pay for found profiles only. At $0.50 per 1,000 profiles, a 2,000-row file costs at most $1, and rows with no public profile cost nothing.

What the input and output look like

The input is any CSV with a column of public LinkedIn profile URLs. The script expects that column to be called linkedin_url; every other column is carried through untouched.

email,company,linkedin_url
bill@example.com,Gates Foundation,https://www.linkedin.com/in/williamhgates
satya@example.com,Microsoft,https://www.linkedin.com/in/satyanadella

The output is the same file with these columns added on the right:

ColumnComes fromNotes
statusresult statusok, gone, unavailable, failed, invalid_url or duplicate
full_nameprofile.full_name
headlineprofile.headline
location, countryprofile.location, profile.country
current_title, current_companyfirst experience entry with no end_dateTitles are only shown for current roles
followers, connectionsprofile.followers, profile.connectionsconnections is capped at 500
last_post_atprofile.last_post_atUseful for outreach timing
scraped_atprofile.scraped_atWhen the profile was read

For the two sample rows, the enriched columns come back as:

full_nameheadlinecurrent_titlecurrent_companyfollowers
Bill GatesChair, Gates Foundation and Founder, Breakthrough EnergyCo-chairGates Foundation40725248
Satya NadellaChairman and CEO at MicrosoftChairman and CEOMicrosoft12222008

Those values are from real responses read on 2026-10-13. Every other field the API returns is listed in the LinkedIn profile JSON schema guide if you want more columns.

Profile URLs grouped into batches of 100 before they are sent

The complete script

Save this as enrich.py, set your key in the environment, and run python enrich.py leads.csv leads_enriched.csv. It needs Python 3.8+ and the requests package.

import csv, os, sys, time, requests

API = "https://api.profilehunt.dev/v1/profile/batches"
HEADERS = {"Authorization": f"Bearer {os.environ['PROFILEHUNT_KEY']}"}
COLUMNS = ["status", "full_name", "headline", "location", "country", "current_title",
           "current_company", "followers", "connections", "last_post_at", "scraped_at"]


def create_batch(urls):
    while True:
        res = requests.post(API, headers=HEADERS, json={"urls": urls})
        if res.status_code in (429, 503):  # not charged; wait and send again
            time.sleep(int(res.headers.get("Retry-After", "10")))
            continue
        res.raise_for_status()  # 402 = not enough credits for this batch
        return res.json()


def wait_for(batch):
    while batch["status"] != "completed":
        time.sleep(5)  # polling is not rate limited
        res = requests.get(f"{API}/{batch['id']}", headers=HEADERS)
        res.raise_for_status()
        batch = res.json()
    return batch


def flatten(result):
    p = result["profile"] or {}
    current = next((e for e in p.get("experience", []) if e["end_date"] is None), {})
    row = {k: p.get(k) for k in COLUMNS}
    row.update(status=result["status"], current_title=current.get("title"),
               current_company=current.get("company"))
    return row


def main(src, dst):
    with open(src, newline="", encoding="utf-8") as f:
        rows = list(csv.DictReader(f))
    urls = list(dict.fromkeys(r["linkedin_url"].strip() for r in rows if r["linkedin_url"].strip()))

    enriched = {}
    for i in range(0, len(urls), 100):
        chunk = urls[i:i + 100]
        batch = wait_for(create_batch(chunk))
        for url, result in zip(chunk, batch["results"]):  # same order as sent
            enriched[url] = flatten(result)
        print(f"{i + len(chunk)}/{len(urls)} URLs, {batch['credits_used']} credits used")

    with open(dst, "w", newline="", encoding="utf-8") as f:
        writer = csv.DictWriter(f, fieldnames=list(rows[0]) + COLUMNS, extrasaction="ignore")
        writer.writeheader()
        for r in rows:
            writer.writerow({**r, **enriched.get(r["linkedin_url"].strip(), {})})


if __name__ == "__main__":
    main(sys.argv[1], sys.argv[2])

How the script works, block by block

create_batch

create_batch sends one group of up to 100 URLs to POST /v1/profile/batches and returns the batch with its id. A 429 (over 60 requests a minute) or 503 (the batch couldn't be queued) is never charged and holds no credits, so the function waits for the Retry-After header and sends the same group again. Any other error stops the run. The one you are most likely to see is 402, which means the workspace doesn't have enough credits to cover every URL in the group; nothing is held when that happens.

wait_for

wait_for polls GET /v1/profile/batches/<id> every 5 seconds until status is completed. Polling does not count against the rate limit, so a short interval costs nothing.

flatten

flatten turns one result into a flat dictionary of columns. When a profile wasn't returned, profile is null and every enriched column stays empty except status. The current role is the first experience entry whose end_date is null. Some people hold several current roles at once (a CEO who is also a board member, for example); the script takes the first one listed.

main

main reads the whole CSV, removes blank and exactly repeated URLs, sends the rest in groups of 100, and writes every original row back with its enriched columns. Rows that share a URL all receive the same data, but the profile is only fetched and paid for once.

What Most Guides Get Wrong About Batch Enrichment

They match results back by name or by URL lookup. The returned profile has its own profile_url and public_id, which are normalized forms and can differ from what you sent (a country subdomain, a trailing slash, an encoded name). Matching on those breaks quietly. The batch API keeps your order, so the script zips each group's URLs with its results instead.

They send one request per row. Calling the single endpoint for every row of a 5,000-row file uses 5,000 of your 60 requests a minute, which is over 80 minutes of rate limit. The same file is 50 batch requests.

They treat every empty row as a failure. gone (no public profile at that URL) and unavailable (LinkedIn didn't serve it this time) both leave the columns empty, but they mean different things. Keeping the status column in the output is what lets you tell them apart later.

Myth vs Reality

MythReality
"Batch enrichment needs a queue, workers and a database."One script with a loop is enough for files up to tens of thousands of rows. The API does the queueing.
"Duplicate rows cost double."The script sends each distinct URL once, and the API also skips repeated profiles inside a batch (duplicate, never charged).
"Empty columns mean the API missed data."Every key is always present; null means the public profile doesn't show it. The status column says why a whole row is empty.
"I need to log in to LinkedIn for this to work."The API reads the public view. No LinkedIn account, cookie or Sales Navigator seat is used.
"You can get emails out of the same run."Public profiles don't show emails or phone numbers. Keep your email column from your own source; this run adds profile data next to it.

Original rows on one side, the same rows with enriched columns on the other

After the run: cleaning up the status column

Filter the output on status and handle each group once:

statusWhat to do with the row
okDone. Import it.
unavailable, failedPut these URLs in a new CSV and run the script again later. They were not charged.
goneCheck the URL by hand. The profile was removed, made private, or the URL is wrong.
invalid_urlNot a linkedin.com/in/ URL: company pages, search links and typos land here. Fix or drop.
duplicateThe same profile appeared twice in one batch under different spellings. Copy the data from the first row.

The batch API reference has the full status table with credit rules for each.

Advanced: Running This on Large or Recurring Files

The script above holds everything in memory and writes the output once at the end. That is the right trade-off up to tens of thousands of rows. Beyond that, or for a nightly job, change three things:

  1. Write as you go. Append each finished group to the output instead of waiting for the end, so a crash at row 40,000 keeps the first 39,900.
  2. Record batch ids. Save each batch id to a file the moment it is created. If the run stops, read the open batches back with GET (they stay readable for 30 days) instead of creating them again and paying twice. The bulk submission guide has a resumable version with exactly this.
  3. Normalize before you dedupe. https://uk.linkedin.com/in/williamhgates/ and https://www.linkedin.com/in/williamhgates are the same person. The API catches that inside one batch, but not across two batches. Reduce every URL to its /in/<slug> before removing duplicates; formatting a profile URL in a payload has a dedupe key function.

For a recurring refresh of a CRM or event list, the sales operations guide covers scheduling and budgeting per list. For 100,000 rows with checkpoints, retries and cost math, see the Python workflow at scale.

Where ProfileHunt Fits

ProfileHunt is a LinkedIn Profile API: public LinkedIn profile URL in, JSON out, and you pay only for profiles found. The batch endpoint takes 100 URLs per request, reads each profile live, and returns the same profile object a single call returns, so one flattening function works for both.

Pricing is $0.50 per 1,000 profiles found, prepaid credits with no subscription, and credits never expire. ProfileHunt returns the public view of a profile: no emails, no phone numbers, no titles for past roles, and connections capped at 500.

Getting Started

  1. Sign up at profilehunt.dev. A work email gets 100 free credits, enough to run the script on a 100-row test file.
  2. Copy your API key and set it as PROFILEHUNT_KEY. The quickstart shows the first call.
  3. Run the script on your CSV. If you'd rather not write code for a list of 100 or fewer, the dashboard's batch playground takes pasted URLs and downloads the results as CSV.

The batch LinkedIn profile API reference has every status, limit and error the script can meet.

Frequently asked questions

How do I enrich a CSV of LinkedIn URLs with Python?

Read the URL column with the csv module, send the URLs to a batch endpoint in groups of 100, poll each batch until it completes, and write the returned fields back to each row by position. The script in this post does all of that in about 50 lines.

How long does it take to enrich 1,000 LinkedIn profiles?

1,000 URLs are 10 batch requests, which takes seconds to submit. The total time depends on how fast the profiles are read, since each one is fetched live; poll each batch every few seconds rather than waiting a fixed time.

How much does it cost to enrich a list of LinkedIn profile URLs?

With ProfileHunt, one credit per profile found, which is $0.50 per 1,000 profiles. Rows that come back gone, unavailable, failed, invalid_url or duplicate are not charged.

Can I enrich LinkedIn URLs in Google Sheets without code?

Yes. Export the sheet as CSV and paste up to 100 URLs into the batch playground in the dashboard, then download the results as CSV. For larger sheets, an automation tool such as n8n can call the API from the sheet.

What happens if my script crashes halfway through a batch?

The batch keeps running on the server. Its results stay readable for 30 days with GET /v1/profile/batches/<id>, so if you saved the batch id you can collect the results without creating the batch again.

Get API key 100 free credits with a work email