LINKEDIN PROFILE API

How to Format a LinkedIn Profile URL in an API Payload

How to format a public LinkedIn profile URL in an API payload: subdomains, trailing slashes, query strings, accented names, spreadsheet links and dedupe.

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 · தமிழ் · 한국어

How to Format a LinkedIn Profile URL in an API Payload

To format a public LinkedIn profile URL in an enrichment API payload, put it in the JSON as a plain string, ideally in the canonical form https://www.linkedin.com/in/<name>. With ProfileHunt the canonical form is a goal, not a requirement: the API reads the profile name after /in/, so country subdomains, trailing slashes and tracking query strings all reach the same profile. What does need care is the part the API can't guess for you: accented names, stray punctuation from spreadsheets, and the key you use to spot duplicates.

For what the API does with the URL afterwards, see what a LinkedIn profile API is.

Key takeaways

  • One canonical form. https://www.linkedin.com/in/<name>, which is also the profile_url the API returns.
  • Extras are accepted, not refused. Subdomain, www., trailing path and query string all lead to the same name.
  • Encode a name once, never twice. josé, jos\u00e9 and jos%C3%A9 are the same profile; jos%25C3%25A9 is a different one.
  • Dedupe on the lowercase name, not the raw URL. The same person often appears under several spellings of the URL.

The Canonical Form to Aim For

The API reads the name after /in/, returns it decoded as public_id, and sets profile_url to https://www.linkedin.com/in/ followed by that name. So the most useful thing you can store is the same form:

{ "url": "https://www.linkedin.com/in/williamhgates" }

Writing that form yourself gives you a stable value to compare, store and display. The response's public_id is the decoded name (williamhgates) and profile_url is the canonical URL, so storing the canonical form also makes joins back to your records trivial.

Country Subdomains, Trailing Slashes and Query Strings

LinkedIn URLs arrive in many shapes. Here is what each shape becomes:

As you found itName the API readsCanonical form
https://uk.linkedin.com/in/ewan-cairdewan-cairdhttps://www.linkedin.com/in/ewan-caird
linkedin.com/in/williamhgates/williamhgateshttps://www.linkedin.com/in/williamhgates
https://www.linkedin.com/in/williamhgates?utm_source=sharewilliamhgateshttps://www.linkedin.com/in/williamhgates
https://www.linkedin.com/in/ewan-caird/details/experience/ewan-cairdhttps://www.linkedin.com/in/ewan-caird

The documented host forms are linkedin.com, with or without www., and country subdomains such as uk.linkedin.com. Which inputs are refused outright, and how to check them in code, is the job of how to validate LinkedIn profile URL input.

Several pipes with different bends merging into one straight pipe

Accented and Non-Latin Profile Names

Custom profile URLs can contain letters outside A–Z. There are three correct ways to put such a name in a JSON payload, and the API treats all three as the same profile:

{ "url": "https://www.linkedin.com/in/josé" }
{ "url": "https://www.linkedin.com/in/jos\u00e9" }
{ "url": "https://www.linkedin.com/in/jos%C3%A9" }

The first is raw UTF-8 in the JSON string. The second is a JSON escape, which any JSON parser turns back into é before the API sees it. The third is the URL's percent-encoding. Each comes back with the decoded name, josé, as public_id.

The one wrong way is double encoding. If a tool percent-encodes a URL that is already encoded, %C3%A9 becomes %25C3%25A9, and the name no longer matches the profile. Expect a gone: nothing is charged, but the row is lost. If you see %25 in a profile URL, decode it once before sending.

JSON's optional \/ escape for slashes is harmless too: "https:\/\/www.linkedin.com\/in\/williamhgates" is the same string once parsed.

Building the Payload Without Breaking It

The URL is safe once it's inside a properly serialized JSON string. The breakage happens when payloads are assembled by hand.

ApproachSafe?
JSON.stringify({ url }) in JavaScriptYes
json={"url": url} with Python requestsYes
jq -n --arg u "$URL" '{url: $u}' in a shellYes
'{"url": "' + url + '"}' string concatenationNo, breaks on quotes, backslashes and line breaks
A no-code tool's "raw body" field with the URL dropped into quotesOnly if the tool escapes the value

In no-code tools, prefer a JSON body builder (key url, value mapped from your field) to a hand-typed raw body. Complete request bodies for both endpoints are in LinkedIn profile API request body examples, and sending a URL from a sheet, CRM or form shows the glue for each source.

URLs Copied From Spreadsheets and CRMs

Most bad payloads start as a cell. These are the patterns to clean before the URL goes into JSON:

Linked names instead of URLs. A cell can show "Bill Gates" while linking to the profile. When that sheet is exported to CSV, the cell usually becomes its visible text, and the link is gone. If a column shows names, pull the link targets out before exporting.

Wrapping characters. A value pasted from a CSV line, an email or Markdown can arrive as "https://www.linkedin.com/in/williamhgates", <https://www.linkedin.com/in/williamhgates> or …/in/williamhgates, with a trailing comma or semicolon. None of those characters belongs to the profile name. Strip quotes, angle brackets, commas and semicolons from both ends.

Trailing punctuation. A URL copied from the end of a sentence picks up the full stop: …/in/williamhgates. That is still a well-formed URL, so a shape check passes it, but the name is now williamhgates., a different profile. Strip ., !, ? and : from the end.

Several URLs in one cell. Notes fields often hold a URL plus text. Extract the /in/ link rather than sending the whole cell.

ProfileHunt's free LinkedIn URL extractor pulls every profile URL out of pasted text, CSV or HTML in canonical form, and the LinkedIn URL cleaner checks a pasted column line by line. Both run in your browser.

What Most Guides Get Wrong About Formatting Profile URLs

They strip everything to a bare username. williamhgates on its own is refused with 422. Keep the linkedin.com/in/ part; it is what makes the value a profile URL.

They URL-encode the whole URL before putting it in JSON. JSON is not a query string. https%3A%2F%2Fwww.linkedin.com%2Fin%2Fwilliamhgates is not a profile URL and gets 422. Encoding belongs only in the name, and only once.

They trust a URL because it passed validation. Trailing punctuation and double encoding both produce valid-looking URLs for the wrong name. Format checks catch shape; only cleaning catches these.

Myth vs Reality

MythReality
Country URLs like uk.linkedin.com need converting first.The API accepts country subdomains. Convert only to keep your own data consistent.
Accented names must be percent-encoded.Raw UTF-8, a JSON escape and percent-encoding all work. Only double encoding fails.
Removing ?utm_source=share changes the profile.The API accepts a query string on the URL. It is safe to keep and safe to drop.
Two different URLs mean two different people.uk.linkedin.com/in/John-Doe/ and www.linkedin.com/in/john-doe are one person.
The API's batch dedupe catches every repeat.It catches a repeated profile within one batch. Across batches, and across days, dedupe is your job.

A sieve dropping one block from each identical pair into a tray

Advanced: Normalizing for Dedupe

Dedupe before you enrich, or you pay twice for one person. The right key is the decoded profile name in lowercase, because LinkedIn treats profile names case-insensitively, so John-Doe and john-doe are one person.

Inside a single batch, ProfileHunt already marks a repeated profile as duplicate and doesn't charge it. It can't see repeats across batches or across days, so your own key covers those, and treats case variants as one person too:

// slugFromUrl is the parser from the validation guide: the encoded name, or null.
const canonicalUrl = url => {
  const slug = slugFromUrl(url)
  return slug ? `https://www.linkedin.com/in/${slug}` : null
}
const dedupeKey = url => {
  const slug = slugFromUrl(url)
  return slug ? decodeURIComponent(slug).toLowerCase() : null
}

dedupeKey("https://uk.linkedin.com/in/John-Doe/?trk=x") // "john-doe"
dedupeKey("www.linkedin.com/in/john-doe")              // "john-doe"

Four practices make this hold up in production:

  • Store three values per row: the URL as received, the canonical URL and the dedupe key. Batch results echo the URL exactly as you sent it, so the raw value is your join back to the source row.
  • Dedupe across chunks, too. Submitting URLs in bulk maps each dedupe key back to every row that shared it.
  • Dedupe across time, not only within a list. Keep a table keyed on the dedupe key with the last scraped_at, and skip people you enriched recently.
  • Treat a gone on a URL that used to work as a signal. It can mean the member changed their custom URL or hid their profile. Find the person again before deleting the record.

Where ProfileHunt Fits

ProfileHunt is a LinkedIn Profile API: public LinkedIn profile URL in, JSON out. It is forgiving about format, accepting subdomains, trailing paths and query strings, and it returns the canonical profile_url for every profile it finds. Repeats inside a batch and malformed URLs are never charged, and neither are profiles that come back gone or unavailable.

You pay only for profiles found, $0.50 per 1,000, from prepaid credits that never expire. The data is the public view, read live without a LinkedIn login. It has no emails or phone numbers, no titles for past roles, and connections stops at 500.

Getting Started

Sign in for an API key and 100 free credits with a work email. Run your URL column through the canonical form and dedupe key above, then send it with the batch API in groups of up to 100. For the fundamentals, go back to what a LinkedIn profile API is.

Frequently asked questions

What is the correct format for a LinkedIn profile URL in an API request?

https://www.linkedin.com/in/<name>, as a plain string in the JSON body: { "url": "https://www.linkedin.com/in/williamhgates" }. ProfileHunt also accepts versions without the scheme, with a country subdomain, a trailing slash or a query string.

Should I remove query parameters from LinkedIn URLs before sending them to an API?

You don't have to. ProfileHunt accepts URLs with a query string. Removing them is still a good idea for your own storage and dedupe, since it gives one value per person.

How do I send a LinkedIn URL with special characters or accents in JSON?

Put it in the JSON string as is, for example "https://www.linkedin.com/in/josé", and let your JSON library handle it. A JSON escape (\u00e9) or percent-encoding (%C3%A9) also works. Never encode it twice.

Do uk.linkedin.com and www.linkedin.com URLs point to the same profile?

Yes. The country subdomain doesn't change the profile; the name after /in/ does. ProfileHunt reads that name and returns profile_url on www.linkedin.com.

How do I remove duplicate LinkedIn URLs from a list?

Reduce each URL to its profile name after /in/, decode it, lowercase it, and keep the first row per name. The JavaScript dedupeKey above does exactly that, and the free URL cleaner does it for a pasted list.

Get API key 100 free credits with a work email