Here is a complete Python example for public LinkedIn profile URL enrichment: eight lines with requests that send one profile URL to ProfileHunt and print the person's name, headline and last post time. Below it, every line is explained, then the same call is shown with httpx, and finally the three checks that make it safe to run on real data.
If you are new to the idea, what a LinkedIn profile API is explains what happens on the other side of this request.
Key takeaways
- One POST, one JSON body.
{"url": "https://www.linkedin.com/in/williamhgates"}is the whole request. - The key goes in a header.
Authorization: Bearer <key>, read from an environment variable, never from the source file. - Check
statusbeforeprofile.profileisNonewhen the profile isgoneorunavailable, and neither is charged. - Set a timeout.
requestswaits forever by default;httpxgives up after 5 seconds, which can be too short for a live lookup.
The shortest working example
Install requests (pip install requests), put your API key in PROFILEHUNT_KEY, and run:
import os, requests
res = requests.post(
"https://api.profilehunt.dev/v1/profile",
headers={"Authorization": f"Bearer {os.environ['PROFILEHUNT_KEY']}"},
json={"url": "https://www.linkedin.com/in/williamhgates"},
)
profile = res.json()["profile"]
print(profile["full_name"], profile["headline"], profile["last_post_at"])
With the sample response from the ProfileHunt home page (read on 2026-10-13), it prints:
Bill Gates Chair, Gates Foundation and Founder, Breakthrough Energy 2026-10-12T20:10:59.000Z
Your output will show whatever the profile says when you run it, because every call reads the public profile live.

The example, line by line
| Line | What it does |
|---|---|
import os, requests | os reads the key from the environment; requests sends the HTTP call. |
requests.post( | The endpoint takes POST, because you send a body. |
"https://api.profilehunt.dev/v1/profile" | The single-profile endpoint. Lists use /v1/profile/batches instead. |
headers={"Authorization": f"Bearer ..."} | Authenticates the call with your workspace key. {"x-api-key": key} works too. |
json={"url": ...} | Serializes the dict and sets Content-Type: application/json for you. |
res.json()["profile"] | The body is {"status": ..., "profile": {...}}; this takes the profile. |
print(profile["full_name"], ...) | Reads three of the keys every profile has. |
Three details are easy to miss:
- The URL must be a
linkedin.com/in/profile URL. Anything else gets422and costs nothing. json=, notdata=.data=would send form fields, and the API expects JSON.os.environ['PROFILEHUNT_KEY']fails loudly with aKeyErrorif the variable isn't set, which is what you want.os.getenvwould sendBearer Noneand get a401.
The full key list for profile is in the profile endpoint reference. For turning those keys into types, dates and a DataFrame, see how to parse structured LinkedIn profile JSON with Python.
The same request with httpx
httpx has nearly the same API as requests, plus an async client. The call is identical except for one argument you should always pass:
import os, httpx
res = httpx.post(
"https://api.profilehunt.dev/v1/profile",
headers={"Authorization": f"Bearer {os.environ['PROFILEHUNT_KEY']}"},
json={"url": "https://www.linkedin.com/in/williamhgates"},
timeout=60,
)
profile = res.json()["profile"]
print(profile["full_name"], profile["headline"], profile["last_post_at"])
httpx times out after 5 seconds by default. A lookup reads the profile live, so give it room: timeout=60 lets the API answer on its own terms, including a 504 if a lookup runs too long.
The async version, for when you already run inside an event loop (FastAPI, an async worker):
import asyncio, os, httpx
async def enrich(url: str) -> dict:
async with httpx.AsyncClient(timeout=60) as client:
res = await client.post(
"https://api.profilehunt.dev/v1/profile",
headers={"Authorization": f"Bearer {os.environ['PROFILEHUNT_KEY']}"},
json={"url": url},
)
return res.json()
print(asyncio.run(enrich("https://www.linkedin.com/in/williamhgates"))["status"])
Make it safe for real data
The short example assumes everything works. Three additions make it ready for real URLs:
import os, requests
res = requests.post(
"https://api.profilehunt.dev/v1/profile",
headers={"Authorization": f"Bearer {os.environ['PROFILEHUNT_KEY']}"},
json={"url": "https://www.linkedin.com/in/williamhgates"},
timeout=60, # 1. never wait forever
)
res.raise_for_status() # 2. 401, 402, 422, 429 and 5xx raise here
data = res.json()
if data["status"] == "ok": # 3. gone / unavailable carry no profile
profile = data["profile"]
print(profile["full_name"], profile["headline"], profile["last_post_at"])
else:
print("no profile:", data["status"]) # not charged
What each outcome means for this script:
| Response | Meaning | Credit |
|---|---|---|
200, status: "ok" | Profile found and returned. | 1 |
200, status: "gone" | No public profile at this URL. Don't retry. | 0 |
200, status: "unavailable" | LinkedIn didn't serve it just then. Retry later. | 0 |
401 | Key missing, wrong or revoked. | 0 |
402 | The workspace is out of credits. | 0 |
422 | Not a linkedin.com/in/ URL. | 0 |
429 | Over 60 requests a minute on this key. Wait for Retry-After. | 0 |
The error reference lists the 5xx codes and what to do about each, and response status handling for failed lookups has a Python retry function for them.

What Most Guides Get Wrong About Python Profile Examples
They skip the timeout. Most requests snippets online have no timeout, so a stalled connection hangs the script with no error. Production code always passes one.
They read profile without checking status. A not-found profile comes back as 200 with profile: None, so raise_for_status() passes and the next line fails with TypeError. The status check is not optional.
They paste the API key into the script. A key in source ends up in Git history and in screenshots. An environment variable, a .env file loaded by your framework, or a secret manager keeps it out.
They loop this example over a whole CSV. One call per row works for a handful of URLs, but each call counts against the 60-requests-a-minute limit. For lists, the batch endpoint takes 100 URLs in one request; see the Python workflow for enriching LinkedIn profiles at scale.
Myth vs Reality
| Myth | Reality |
|---|---|
| You need a LinkedIn account or cookie to fetch a profile in Python. | ProfileHunt reads the public view and never uses your LinkedIn login, cookie or seat. |
A 200 means the profile was found. | 200 also carries gone and unavailable. Read status. |
httpx is a drop-in for requests. | Almost: it has a 5-second default timeout, and that matters for live lookups. |
| Async makes enrichment faster. | Async lets you wait on several calls at once, but the per-key limit is still 60 requests a minute. Batches are the faster path for lists. |
| A failed lookup still costs a credit. | Only status: "ok" uses a credit. Not found, unavailable, errors and rate-limit refusals are free. |
Advanced: Reusing Connections and Respecting the Limit
When this example moves into a service that enriches profiles all day, two things change.
Reuse one client. requests.post opens a new connection each time. A requests.Session() or a long-lived httpx.Client keeps the TLS connection open and sets the headers once:
import os, requests
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['PROFILEHUNT_KEY']}"
def enrich(url: str) -> dict:
res = session.post("https://api.profilehunt.dev/v1/profile", json={"url": url}, timeout=60)
res.raise_for_status()
return res.json()
Budget the 60 requests a minute. The limit is per key and resets at the start of each clock minute. Every counted response carries X-RateLimit-Remaining, so a service can slow down before it hits 429 rather than after. When it does get a 429, the Retry-After header says how many seconds to wait; sleeping exactly that long is better than a fixed back-off. The rate limit docs show the headers.
Pick the endpoint by latency need, not habit. A user waiting on a page should get the single call. Anything that can wait a few seconds more (an import, a nightly refresh) should go through batches, which take 100 URLs per counted request and run after single calls, so they never slow down the lookups your users are waiting on.
Where ProfileHunt Fits
ProfileHunt is a LinkedIn Profile API: public profile URL in, structured JSON out, with the same keys on every profile. That is why an eight-line script is a working integration, not a demo. There is no LinkedIn login to manage and no browser to drive.
Pricing is $0.50 per 1,000 profiles found ($1 buys 2,000 credits), with no subscription, and credits never expire. It returns the public view only, so no emails or phone numbers, and past roles come without titles.
Getting Started
Sign up with a work email for 100 free credits, create a key, and run the example above; the quickstart has the same call, and the playground runs it with no code. When you are ready to handle a list, move on to the batch API guide. For how the API fits a data stack, read what a LinkedIn profile API is.
Frequently asked questions
How do I get LinkedIn profile data with Python?
Send a POST to https://api.profilehunt.dev/v1/profile with requests, an Authorization: Bearer header and a JSON body {"url": "<profile URL>"}. The response's profile key holds the data as a dict.
Do I need the LinkedIn API or a LinkedIn developer app to do this in Python?
No. ProfileHunt is its own REST API with its own keys. You don't register a LinkedIn app or sign in to LinkedIn.
Should I use requests or httpx for a LinkedIn profile API?
Either works. Use requests for simple scripts and httpx when you need async. With httpx, set timeout=60, because its 5-second default can cut off a live lookup.
Why does my Python script return a 401 error?
The key is missing, wrong or revoked. Check that PROFILEHUNT_KEY is set in the shell that runs the script and that the header reads Bearer <key> with a space.
How much does one LinkedIn profile lookup cost from Python?
One credit, $0.0005, and only when status is ok. Profiles that are gone or unavailable are not charged, and new workspaces start with 100 free credits on a work email.


