Get Multiple Member Profiles

Gets multiple member profiles at once. [See the docs here](https://docs.microsoft.com/en-us/linkedin/shared/integrations/people/profile-api#retrieve-other-members-profile)

Script linkedin Verified

by hugo697 ยท 7/17/2024

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 689 days ago
1
type Linkedin = {
2
	token: string
3
	apiVersion: string
4
}
5

6
export async function main(resource: Linkedin, personIdList: string[]) {
7
	const personIdUrl = personIdList.map((id) => `(id:${id})`).join(',')
8

9
	// https://api.linkedin.com/rest/people?ids=List((id:{Person ID1}),(id:{Person ID2}),(id:{Person ID3}))
10
	const endpoint = `https://api.linkedin.com/rest/people?ids=List(${personIdUrl})`
11

12
	const response = await fetch(endpoint, {
13
		method: 'GET',
14
		headers: {
15
			Authorization: `Bearer ${resource.token}`,
16
			'LinkedIn-Version': `${resource.apiVersion}`,
17
			'X-Restli-Protocol-Version': '2.0.0'
18
		}
19
	})
20

21
	if (!response.ok) {
22
		throw new Error(`HTTP error! status: ${response.status}`)
23
	}
24

25
	const data = await response.json()
26

27
	return data
28
}
29