Skip to content

Commit 2c6df38

Browse files
Profile viewers
1 parent eac854e commit 2c6df38

8 files changed

Lines changed: 70 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@linkedapi/node",
3-
"version": "2.3.8",
3+
"version": "2.3.9",
44
"description": "Control your LinkedIn accounts and retrieve real-time data, all through this Node.js SDK.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/core/operation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const OPERATION_NAME = {
2525
withdrawConnectionRequest: 'withdrawConnectionRequest',
2626
retrievePendingRequests: 'retrievePendingRequests',
2727
retrieveInvitations: 'retrieveInvitations',
28+
retrieveProfileViewers: 'retrieveProfileViewers',
2829
acceptInvitation: 'acceptInvitation',
2930
ignoreInvitation: 'ignoreInvitation',
3031
retrieveConnections: 'retrieveConnections',

src/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
RetrieveInvitations,
3131
RetrievePendingRequests,
3232
RetrievePerformance,
33+
RetrieveProfileViewers,
3334
RetrieveSSI,
3435
SearchCompanies,
3536
SearchJobs,
@@ -115,6 +116,7 @@ class LinkedApi {
115116
this.withdrawConnectionRequest = new WithdrawConnectionRequest(this.httpClient);
116117
this.retrievePendingRequests = new RetrievePendingRequests(this.httpClient);
117118
this.retrieveInvitations = new RetrieveInvitations(this.httpClient);
119+
this.retrieveProfileViewers = new RetrieveProfileViewers(this.httpClient);
118120
this.acceptInvitation = new AcceptInvitation(this.httpClient);
119121
this.ignoreInvitation = new IgnoreInvitation(this.httpClient);
120122
this.retrieveConnections = new RetrieveConnections(this.httpClient);
@@ -155,6 +157,7 @@ class LinkedApi {
155157
this.withdrawConnectionRequest,
156158
this.retrievePendingRequests,
157159
this.retrieveInvitations,
160+
this.retrieveProfileViewers,
158161
this.acceptInvitation,
159162
this.ignoreInvitation,
160163
this.retrieveConnections,
@@ -1173,6 +1176,27 @@ class LinkedApi {
11731176
*/
11741177
public retrieveInvitations: RetrieveInvitations;
11751178

1179+
/**
1180+
* Retrieve the viewers visible on the current account's LinkedIn profile analytics page.
1181+
*
1182+
* @param params - Optional maximum number of viewers to retrieve (1-300, default 20)
1183+
* @returns Promise resolving to identified and anonymous profile viewers
1184+
*
1185+
* @see {@link https://linkedapi.io/sdks/retrieve-profile-viewers/ SDK Documentation}
1186+
* @see {@link https://linkedapi.io/docs/action-st-retrieve-profile-viewers/ st.retrieveProfileViewers Action Documentation}
1187+
*
1188+
* @example
1189+
* ```typescript
1190+
* const workflow = await linkedapi.retrieveProfileViewers.execute({ limit: 50 });
1191+
* const result = await linkedapi.retrieveProfileViewers.result(workflow.workflowId);
1192+
*
1193+
* for (const viewer of result.data ?? []) {
1194+
* console.log(viewer.viewerType, viewer.viewedAgo);
1195+
* }
1196+
* ```
1197+
*/
1198+
public readonly retrieveProfileViewers: RetrieveProfileViewers;
1199+
11761200
/**
11771201
* Accept an incoming connection, company-follow, or newsletter-subscription invitation.
11781202
*

src/operations/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export * from './check-connection-status';
2424
export * from './withdraw-connection-request';
2525
export * from './retrieve-pending-requests';
2626
export * from './retrieve-invitations';
27+
export * from './retrieve-profile-viewers';
2728
export * from './accept-invitation';
2829
export * from './ignore-invitation';
2930
export * from './retrieve-connections';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Operation, TOperationName } from '../core';
2+
import { ArrayWorkflowMapper } from '../mappers/array-workflow-mapper';
3+
import { TProfileViewer, TRetrieveProfileViewersParams } from '../types';
4+
5+
export class RetrieveProfileViewers extends Operation<
6+
TRetrieveProfileViewersParams,
7+
Array<TProfileViewer>
8+
> {
9+
public override readonly operationName: TOperationName = 'retrieveProfileViewers';
10+
protected override readonly mapper = new ArrayWorkflowMapper<
11+
TRetrieveProfileViewersParams,
12+
TProfileViewer
13+
>('st.retrieveProfileViewers');
14+
}

src/types/actions/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ export * from './message';
1111
export * from './network';
1212
export * from './person';
1313
export * from './post';
14+
export * from './profile-viewer.type';
1415
export * from './retrieve-feed-params.type';
1516
export * from './retrieve-invitations-result.type';
17+
export * from './retrieve-profile-viewers-params.type';
1618
export * from './search-companies';
1719
export * from './search-people';
1820
export * from './statistics';
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
interface TProfileViewerBase {
2+
viewedAt: string | null;
3+
viewedAgo: string | null;
4+
}
5+
6+
interface TIdentifiedProfileViewer extends TProfileViewerBase {
7+
viewerType: 'identified';
8+
name: string;
9+
publicUrl: string;
10+
urn: string | null;
11+
headline: string | null;
12+
connectionDegree: 1 | 2 | 3 | null;
13+
avatarUrl: string | null;
14+
}
15+
16+
interface TAnonymousProfileViewer extends TProfileViewerBase {
17+
viewerType: 'anonymous';
18+
description: string;
19+
searchUrl: string;
20+
}
21+
22+
export type TProfileViewer = TIdentifiedProfileViewer | TAnonymousProfileViewer;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type { TLimitParams } from '../params';
2+
3+
export interface TRetrieveProfileViewersParams extends TLimitParams {
4+
since?: string;
5+
}

0 commit comments

Comments
 (0)