JavaScriptలో LinkedIn ప్రొఫైల్ API రెస్పాన్స్ను పార్స్ చేయడానికి ముందు దానికి టైప్ ఇవ్వండి, తర్వాత మూడు విషయాలను స్పష్టంగా హ్యాండిల్ చేయండి: null విలువలు, [] జాబితాలు, LinkedIn యొక్క రెండు తేదీ ఫార్మాట్లు ("2014", "2014-02"). ProfileHuntలో ప్రతి key ఎప్పుడూ ఉంటుంది, కాబట్టి key ఉందో లేదో ఎప్పుడూ చెక్ చేయనక్కర్లేదు; దాని విలువ null అవునో కాదో చెక్ చేస్తారు. ఈ గైడ్లో పూర్తి TypeScript టైప్లు, తేదీలు, ప్రస్తుత రోల్ కోసం helper ఫంక్షన్లు, ఒక ప్రొఫైల్ను ఒకే టేబుల్ రోగా ఫ్లాట్ చేసే ఫంక్షన్ ఉన్నాయి.
డేటా ఎక్కడి నుండి వస్తుందో LinkedIn ప్రొఫైల్ API పరిచయం వివరిస్తుంది; JSON మీ చేతికి వచ్చాక ఈ పోస్ట్ మొదలవుతుంది.
ముఖ్యాంశాలు
- రెస్పాన్స్ను
statusపై unionగా టైప్ చేయండి.status === "ok"తర్వాతprofilenullకాదని TypeScriptకు తెలుస్తుంది. ?.,??వాడండి,inఎప్పుడూ వాడకండి. keys ఎప్పుడూ మాయం కావు; విలువలుnullకావచ్చు, జాబితాలు ఖాళీగా ఉండవచ్చు.- రోల్, స్కూల్ తేదీలు strings, timestamps కావు.
"2014","2014-02"రెండూ వస్తాయి;new Date("2014")లేని జనవరి 1ని సృష్టిస్తుంది. - ప్రస్తుత రోల్ అంటే
end_date === nullఉన్నది. అలాంటివి చాలా ఉండవచ్చు, పబ్లిక్ వ్యూలో గత రోల్స్కుtitleఉండదు.
రెస్పాన్స్ కోసం TypeScript టైప్లు
ఈ టైప్లు ప్రొఫైల్ ఎండ్పాయింట్ రిఫరెన్స్ను, ProfileHunt హోమ్ పేజీలోని నమూనా రెస్పాన్స్లను అనుసరిస్తాయి. వీటిని profilehunt.ts ఫైల్లో పేస్ట్ చేయండి:
export type Position = {
company: string;
company_url: string | null;
title: string | null; // current roles only
location: string | null;
description: string | null;
start_date: string | null; // "2014" or "2014-02"
end_date: string | null; // null = current role
};
export type School = {
school: string;
school_url: string | null;
start_date: string | null;
end_date: string | null;
};
export type Post = {
url: string;
posted_at: string; // ISO 8601 UTC
text: string | null;
likes: number | null;
};
export type Article = {
url: string;
headline: string | null;
image_url: string | null;
published_at: string; // ISO 8601 UTC
likes: number | null;
};
export type Reaction = {
verb: string; // the kind of reaction, as LinkedIn labels it
reacted_at: string; // ISO 8601 UTC
post_url: string | null;
post_author: string | null; // profile name from the post URL
post_at: string | null;
};
export type Comment = {
verb: string; // "commented on a post" or "replied to a comment"
text: string | null;
age: string; // as LinkedIn shows it: "5h", "3d", "2w", "4mo", "1y"
commented_at: string | null; // approximate: age counted back from scraped_at
post_url: string | null;
post_author: string | null;
post_at: string | null; // exact
};
export type Profile = {
public_id: string;
profile_url: string;
full_name: string | null;
first_name: string | null;
last_name: string | null;
photo_url: string | null;
headline: string | null;
about: string | null;
location: string | null;
country: string | null; // two-letter code, e.g. "US"
experience: Position[];
education: School[];
languages: string[];
followers: number | null;
connections: number | null; // 500 means 500 or more
creator: boolean;
badges: string[];
last_post_at: string | null;
recent_posts: Post[];
recent_articles: Article[];
last_reaction_at: string | null;
recent_reactions: Reaction[];
last_comment_at: string | null; // approximate, like commented_at
recent_comments: Comment[];
last_active_at: string | null; // newest of last_post_at, last_reaction_at, last_comment_at
scraped_at: string; // ISO 8601 UTC
};
export type ProfileResult =
| { status: "ok"; profile: Profile }
| { status: "gone" | "unavailable"; profile: null };
API తిరిగి ఇచ్చే ప్రతి key ఇదే. ఎప్పుడూ పోస్ట్ చేయని వ్యక్తులకు కూడా రియాక్షన్, కామెంట్ keys యాక్టివిటీని చూపిస్తాయి; LinkedIn 4w వంటి వయసును మాత్రమే చూపిస్తుంది కాబట్టి commented_at సుమారు విలువ, అయితే reacted_at, post_at కచ్చితమైనవి. ప్రతి ఫీల్డ్పై వివరణ ప్రొఫైల్ రిఫరెన్స్లో ఉంది.
ProfileResult పొందడానికి Node.js నుండి LinkedIn ప్రొఫైల్ API కాల్లో చూపినట్లు రిక్వెస్ట్ పంపి, పార్స్ చేసిన బాడీని cast చేయండి: const result = (await res.json()) as ProfileResult.

ఇబ్బంది పెట్టే ఫీల్డ్లను పార్స్ చేయడం
ప్రొఫైల్ పార్సింగ్లో చాలా బగ్లు నాలుగు చోట్ల నుండి వస్తాయి: null విలువలు, తేదీలు, ప్రస్తుత రోల్, పరిమితి ఉన్న సంఖ్యలు. ఒక్కోదానికి ఒక చిన్న పరిష్కారం ఉంది.
Null విలువలు, ఖాళీ జాబితాలు
ప్రొఫైల్ బహిరంగంగా చూపించని విలువ null; ఏమీ లేని జాబితా []. కాబట్టి profile.experience.length ఎప్పుడూ సురక్షితం, profile.experience[0] undefined కావచ్చు.
const name = profile.full_name ?? profile.public_id;
const firstSchool = profile.education[0]?.school ?? null;
const postCount = profile.recent_posts.length;
if ("headline" in profile) అని రాయకండి. అది ఎప్పుడూ true, కాబట్టి అసలు ప్రశ్నను దాచేస్తుంది: headline null అవునా కాదా.
సంవత్సరం vs సంవత్సరం-నెల తేదీలు
రోల్స్, స్కూల్స్పై ఉండే start_date, end_date LinkedIn చూపించేవే: Gates Foundationలో Bill Gatesకు "2000", Microsoftలో Satya Nadellaకు "2014-02". వీటిని Dateగా కాకుండా భాగాలుగా పార్స్ చేయండి:
export function parseYearMonth(d: string | null) {
if (!d) return null;
const [year, month] = d.split("-").map(Number);
return { year, month: month ?? null }; // month is 1-12 or null
}
new Date("2014") జనవరి 1, 2014 అర్ధరాత్రి UTCని ఇస్తుంది, ప్రొఫైల్ ఎప్పుడూ చెప్పని కచ్చితత్వం అది. month: null అలాగే ఉంచి, ప్రతి use caseకు విడిగా నిర్ణయించండి, ఉదాహరణకు పదవీకాల అంచనాలకు "సంవత్సరం మధ్యలో అనుకోండి". timestamps (posted_at, published_at, reacted_at, last_post_at, last_active_at, scraped_at మిగిలినవి) UTCలో పూర్తి ISO 8601 strings, కాబట్టి వాటికి new Date(value) సరైనదే.
ముడి stringsను sort చేయడం పనిచేస్తుంది: సాధారణ string పోలికలో "2014" < "2014-02" < "2015".
ప్రస్తుత రోల్
ప్రస్తుత రోల్కు end_date: null ఉంటుంది. పబ్లిక్ వ్యూ కూడా ప్రస్తుత రోల్స్కు మాత్రమే title చూపిస్తుంది; గత రోల్స్ title: nullతో వస్తాయి.
export function currentRoles(p: Profile) {
return p.experience.filter(e => e.end_date === null);
}
export const currentRole = (p: Profile) => currentRoles(p)[0] ?? null;
Satya Nadella నమూనా ప్రొఫైల్లో రెండు ప్రస్తుత రోల్స్ ఉన్నాయి: "2014-02" నుండి Microsoftలో Chairman and CEO, "2018" నుండి University of Chicagoలో Member Board Of Trustees. currentRole మొదటిదాన్ని తీసుకుంటుంది, ఎందుకంటే experience ప్రొఫైల్ చూపించే క్రమాన్ని పాటిస్తుంది. మీకు "యజమాని సంస్థ" కావాలంటే సాధారణంగా అదే సరైనది; ప్రతి అనుబంధం కావాలంటే currentRoles వాడండి.
పరిమితి ఉన్న, తక్కువ సంఖ్యలు
connectionsకు పరిమితి ఉంది: 500 దాటితే లాగ్ అవుట్ అయిన సందర్శకులకు LinkedIn "500+" చూపిస్తుంది, కాబట్టి 500 అంటే 500 లేదా అంతకంటే ఎక్కువ. దాన్ని "500+"గా చూపించండి. తక్కువ సంఖ్యలు కూడా నిజమైనవే: Bill Gates నమూనాలో followers: 40725248 పక్కన connections: 8 ఉంది. రీచ్ కోసం followers వాడండి.
const connectionsLabel = (n: number | null) => (n === null ? "" : n >= 500 ? "500+" : String(n));

ప్రొఫైల్ను ఒకే టేబుల్ రోగా ఫ్లాట్ చేయడం
స్ప్రెడ్షీట్లు, CSV ఫైల్లు, SQL టేబుల్స్కు ఒక వ్యక్తికి ఒక ఫ్లాట్ రో కావాలి. మీకు కావాల్సిన కాలమ్లను ఎంచుకుని, మిగిలినవాటిని derive చేయండి:
export function toRow(p: Profile) {
const role = currentRole(p);
return {
public_id: p.public_id,
full_name: p.full_name ?? "",
headline: p.headline ?? "",
location: p.location ?? "",
country: p.country ?? "",
current_company: role?.company ?? "",
current_title: role?.title ?? "",
current_since: role?.start_date ?? "",
latest_school: p.education[0]?.school ?? "",
followers: p.followers ?? "",
connections: connectionsLabel(p.connections),
last_post_at: p.last_post_at ?? "",
scraped_at: p.scraped_at,
};
}
Satya Nadella నమూనాపై console.table([toRow(profile)]) రన్ చేస్తే:
| కాలమ్ | విలువ |
|---|---|
full_name | Satya Nadella |
headline | Chairman and CEO at Microsoft |
location | Redmond, Washington, United States |
current_company | Microsoft |
current_title | Chairman and CEO |
current_since | 2014-02 |
latest_school | The University of Chicago Booth School of Business |
followers | 12222008 |
connections | 500+ |
last_post_at | 2026-10-12T13:03:00.729Z |
ముడి JSONను ఫ్లాట్ రో పక్కనే ఉంచండి (ఒక jsonb కాలమ్ లేదా JSONL ఫైల్). రో చదవడానికి, ఫిల్టర్ చేయడానికి; ప్రొఫైల్ను మళ్లీ తెచ్చుకోకుండానే తర్వాత కొత్త కాలమ్ జోడించడానికి JSON ఉపయోగపడుతుంది. జాబితా లోపలికి, ఫైల్ బయటికి వచ్చే పూర్తి స్క్రిప్ట్ కోసం Node.js ఎన్రిచ్మెంట్ వర్క్ఫ్లో చూడండి.
చాలా గైడ్లు ఎక్కడ పొరపడతాయి
ప్రతి ఫీల్డ్ను optionalగా మోడల్ చేస్తాయి. headline?: string అని రాస్తే key లేకపోవచ్చని TypeScriptకు చెప్పినట్టు, కానీ అది ఎప్పుడూ లేకుండా పోదు. headline: string | null కచ్చితమైనది, కంపైలర్ సరైన ప్రశ్న అడిగేలా చేస్తుంది.
ప్రతి తేదీని new Date()తో పార్స్ చేస్తాయి. అది "2014"ను కచ్చితమైన timestampగా మార్చి, నిజానికి కచ్చితం కాని పదవీకాల లెక్కలను కచ్చితంగా కనిపించేలా చేస్తుంది.
experience[0]ను ప్రస్తుత ఉద్యోగంగా తీసుకుంటాయి. అది జాబితాలోని మొదటి రోల్ మాత్రమే, అది ముగిసి ఉండవచ్చు. ముందుగా end_date === nullపై ఫిల్టర్ చేయండి.
అపోహ vs వాస్తవం
| అపోహ | వాస్తవం |
|---|---|
| "TypeScript టైప్లు API రెస్పాన్స్ను ధృవీకరిస్తాయి." | రన్టైమ్లో టైప్లు మాయమవుతాయి. as ProfileResult మీరు ఇచ్చే హామీ మాత్రమే; దాన్ని అమలు చేసేది రన్టైమ్ చెక్. |
"ఖాళీ experience అంటే ఆ వ్యక్తికి ఉద్యోగం లేదని." | పబ్లిక్ వ్యూ ఏ రోల్స్నూ చూపించడం లేదని అర్థం. చాలా మంది సభ్యులు లాగ్ అవుట్ అయిన సందర్శకుల నుండి వివరాలను దాచుకుంటారు. |
"పాత రోల్పై title: null పార్సింగ్ బగ్." | పబ్లిక్ వ్యూలో గత రోల్స్కు టైటిల్స్ ఉండవు. null సరైన విలువే. |
"connections: 500 అంటే సరిగ్గా 500." | 500 లేదా అంతకంటే ఎక్కువ అని అర్థం. |
అడ్వాన్స్డ్: రన్టైమ్ చెక్లు, జనరేట్ చేసిన టైప్లు
ఒక సర్వీస్కు చేతితో రాసిన టైప్లు సరిపోతాయి. చాలా సర్వీస్లు ఒకే డేటాను వాడుతున్నప్పుడు రెండు మెరుగుదలలు సహాయపడతాయి.
OpenAPI spec నుండి టైప్లను జనరేట్ చేయండి. ProfileHunt తన స్కీమాను /openapi.jsonలో ప్రచురిస్తుంది, అందులో Profile, Position, School, Post, Article, Reaction, Comment పేరున్న స్కీమాలుగా ఉంటాయి. openapi-typescript వంటి జనరేటర్ దాన్ని టైప్లుగా మారుస్తుంది, కాబట్టి మళ్లీ జనరేట్ చేసినప్పుడు కొత్త ఫీల్డ్ మీ ఎడిటర్లో కనిపిస్తుంది.
సరిహద్దు వద్ద చెక్ చేయండి, లోపల నమ్మండి. JSON మీ సిస్టమ్లోకి ప్రవేశించే చోట ఒక్కసారి ధృవీకరించండి: APIని కాల్ చేసే ఫంక్షన్లో, లేదా భద్రపరచిన JSONను తిరిగి చదివే చోట. ఇంత చిన్న guard కూడా చాలా ఆశ్చర్యాలను పట్టుకుంటుంది:
function isProfileResult(x: any): x is ProfileResult {
return (x?.status === "ok" && typeof x.profile?.public_id === "string")
|| ((x?.status === "gone" || x?.status === "unavailable") && x.profile === null);
}
Zod వంటి స్కీమా లైబ్రరీ ఫీల్డ్ స్థాయి ఎర్రర్లతో అదే చెక్ ఇస్తుంది. ఏ పద్ధతి అయినా, సరిహద్దు దాటిన ప్రతిదీ టైప్లపై ఆధారపడవచ్చు.
ProfileHunt ఎక్కడ సరిపోతుంది
ProfileHunt ఒక LinkedIn ప్రొఫైల్ API: పబ్లిక్ LinkedIn ప్రొఫైల్ URL లోపలికి, JSON బయటికి, ప్రతి రెస్పాన్స్లో అవే keys. ఆ స్థిరత్వం వల్లే పై పార్సింగ్ చిన్నదిగా ఉంది: key చెక్లు లేవు, ఒకే null నియమం, ఒకే తేదీ నియమం.
దొరికిన ప్రతి ప్రొఫైల్కు ఒక క్రెడిట్, 1,000 ప్రొఫైల్లకు $0.50, gone లేదా unavailableకు ఏమీ లేదు. ఇది పబ్లిక్ వ్యూని మాత్రమే అందిస్తుంది, కాబట్టి ఈమెయిల్లు, ఫోన్ నంబర్లు, గత రోల్స్కు టైటిల్స్ ఉండవు, connections 500 వద్ద పరిమితమవుతుంది.
ప్రారంభించడం
- profilehunt.dev/loginలో సైన్ ఇన్ చేయండి: వర్క్ ఈమెయిల్తో 100 ఉచిత క్రెడిట్లు, వ్యక్తిగత ఈమెయిల్తో 10.
- ఒక ప్రొఫైల్ను తెచ్చి, JSONను ఫైల్లో సేవ్ చేయండి.
- పై టైప్లను పేస్ట్ చేసి, దానిపై
toRowరన్ చేసి, LinkedIn ప్రొఫైల్ JSON స్కీమాతో పోల్చండి. Pythonలో పనిచేస్తున్నారా? Pythonతో ప్రొఫైల్ JSON పార్సింగ్ చూడండి.
API అంటే ఏమిటి, అది ఏం కవర్ చేస్తుందో తెలుసుకోవడానికి LinkedIn ప్రొఫైల్ API పరిచయంకు తిరిగి వెళ్లండి.
తరచుగా అడిగే ప్రశ్నలు
LinkedIn ప్రొఫైల్ JSON నుండి ఒకరి ప్రస్తుత ఉద్యోగాన్ని ఎలా పొందాలి?
experienceలో end_date === null ఉన్న ఎంట్రీలను ఫిల్టర్ చేయండి. వాటిలో మొదటిది ప్రొఫైల్లో మొదట చూపిన రోల్; ఒకటి కంటే ఎక్కువ ప్రస్తుత రోల్స్ ఉండవచ్చు.
LinkedIn API రెస్పాన్స్లో గత ఉద్యోగాలకు టైటిల్ null ఎందుకు?
LinkedIn పబ్లిక్ ప్రొఫైల్ వ్యూ గత రోల్స్కు టైటిల్స్ చూపించదు, కాబట్టి ProfileHunt వాటికి title: null ఇస్తుంది. కంపెనీ, తేదీలు మాత్రం ఉంటాయి.
"2014-02" వంటి LinkedIn తేదీలను JavaScript Dateగా ఎలా మార్చాలి?
new Date() కాల్ చేయకుండా - దగ్గర విభజించి సంవత్సరం, ఐచ్ఛిక నెలగా తీసుకోండి. Date తప్పనిసరిగా కావాలంటే, రోజును మీరే ఎంచుకోండి, ఉదాహరణకు new Date(Date.UTC(year, (month ?? 1) - 1, 1)), ప్రొఫైల్ సంవత్సరం లేదా సంవత్సరం-నెల మాత్రమే ఇచ్చిందని గుర్తుంచుకోండి.
LinkedIn ప్రొఫైల్ APIకి TypeScript టైప్లు ఉన్నాయా?
ఈ పోస్ట్లోని టైప్లను కాపీ చేసుకోవచ్చు, లేదా openapi-typescript వంటి టూల్తో /openapi.jsonలోని ProfileHunt OpenAPI spec నుండి జనరేట్ చేయవచ్చు.
JavaScriptలో LinkedIn ప్రొఫైల్ JSONను CSVగా ఎలా మార్చాలి?
ప్రతి ప్రొఫైల్ను strings, సంఖ్యలతో కూడిన ఒక ఆబ్జెక్ట్గా ఫ్లాట్ చేయండి (పేరు, హెడ్లైన్, ప్రస్తుత కంపెనీ, followers), తర్వాత ఒక్కో ఆబ్జెక్ట్కు ఒక లైన్ రాయండి, కామాలు లేదా కోట్స్ ఉన్న విలువలను కోట్స్లో పెట్టండి.


