Pre-Black Friday: 20% off, for as long as you stayEARLYBFon Solo and AgencyEnds Nov 28Start free

How-to guide

How to Enrich a List of LinkedIn URLs (in TypeScript)

One TypeScript file that reads URLs, calls the enrich endpoint, backs off on 429 and writes the results to a CSV.

Get your free API key →Free to start. No credit card. 1,000 records to spend whenever you like.

You can enrich a list of LinkedIn URLs in TypeScript with one file and no packages: read the URLs, call POST /v1/people/enrich for each, wait out any 429, and write a CSV. This guide gives you that file and explains each part.

TL;DR

  • One TypeScript file, 39 lines, no dependencies beyond Node 22. It reads urls.txt and writes people.csv.
  • Time: about 10 minutes to set up. At 4 requests a second, 1,000 URLs take roughly 4 minutes.
  • Cost: 1 LeadOcean record per URL we hold a match for. A miss is a 404 and is free, so the Free plan's 1,000 records cover up to 1,000 matches.

Prerequisites

  • Node 22.7 or newer (it runs .ts files with --experimental-strip-types, and fetch is built in).
  • A LeadOcean API key, exported as $LEADOCEAN_API_KEY. The Free plan gives you one with 1,000 records for life, no card.
  • A urls.txt file with one LinkedIn profile URL per line.

Step 1: Get a key and prepare the list

Sign up at app.leadocean.io, create a key and put it in your shell. Never write the key into the source file.

bash
export LEADOCEAN_API_KEY="your-key-here"
printf '%s\n' \
  "https://www.linkedin.com/in/jane-doe-acme" \
  "https://www.linkedin.com/in/john-roe-acme" > urls.txt

The enrich endpoint takes exactly one identifier per call: linkedin_url, email, phone or person_id. Enrich does not page. You make one call per URL, so "paging" here means walking your file line by line.

Step 2: Write the TypeScript

Save this as enrich.ts. Requests go to https://api.leadocean.io with the x-api-key header.

ts
import { readFileSync, writeFileSync } from "node:fs";

const key = process.env.LEADOCEAN_API_KEY ?? "";
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
const cell = (s: string) => `"${s.replaceAll('"', '""')}"`;

async function enrich(url: string): Promise<[number, string]> {
  for (let attempt = 0; attempt < 5; attempt++) {
    try {
      const res = await fetch("https://api.leadocean.io/v1/people/enrich", {
        method: "POST",
        headers: { "x-api-key": key, "content-type": "application/json" },
        body: JSON.stringify({ linkedin_url: url, reveal_email: true }),
      });
      if (res.status === 429) {
        const wait = Number(res.headers.get("retry-after")) || 1;
        await sleep(wait * 1000);
        continue;
      }
      return [res.status, await res.text()];
    } catch {
      await sleep(1000);
    }
  }
  return [0, "gave up after 5 tries"];
}

const urls = readFileSync("urls.txt", "utf8")
  .split("\n")
  .map((u) => u.trim())
  .filter(Boolean);
const rows = ["linkedin_url,status,json"];
for (const url of urls) {
  const [status, body] = await enrich(url);
  rows.push([cell(url), status, cell(body)].join(","));
  await sleep(250);
}
writeFileSync("people.csv", rows.join("\n") + "\n");
console.log(`wrote ${rows.length - 1} rows to people.csv`);

Three choices in that file matter:

  • reveal_email: true returns the contact points on the record. It adds no extra record.
  • The 250 ms pause keeps you at 4 requests a second, under the Free plan's limit of 5.
  • On a 429 the code reads Retry-After, sleeps that many seconds, and tries again, up to 5 times. See API rate limits and 429 errors.

Step 3: Run it

bash
node --experimental-strip-types enrich.ts
head -3 people.csv

The status column tells you what happened per URL: 200 is a match, 404 is nobody found. Filter on it before you load rows anywhere else. Rows are written once at the end, so a crash loses the run. For long lists, append to the file inside the loop instead.

Step 4: Parse the fields you need

The CSV stores the raw JSON so you lose nothing. When you know which fields you want, JSON.parse the body. The current role is in contact_current_experiences[] and phones are in contact_phones[].phone. Since October 2026 the same call also returns career history in resume_data: past roles, education, certifications and awards.

Past employers carry no company_id yet. If you need a company record, call POST /v1/companies/enrich with the domain.

What you get

The response shape from the API reference, with placeholder values. This is not a real person.

json
{
  "success": true,
  "data": {
    "profile_data": { "...": "name, headline, location" },
    "contact_data": { "...": "present because reveal_email was true" },
    "resume_data": { "...": "experiences[], educations[], certifications[]" }
  },
  "meta": { "source": "leadocean" }
}

Source: response shape from the API reference (openapi.json, October 2026). Each record also carries a fetched_at date, and the dataset refreshes monthly.

Troubleshooting

ErrorCauseFix
401Missing or wrong x-api-key, or $LEADOCEAN_API_KEY is empty in this shellRe-export the key and check with echo ${#LEADOCEAN_API_KEY}
429You sent faster than the plan allows: 5 a second on Free, 200 on AgencyRaise the sleep, or rely on the Retry-After retry in the code
402The records are spent. Free is 1,000 for lifeStop the run and upgrade. Paid plans slow at their pace instead of returning 402
404No person matched that URL. It is freeKeep the row, mark it unmatched, move on

FAQ

Can I run the calls in parallel?

Yes, with a small worker pool. Keep the total under your plan's per-account limit: 5 requests a second on Free, 50 on Solo, 200 on Agency. Sequential is fine below about 10,000 URLs.

Does a URL with no match use a record?

No. A person we hold nothing for is a 404 and costs nothing. Only a match returns a record.

Should I use GET or POST?

Both work on /v1/people/enrich. POST with a JSON body avoids URL-encoding the LinkedIn address. Skip the deprecated /v1/people/enrich alias.

What if I have more than 10,000 URLs?

Run the same loop in batches and write each batch to its own file. Paid plans have a fair-use pace instead of credits, and reaching it slows the key rather than stopping it.

Is there a bulk option?

Not for a list of URLs. POST /v1/exports builds a CSV from search filters, not from identifiers you supply. It takes up to 50,000 rows a request and 500,000 a day, and it is not on Free. It starts on Solo at $97 a month.

See the same recipe in Go, C# and Rust.

For the no-code version of this lookup, see LinkedIn to email.

Enrich your first 1,000 LinkedIn URLs free

Free to start. No credit card. 1,000 records to spend whenever you like.

Get your free API key →