LINKEDIN PROFILE API

REST-Compatible LinkedIn Profile Enrichment API and OpenAPI

Why a REST-compatible LinkedIn profile enrichment API is easy to build on: JSON over HTTPS, standard status codes, Retry-After and an OpenAPI 3.1 spec.

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

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

REST-Compatible LinkedIn Profile Enrichment API and OpenAPI

A REST-compatible LinkedIn profile enrichment API is one you can call with nothing but standard HTTP: JSON request and response bodies over HTTPS, an API key in a header, status codes that mean what HTTP says they mean, Retry-After when you should wait, and a machine-readable OpenAPI description. ProfileHunt works this way, and that buys developers something concrete: no SDK to install, generic tooling that works on day one, and a client you can generate from /openapi.json in one command.

For what the API returns and why, start with what a LinkedIn profile API is.

Key takeaways

  • Plain HTTP is the SDK. Every language and tool already speaks JSON over HTTPS, so there is nothing ProfileHunt-specific to install or keep updated.
  • Status codes carry the decision. 401, 402, 422, 429 and 5xx each tell your code what to do next, with a stable error code in the body.
  • Lookup results are data, not errors. A profile that doesn't exist is a successful lookup with status: "gone", not a 404.
  • The OpenAPI 3.1 spec is the contract. Generate typed clients, import into Postman or Insomnia, and diff it to catch changes.

What "REST-compatible" means for this API

REST-compatible here means the API follows the conventions of HTTP itself, as defined in RFC 9110, rather than inventing its own. Three endpoints cover everything:

Method and pathoperationIdWhat it doesSuccess
POST /v1/profilegetProfileReads one public profile now200
POST /v1/profile/batchescreateBatchCreates a batch resource of 1 to 100 URLs202 Accepted
GET /v1/profile/batches/{id}getBatchReads that batch's progress and results200

The batch endpoints are textbook resources: POST creates a batch and answers 202 because the work continues in the background, GET reads it by id, and an unknown id (or one from another workspace) gets 404. The single lookup uses POST because its input is a URL sent in a JSON body. The version is in the path (/v1), and the base URL is https://api.profilehunt.dev.

Authentication follows the same standards. The spec declares two schemes: HTTP bearer (Authorization: Bearer <key>) and an API key in the x-api-key header. Either works on every endpoint, so any HTTP library's built-in bearer auth just works. The HTTP client settings guide shows where those values go in eight common clients.

A row of gates over one pipe, one open gate letting a block through

Standard status codes, and what each tells your code

Every error is a non-2xx HTTP status with a small JSON body: { "error": "rate_limited" }. The status code says what class of problem it is; the error string is a stable code to branch on. None of these costs a credit:

HTTPerrorMeaningWhat your code does
401unauthorizedKey missing, wrong or revokedFix configuration; don't retry
402insufficient_creditsWorkspace out of creditsAlert; retry after a top-up
422invalid_url / invalid_batchInput isn't a linkedin.com/in/ URL, or urls is missing, empty or over 100Fix the input; don't retry
429rate_limitedOver 60 requests a minute on this keyWait Retry-After seconds
500internalFailure on the API sideRetry with back-off
502upstream_failedLinkedIn couldn't be reachedRetry with back-off
503temporarily_unavailableBusy; requests paused brieflyWait Retry-After seconds
504timeoutThe lookup took too longRetry

Because these are ordinary HTTP semantics, generic infrastructure handles them correctly without custom code: retry middleware that retries 5xx and honours Retry-After, API gateways that count 4xx separately from 5xx, and monitoring that alerts on error rates by class. The errors reference is the full list, and response status handling for failed lookups has retry code in JavaScript and Python.

Retry-After and the rate-limit headers

Retry-After is the standard HTTP header for "come back in N seconds" (see MDN on Retry-After). ProfileHunt sends it with 429 and 503. With 429, it counts the seconds until the next clock minute, when the per-key count resets. Counted requests also carry X-RateLimit-Limit and X-RateLimit-Remaining, so a client can slow down before it is refused:

HTTP/1.1 429 Too Many Requests
Retry-After: 12
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 0

{ "error": "rate_limited" }

Why a missing profile is a 200, not a 404

The most deliberate design choice in the API is this one. A lookup for a private, deleted or removed profile answers HTTP 200 with {"status":"gone","profile":null}, and a profile LinkedIn didn't serve just then answers {"status":"unavailable","profile":null}.

The reason is that HTTP status codes describe the request, and the request succeeded: the API did its job and the answer is "there is no public profile here". A 404 would mean the endpoint itself wasn't found, and a client couldn't tell a typo in its own path from a dead LinkedIn URL. Keeping lookup outcomes in the body keeps the two apart, and makes the cost rule simple: only status: "ok" uses a credit. In the spec, ProfileResponse has a required status enum of ok, gone and unavailable, and profile is either a Profile object or null.

Generating a client from /openapi.json

The OpenAPI 3.1 description at https://profilehunt.dev/openapi.json defines the three operations, both auth schemes, and the schemas ProfileResponse, Batch, Profile, Position, School, Post, Article, Reaction, Comment and Error. The same schemas back the field tables in the profile endpoint reference, so generated types and the docs describe one shape.

In TypeScript, openapi-typescript turns the spec into types and openapi-fetch gives a small typed client on top of fetch:

npx openapi-typescript https://profilehunt.dev/openapi.json -o profilehunt.d.ts
npm install openapi-fetch
import createClient from "openapi-fetch";
import type { paths } from "./profilehunt";

const api = createClient<paths>({
  baseUrl: "https://api.profilehunt.dev",
  headers: { Authorization: `Bearer ${process.env.PROFILEHUNT_KEY}` },
});

const { data, error } = await api.POST("/v1/profile", {
  body: { url: "https://www.linkedin.com/in/williamhgates" },
});
if (data?.status === "ok") console.log(data.profile?.full_name, data.profile?.scraped_at);

Paths, bodies and response fields are now checked by the compiler: a typo in full_name or a missing url fails the build. For other languages, generators such as OpenAPI Generator read the same file; check that the one you pick supports OpenAPI 3.1. The same file also imports into Postman and Insomnia. The format itself is defined in the OpenAPI Specification 3.1.

A mould press stamping identical keys from one plate

What Most Guides Get Wrong About REST Enrichment APIs

They equate "REST" with "has an SDK". For a three-endpoint JSON API, an SDK mostly adds a dependency with its own release cycle. A generated client or forty lines of fetch cover the whole surface; see the service module in integrating a LinkedIn profile API with a custom backend.

They read every non-2xx as "retry". 401, 402 and 422 will fail the same way every time. Only 429, 5xx and 504 are worth retrying, and 429 and 503 tell you exactly when.

They ignore the body on 200. With an enrichment API, the interesting outcomes live in the body's status. Code that stops at res.ok writes empty records for gone profiles.

Myth vs Reality

MythReality
"REST means every lookup should be a GET."REST is about resources and standard semantics. The batch endpoints are classic resources; the single lookup takes a JSON body, so it's a POST.
"A not-found profile should return 404."404 would hide whether the endpoint or the profile was missing. A 200 with status: "gone" is unambiguous and not charged.
"An OpenAPI spec is just documentation."It's an input to tooling: typed clients, request collections, mock servers and contract diffs.
"Standard codes aren't enough; you need custom error formats."One stable error string per case, on top of the HTTP class, is all a client needs to branch.

Advanced: Treat the spec as a contract in CI

Teams that depend on an external API get the most from its OpenAPI file by checking it automatically, not by reading it once:

  • Pin and diff. Save a copy of /openapi.json in your repository with your generated types. A scheduled CI job fetches the live file and diffs it; any change opens a pull request that regenerates the types, so a new field shows up as a reviewed change instead of a surprise.
  • Treat new fields as additive. The changelog records new fields and endpoints by date. Code that reads only the keys it needs, and stores the full profile JSON alongside, keeps working as fields are added.
  • Mock from the spec. OpenAPI mock servers can serve responses shaped by the same file, including its examples, so tests of your mapping code run offline and cost no credits.
  • Validate at the edge. Check that each input is a linkedin.com/in/ URL before it leaves your system. The API would refuse anything else with 422 for free, but rejecting it earlier keeps your queues and logs clean.

Where ProfileHunt Fits

ProfileHunt is a LinkedIn Profile API built on these conventions: three endpoints, JSON over HTTPS, two standard auth schemes, standard status codes with Retry-After, and an OpenAPI 3.1 description you can generate from. It reads the public view of a profile live on every call, without your LinkedIn account, cookie or seat.

The data limits are the public view's: no emails or phones, no titles for past roles, connections capped at 500. Pricing is $0.50 per 1,000 profiles found, and every non-ok outcome in this guide is free.

Getting Started

Create a workspace to get an API key and 100 free credits with a work email. Generate types from /openapi.json, make one call with the quickstart, and read the profile endpoint reference in the docs for every field. For the bigger picture of profile APIs, see the LinkedIn profile API overview.

Frequently asked questions

Is there a REST API for LinkedIn profile data?

Yes. ProfileHunt is a REST-compatible API: POST https://api.profilehunt.dev/v1/profile with a JSON body { "url": "https://www.linkedin.com/in/..." } returns the public profile as JSON. LinkedIn's own APIs don't offer lookups of arbitrary public profiles by URL.

Does the LinkedIn profile API have an OpenAPI spec?

Yes, an OpenAPI 3.1 description at https://profilehunt.dev/openapi.json, covering the profile and batch endpoints, both auth schemes and every response schema.

How do I generate a TypeScript client for a LinkedIn profile API?

Run npx openapi-typescript https://profilehunt.dev/openapi.json -o profilehunt.d.ts, then create a client with openapi-fetch and call api.POST("/v1/profile", { body: { url } }). Requests and responses are then type-checked.

Why does the API return 200 when the LinkedIn profile doesn't exist?

Because the lookup itself succeeded. The answer is status: "gone" with profile: null, which keeps a dead LinkedIn URL distinct from a wrong endpoint, and isn't charged.

What does Retry-After mean in a 429 response?

It's the number of seconds to wait before sending again. ProfileHunt sends it with 429 (over 60 requests a minute on a key) and 503. See rate limits.

Get API key 100 free credits with a work email