1. Tutorials
  2. How to scrape LinkedIn company page

How to scrape LinkedIn company page

Get LinkedIn company page as JSON with one request. It costs 1 credit.

Get an API key; the examples use api.socialscrape.dev.

Before you start

  • An API key, sent in the x-api-key header. Keep it on your server.
  • For this endpoint you send url. The LinkedIn company page page lists every parameter.

Step 1: Send the request

GET /v1/linkedin/company. Pick your language; each one reads the key from SOCIALSCRAPE_API_KEY.

1curl -G "https://api.socialscrape.dev/v1/linkedin/company" \2  -H "x-api-key: $SOCIALSCRAPE_API_KEY" \3  --data-urlencode 'url=https://www.linkedin.com/company/microsoft'

Step 2: Read the response

The result is in data. Here is what the object gives you, from a recorded sample.

1print(body["data"]["name"])2print(body["data"]["handle"])3print(body["data"]["stats"]["followers"])
SampleFields printed above
1{2  "name": "Microsoft",3  "handle": "microsoft",4  "stats": {5    "followers": 294021016  }7}

A field the platform does not give comes back as null. The full field list is on the endpoint page.

Step 3: Handle errors

Check ok, then branch on error.code and error.retryable, never on the message.

1body = res.json()2if not body["ok"]:3    err = body["error"]4    if err["retryable"]:5        ...  # wait a moment and send the same request again6    else:7        raise RuntimeError(f'{err["code"]}: {err["message"]}')
CodeHTTPRetryMeaning
invalid_params400noA parameter is missing, unknown or has the wrong type.
unsupported_url400noThe URL is not one this endpoint accepts (wrong platform or form).
not_found404noThe platform says this profile, post or item does not exist.

Other errors, such as unauthorized or rate_limited, are on the errors page.

With the SDK

The Python and TypeScript clients wrap all of this: typed errors, retries. Install them with pip install socialscrape-sdk or npm install socialscrape.

1from socialscrape import SocialScrape23client = SocialScrape()  # reads SOCIALSCRAPE_API_KEY45res = client.linkedin.company(url="https://www.linkedin.com/company/microsoft")6print(res.data)7print(res.credits_charged, res.credits_remaining)

What it costs

1 credit. A failed request costs nothing. Add max_age_days to reuse a cached result for 0 credits. Results are kept 30 days.

Next

Questions

Which language should I use?

Any. It is plain HTTP and JSON, so every language with an HTTP client works. The tabs show the same request nine ways.