Integrating a LinkedIn profile API with a custom backend application takes five parts: a small service module that owns every call, a job queue that sends lists through the batch endpoint, one database table for profiles, a refresh policy driven by scraped_at, and enough logging to see cost and failures. This guide gives each part concretely, with code and a table schema, using the ProfileHunt API.
If you're still choosing a data source, start with what a LinkedIn profile API is.
Key takeaways
- One module talks to the API. Every other part of the codebase calls functions like
getProfileand never builds an HTTP request itself. - Interactive lookups go single, lists go batch. Single calls answer in seconds; batches carry 100 URLs for one request against the rate limit.
- Store the status, not just the profile.
ok,goneandunavailableeach lead to a different next action. - Refresh by age, not by habit.
scraped_attells you how old each profile is; refresh important records more often and leave the rest alone.
The architecture at a glance
A backend integration has a request path and a background path. The request path serves a user who is waiting: someone opens a contact and your app needs the profile now. The background path works through lists: imports, nightly refreshes, new sign-ups.
| Part | Job | Talks to |
|---|---|---|
| Service module | The only code that calls the API: headers, timeouts, error mapping | ProfileHunt API |
| Job queue and worker | Groups pending URLs into batches of up to 100, polls, writes results | Service module, database |
linkedin_profiles table | One row per profile with status, extracted columns and the raw JSON | Your app, the worker |
| Refresh scheduler | Picks rows whose data is older than their tier allows | Job queue |
| Logs and metrics | Status counts, credits, rate-limit headroom, errors | Your monitoring |
Keep the API key on the server, read from an environment variable. Browsers can only call the ProfileHunt API from the ProfileHunt dashboard, so your front end asks your backend, and your backend asks the API. Give each app or environment its own key; keys share the workspace's credits, and the rate limit of 60 requests a minute applies per key.
The service module
The service module wraps the three endpoints and turns HTTP errors into one error type with the code and the Retry-After value. Node.js 18 or later, no dependencies:
// profilehunt.ts
const API = "https://api.profilehunt.dev";
export class ProfileHuntError extends Error {
constructor(public http: number, public code: string, public retryAfter: number | null) {
super(`${http} ${code}`);
}
}
async function call(path: string, init: RequestInit = {}) {
const res = await fetch(`${API}${path}`, {
...init,
headers: {
Authorization: `Bearer ${process.env.PROFILEHUNT_KEY}`,
"Content-Type": "application/json",
},
signal: AbortSignal.timeout(60_000),
});
if (!res.ok) {
const body = await res.json().catch(() => ({ error: "unknown" }));
const after = res.headers.get("Retry-After");
throw new ProfileHuntError(res.status, body.error, after ? Number(after) : null);
}
return res.json();
}
export const getProfile = (url: string) =>
call("/v1/profile", { method: "POST", body: JSON.stringify({ url }) });
export const createBatch = (urls: string[]) =>
call("/v1/profile/batches", { method: "POST", body: JSON.stringify({ urls }) });
export const getBatch = (id: string) => call(`/v1/profile/batches/${id}`);
Three choices in this module matter. The timeout is generous, because a single lookup waits while the profile is read, usually a few seconds, and a lookup that runs too long already ends on the API side with 504 timeout (not charged). Errors keep the API's own code (unauthorized, insufficient_credits, invalid_url, rate_limited), so callers can branch on it. And getProfile returns the body as is: HTTP 200 with a status the caller must check. The errors reference lists every code, and the REST-compatible API guide shows how to generate a typed client from the OpenAPI spec instead of writing this by hand.

A job queue for batches
A worker that drains a queue into the batch endpoint is the right shape for every list. Each cycle works like this:
- Select up to 100 rows that are due (new, or past
next_refresh_at), oldest first. - Call
createBatchwith their URLs and store the returned batchidagainst those rows. The API answers202at once. - Poll
getBatch(id)every few seconds untilstatusiscompleted. Polling doesn't count against the rate limit. - Walk
results, which keep the order you sent.results[i]belongs to rowi, so no matching is needed. - Write each row according to its status, then pick the next 100.
Each result status needs its own handling:
| Result status | Write | Next attempt |
|---|---|---|
ok | Profile JSON and extracted columns, scraped_at | Per refresh tier |
gone | Status only; keep any data you had | None; mark the record |
unavailable, failed | Status, increment attempts | Later, with growing gaps |
invalid_url | Status only | None; the input needs fixing |
duplicate | Copy from the first occurrence in the batch | Same as that row |
Two operational details belong in the worker. When the batch is created, one credit is held per fetchable URL, and a workspace that can't cover the whole batch gets 402 insufficient_credits with nothing held; treat that as an alert, not a retry. And a batch can be read for 30 days after creation, after which GET returns 404, so write results as soon as the batch completes. The batch API guide covers the endpoint itself, and submitting URLs in bulk shows how to save batch ids so a restarted worker resumes instead of paying twice.
The request path doesn't use the queue. When a user is waiting, call getProfile directly. Single calls are served before batch items, so a large running batch never slows the lookups your users trigger.
The profiles table
One table holds every profile your backend knows. Postgres shown; the columns carry over to any database:
create table linkedin_profiles (
public_id text primary key, -- the name after /in/, as the API returns it
input_url text not null, -- the URL as you received it
status text not null, -- ok | gone | unavailable | failed | invalid_url
profile jsonb, -- the full response profile when status = 'ok'
full_name text,
headline text,
current_title text,
current_company text,
country char(2),
followers integer,
last_active_at timestamptz,
scraped_at timestamptz, -- when ProfileHunt read the profile
checked_at timestamptz not null, -- when you last asked, whatever the answer
next_refresh_at timestamptz,
attempts integer not null default 0
);
Store the full profile as JSON and extract only the columns you filter or sort on. Every key in the response is always present, with null or [] when the profile doesn't show it, so the extraction never has to check whether a key exists. current_title and current_company come from the first experience item whose end_date is null; past roles have no title in the public view. public_id is the profile name from the URL you sent, so you can compute it before the call and key gone rows the same way as found ones.
Keep scraped_at and checked_at apart. scraped_at is the age of the data; checked_at is the last time you tried. A row that has been unavailable for a week has a recent checked_at and an old scraped_at, and both facts matter.

A refresh policy built on scraped_at
ProfileHunt reads the profile live on every call and caches nothing, so every refresh is a real read and every found profile uses a credit. A refresh policy decides which records are worth that credit and how often. Tiers by business value work well:
| Tier | Example records | Refresh when scraped_at is older than |
|---|---|---|
| Hot | Open deals, candidates in process | 7 days |
| Warm | Active customers, current pipeline | 30 days |
| Cold | Everything else | 90 days, or on demand |
The cost is easy to compute: $0.50 per 1,000 profiles found. Refreshing 10,000 warm records every month costs about $5 in credits; gone and unavailable answers are free. Set next_refresh_at when you write the row, and let the scheduler simply select rows where it has passed.
What Most Guides Get Wrong About Backend Integrations
They call the API from wherever the data is needed. Scattered calls mean scattered keys, retries and error handling. One service module and one table give one place to fix things.
They retry everything. gone will not change on retry, invalid_url needs a different input, and 402 needs a top-up. Only unavailable, failed, 429 and the temporary 5xx codes are worth trying again; what an unavailable response means gives a retry schedule with growing gaps.
They poll without storing. Batch results are readable for 30 days. A worker that keeps results only in memory loses them on a restart; write each row as the batch completes.
Myth vs Reality
| Myth | Reality |
|---|---|
| "Cache profiles at the API layer to save credits." | The API reads live and caches nothing by design. Your linkedin_profiles table is the cache; scraped_at says how old it is. |
| "Loop over single calls for imports." | Each key allows 60 requests a minute. One batch request carries 100 URLs and counts once. |
"A gone row should be deleted." | Keep it with its status. It tells you the URL is dead and stops the scheduler from paying to ask again. |
| "Batches will slow down live lookups." | Single calls are served before batch items. |
Advanced: Observability for an enrichment backend
Once the integration is live, four signals tell you whether it's healthy, and each one comes straight from the API's responses:
- Status mix per run. Log
ok,gone,unavailableandfailedcounts for each batch (the batch response has acountsobject). A sudden rise ingoneusually means a bad list import, not an API problem. - Credits used. Each completed batch reports
credits_used. Sum it per day and per source, and alert before the workspace runs out, rather than learning from a402. - Rate-limit headroom. Counted requests return
X-RateLimit-Remaining. Log its minimum per minute; if it reaches zero regularly, move more work into batches or give the busy job its own key. - Errors by code. Count
429,5xxand504separately from401and422. The first group is temporary and retried; the second means a config or data bug.
When something looks wrong for one profile, every request appears on the dashboard's Usage page with its request ID (req_…) and the key that made it. The rate limits page documents the headers.
Where ProfileHunt Fits
ProfileHunt is a LinkedIn Profile API designed to sit behind a backend like this one: one endpoint for single lookups, one for batches of up to 100, standard status codes and a response shape that never drops keys. It reads the public view of a profile live, without your LinkedIn account, cookie or seat.
The limits are the public view's: no emails or phones, no titles for past roles, and connections capped at 500. Pricing is $0.50 per 1,000 profiles found, with gone and unavailable lookups refunded and credits that never expire.
Getting Started
Sign up for a workspace, a key and 100 free credits with a work email. Make one call with the quickstart, then add the service module and the table above. For mapping fields into existing records, see the enrichment request example. For how profile APIs work overall, see the LinkedIn profile API overview.
Frequently asked questions
How do I integrate a LinkedIn profile API into my backend?
Put every call in one service module that reads the key from an environment variable, call the single endpoint for lookups a user is waiting on, and run lists through a queue that sends batches of up to 100 URLs. Store results with their status and scraped_at in one table.
Should I store LinkedIn profile data in my own database?
Yes, if you look up the same profiles more than once. The API reads live and doesn't cache, so your table is what saves repeat credits. Keep only what you need, have a lawful reason to process it, and honour deletion requests.
How often should I refresh LinkedIn profile data?
It depends on the record's value. A common split is weekly for open deals or active candidates, monthly for active customers and quarterly for the rest, measured from scraped_at.
How do I handle rate limits when calling a LinkedIn profile API from a server?
Use batches for lists, since one batch of 100 URLs counts as one request. On 429, wait the seconds in Retry-After; the refused request isn't charged.
Can I call the LinkedIn profile API from my frontend?
No. Browsers can only call the ProfileHunt API from the ProfileHunt dashboard, and a key in front-end code is readable by anyone. Your front end calls your backend, which calls the API. See authentication.


