Skip to content

Commit a05f416

Browse files
committed
Account info method added
1 parent 22b7685 commit a05f416

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

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": "1.2.14",
3+
"version": "1.2.15",
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/index.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
import {
3232
HttpClient,
3333
LinkedApiError,
34+
TAccountInfo,
3435
TApiUsageAction,
3536
TApiUsageParams,
3637
TConversationPollRequest,
@@ -1040,6 +1041,35 @@ class LinkedApi {
10401041
*/
10411042
public retrievePerformance: RetrievePerformance;
10421043

1044+
/**
1045+
* Retrieve basic information about the LinkedIn account associated with the current API tokens.
1046+
*
1047+
* This method validates the tokens and returns the account name and LinkedIn profile URL.
1048+
* Use this to verify credentials or display account information.
1049+
*
1050+
* @returns Promise resolving to account info (name and url)
1051+
*
1052+
* @example
1053+
* ```typescript
1054+
* const accountInfo = await linkedapi.getAccountInfo();
1055+
* console.log("Account:", accountInfo.data?.name);
1056+
* console.log("URL:", accountInfo.data?.url);
1057+
* ```
1058+
*/
1059+
public async getAccountInfo(): Promise<TMappedResponse<TAccountInfo>> {
1060+
const response = await this.httpClient.get<TAccountInfo>('/account');
1061+
if (response.success && response.result) {
1062+
return {
1063+
data: response.result,
1064+
errors: [],
1065+
};
1066+
}
1067+
throw new LinkedApiError(
1068+
response.error?.type as TLinkedApiErrorType,
1069+
response.error?.message ?? '',
1070+
);
1071+
}
1072+
10431073
/**
10441074
* Retrieve Linked API usage statistics for a specific time period.
10451075
*

src/types/actions/account.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface TAccountInfo {
2+
name: string;
3+
url: string;
4+
}

src/types/actions/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from './account';
12
export * from './company';
23
export * from './connection';
34
export * from './message';

0 commit comments

Comments
 (0)