Get Member Profile

Gets another member's profile, given its person id. [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, personId: string) {
7
	// This API will only return data for members who have not limited their off-LinkedIn visibility.
8
	const endpoint = `https://api.linkedin.com/rest/people/(id:${personId})`
9

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

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

23
	const data = await response.json()
24

25
	return data
26
}
27