Skip to content

Commit 011edab

Browse files
update search with viewerState & connection degrees filter
1 parent e0a9767 commit 011edab

10 files changed

Lines changed: 97 additions & 6 deletions

File tree

‎linkedapi/errors.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
"connectionNotFound",
1818
"searchingNotAllowed",
1919
"searchInterfaceMismatch",
20-
"filterIdentityMismatch",
20+
"filterNotApplied",
2121
"companyNotFound",
2222
"postNotFound",
2323
"jobNotFound",
2424
"commentingNotAllowed",
2525
"commentNotFound",
2626
"replyingNotAllowed",
27+
"duplicateComment",
2728
"noPostingPermission",
2829
"mentionNotResolved",
2930
"repostNotAllowed",
@@ -47,13 +48,14 @@
4748
"connectionNotFound",
4849
"searchingNotAllowed",
4950
"searchInterfaceMismatch",
50-
"filterIdentityMismatch",
51+
"filterNotApplied",
5152
"companyNotFound",
5253
"postNotFound",
5354
"jobNotFound",
5455
"commentingNotAllowed",
5556
"commentNotFound",
5657
"replyingNotAllowed",
58+
"duplicateComment",
5759
"noPostingPermission",
5860
"mentionNotResolved",
5961
"repostNotAllowed",

‎linkedapi/types/__init__.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
CommentOnPostParams,
157157
CommentOnPostResult,
158158
CommentResult,
159+
ContentViewerState,
159160
CreatePostAttachment,
160161
CreatePostParams,
161162
CreatePostResult,
@@ -167,6 +168,7 @@
167168
PostActorType,
168169
PostAuthor,
169170
PostComment,
171+
PostCommentAuthor,
170172
PostCommenterType,
171173
PostCommentsRetrievalConfig,
172174
PostCommentsSort,
@@ -231,6 +233,11 @@
231233
RetrievePerformanceResult,
232234
RetrieveSSIResult,
233235
)
236+
from linkedapi.types.viewer_state import (
237+
ConnectionDegree,
238+
NvConnectionDegreeFilter,
239+
PersonViewerState,
240+
)
234241
from linkedapi.types.webhooks import (
235242
AccountWebhookEvent,
236243
AccountWebhookEventData,
@@ -300,11 +307,13 @@
300307
"CommentOnPostResult",
301308
"CommentResult",
302309
"Company",
310+
"ConnectionDegree",
303311
"ConnectionPerson",
304312
"ConnectionSession",
305313
"ConnectionSessionResult",
306314
"ConnectionSessionStatus",
307315
"ConnectionStatus",
316+
"ContentViewerState",
308317
"ConversationPollRequest",
309318
"ConversationPollResult",
310319
"ConversationType",
@@ -381,6 +390,7 @@
381390
"NvCompanyEmployee",
382391
"NvCompanyEmployeeFilter",
383392
"NvCompanyEmployeeRetrievalConfig",
393+
"NvConnectionDegreeFilter",
384394
"NvFetchCompanyParams",
385395
"NvFetchCompanyResult",
386396
"NvManageConversationParams",
@@ -402,10 +412,12 @@
402412
"PersonExperience",
403413
"PersonLanguage",
404414
"PersonSkill",
415+
"PersonViewerState",
405416
"Post",
406417
"PostActorType",
407418
"PostAuthor",
408419
"PostComment",
420+
"PostCommentAuthor",
409421
"PostCommenterType",
410422
"PostCommentsRetrievalConfig",
411423
"PostCommentsSort",

‎linkedapi/types/company.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
from linkedapi.types.params import BaseActionParams, LimitParams, LimitSinceParams
99
from linkedapi.types.person import YearsOfExperience
1010
from linkedapi.types.post import Post
11+
from linkedapi.types.viewer_state import (
12+
ConnectionDegree,
13+
NvConnectionDegreeFilter,
14+
PersonViewerState,
15+
)
1116

1217

1318
class StCompanyEmployee(LinkedApiModel):
@@ -17,6 +22,7 @@ class StCompanyEmployee(LinkedApiModel):
1722
headline: str | None = None
1823
location: str | None = None
1924
avatar_url: str | None = None
25+
viewer_state: PersonViewerState | None = None
2026

2127

2228
class StCompanyDm(LinkedApiModel):
@@ -27,6 +33,7 @@ class StCompanyDm(LinkedApiModel):
2733
location: str | None = None
2834
avatar_url: str | None = None
2935
country_code: str | None = None
36+
viewer_state: PersonViewerState | None = None
3037

3138

3239
class Company(LinkedApiModel):
@@ -69,6 +76,7 @@ class StCompanyEmployeesFilter(LinkedApiModel):
6976
locations: list[str] | None = None
7077
industries: list[str] | None = None
7178
schools: list[str] | None = None
79+
connection_degrees: list[ConnectionDegree] | None = None
7280

7381

7482
class StCompanyEmployeesRetrievalConfig(LimitParams):
@@ -91,6 +99,7 @@ class NvCompanyEmployee(LinkedApiModel):
9199
position: str | None = None
92100
location: str | None = None
93101
avatar_url: str | None = None
102+
viewer_state: PersonViewerState | None = None
94103

95104

96105
class NvCompanyDm(LinkedApiModel):
@@ -101,6 +110,7 @@ class NvCompanyDm(LinkedApiModel):
101110
location: str | None = None
102111
avatar_url: str | None = None
103112
country_code: str | None = None
113+
viewer_state: PersonViewerState | None = None
104114

105115

106116
class NvCompany(LinkedApiModel):
@@ -138,6 +148,7 @@ class NvCompanyEmployeeFilter(LinkedApiModel):
138148
industries: list[str] | None = None
139149
schools: list[str] | None = None
140150
years_of_experiences: list[YearsOfExperience] | None = None
151+
connection_degrees: list[NvConnectionDegreeFilter] | None = None
141152

142153

143154
class NvCompanyEmployeeRetrievalConfig(LimitParams):

‎linkedapi/types/person.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from linkedapi.types.params import BaseActionParams, LimitSinceParams
66
from linkedapi.types.post import Comment, Post, Reaction
7+
from linkedapi.types.viewer_state import PersonViewerState
78

89
EmploymentType = Literal[
910
"fullTime",
@@ -95,6 +96,7 @@ class Person(BaseActionParams):
9596
followers_count: int | None = None
9697
about: str | None = None
9798
avatar_url: str | None = None
99+
viewer_state: PersonViewerState | None = None
98100
experiences: list[PersonExperience] | None = None
99101
education: list[PersonEducation] | None = None
100102
skills: list[PersonSkill] | None = None

‎linkedapi/types/post.py‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from linkedapi.types.base import LinkedApiModel
66
from linkedapi.types.params import BaseActionParams, LimitParams
7+
from linkedapi.types.viewer_state import PersonViewerState
78

89
PostType = Literal["original", "repost"]
910
PostActorType = Literal["person", "company"]
@@ -14,6 +15,18 @@
1415
AttachmentType = Literal["image", "video", "document"]
1516

1617

18+
class ContentViewerState(LinkedApiModel):
19+
"""What your account has done with a post or a comment.
20+
21+
"reaction" is None if you have not reacted or the page does not show it; comments read in the
22+
feed always report None. "is_own" is None if this cannot be told; content published as a
23+
company page you administer is False.
24+
"""
25+
26+
reaction: ReactionType | None = None
27+
is_own: bool | None = None
28+
29+
1730
class Reaction(LinkedApiModel):
1831
post_url: str | None = None
1932
time: str | None = None
@@ -69,9 +82,22 @@ class ReplyToCommentParams(BaseActionParams):
6982
ReplyToCommentResult: TypeAlias = CommentResult
7083

7184

85+
class PostCommentAuthor(LinkedApiModel):
86+
"""The commenter in the same actor shape a post's author has."""
87+
88+
type: PostActorType | None = None
89+
name: str | None = None
90+
profile_url: str | None = None
91+
headline: str | None = None
92+
company_url: str | None = None
93+
viewer_state: PersonViewerState | None = None
94+
95+
7296
class PostComment(LinkedApiModel):
7397
comment_urn: str | None = None
7498
comment_url: str | None = None
99+
author: PostCommentAuthor | None = None
100+
# Deprecated: use "author" instead of the four commenter_* fields.
75101
commenter_url: str | None = None
76102
commenter_name: str | None = None
77103
commenter_headline: str | None = None
@@ -82,6 +108,7 @@ class PostComment(LinkedApiModel):
82108
is_reply: bool | None = None
83109
reactions_count: int | None = None
84110
replies_count: int | None = None
111+
viewer_state: ContentViewerState | None = None
85112

86113

87114
class PostReaction(LinkedApiModel):
@@ -100,8 +127,11 @@ class PostAuthor(LinkedApiModel):
100127
profile_url: str | None = None
101128
headline: str | None = None
102129
company_url: str | None = None
130+
# Set for a person author only.
131+
viewer_state: PersonViewerState | None = None
103132

104133

134+
# A reposter carries no viewer_state: only the author's relation to your account is reported.
105135
class PostReposter(LinkedApiModel):
106136
type: PostActorType | None = None
107137
name: str | None = None
@@ -131,6 +161,7 @@ class Post(LinkedApiModel):
131161
reactions_count: int | None = None
132162
comments_count: int | None = None
133163
reposts_count: int | None = None
164+
viewer_state: ContentViewerState | None = None
134165
comments: list[PostComment] | None = None
135166
reactions: list[PostReaction] | None = None
136167

‎linkedapi/types/search_people.py‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
from linkedapi.types.base import LinkedApiModel
44
from linkedapi.types.params import BaseActionParams, LimitParams
55
from linkedapi.types.person import YearsOfExperience
6+
from linkedapi.types.viewer_state import (
7+
ConnectionDegree,
8+
NvConnectionDegreeFilter,
9+
PersonViewerState,
10+
)
611

712

813
class SearchPeopleFilter(LinkedApiModel):
@@ -14,6 +19,7 @@ class SearchPeopleFilter(LinkedApiModel):
1419
current_companies: list[str] | None = None
1520
previous_companies: list[str] | None = None
1621
schools: list[str] | None = None
22+
connection_degrees: list[ConnectionDegree] | None = None
1723

1824

1925
class SearchPeopleParams(BaseActionParams, LimitParams):
@@ -29,10 +35,12 @@ class SearchPeopleResult(LinkedApiModel):
2935
headline: str | None = None
3036
location: str | None = None
3137
avatar_url: str | None = None
38+
viewer_state: PersonViewerState | None = None
3239

3340

3441
class NvSearchPeopleFilter(SearchPeopleFilter):
35-
years_of_experience: list[YearsOfExperience] | None = None
42+
years_of_experiences: list[YearsOfExperience] | None = None
43+
connection_degrees: list[NvConnectionDegreeFilter] | None = None # type: ignore[assignment]
3644

3745

3846
class NvSearchPeopleParams(BaseActionParams, LimitParams):
@@ -48,3 +56,4 @@ class NvSearchPeopleResult(LinkedApiModel):
4856
position: str | None = None
4957
location: str | None = None
5058
avatar_url: str | None = None
59+
viewer_state: PersonViewerState | None = None

‎linkedapi/types/search_posts.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
from linkedapi.types.base import LinkedApiModel
66
from linkedapi.types.params import BaseActionParams, LimitParams
7-
from linkedapi.types.post import PostActorType, PostType
7+
from linkedapi.types.post import ContentViewerState, PostActorType, PostType
8+
from linkedapi.types.viewer_state import PersonViewerState
89

910
PostSearchSort = Literal["topMatch", "latest"]
1011
PostSearchDatePosted = Literal["past24Hours", "pastWeek", "pastMonth"]
@@ -78,6 +79,8 @@ class SearchPostActor(LinkedApiModel):
7879
profile_url: str | None = None
7980
headline: str | None = None
8081
company_url: str | None = None
82+
# Set for a person author only; a reposter carries none.
83+
viewer_state: PersonViewerState | None = None
8184

8285

8386
class SearchPostResult(LinkedApiModel):
@@ -101,3 +104,4 @@ class SearchPostResult(LinkedApiModel):
101104
reactions_count: int | None = None
102105
comments_count: int | None = None
103106
reposts_count: int | None = None
107+
viewer_state: ContentViewerState | None = None

‎linkedapi/types/viewer_state.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from __future__ import annotations
2+
3+
from typing import Literal
4+
5+
from linkedapi.types.base import LinkedApiModel
6+
7+
# Your connection degree to a person, as LinkedIn shows it next to their name.
8+
ConnectionDegree = Literal["1st", "2nd", "3rd+"]
9+
# Sales Navigator also filters by members of the groups you belong to.
10+
NvConnectionDegreeFilter = Literal["1st", "2nd", "3rd+", "groupMembers"]
11+
12+
13+
class PersonViewerState(LinkedApiModel):
14+
"""How your account relates to a person.
15+
16+
"connection_degree" is None when LinkedIn shows no degree, e.g. on your own content.
17+
"""
18+
19+
connection_degree: ConnectionDegree | None = None

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "linkedapi"
7-
version = "1.4.0"
7+
version = "1.4.1"
88
description = "Official synchronous Python SDK for Linked API."
99
readme = "README.md"
1010
requires-python = ">=3.10"

‎tests/test_errors.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,14 @@ def test_error_type_sets_match_node_contract() -> None:
4646
"connectionNotFound",
4747
"searchingNotAllowed",
4848
"searchInterfaceMismatch",
49-
"filterIdentityMismatch",
49+
"filterNotApplied",
5050
"companyNotFound",
5151
"postNotFound",
5252
"jobNotFound",
5353
"commentingNotAllowed",
5454
"commentNotFound",
5555
"replyingNotAllowed",
56+
"duplicateComment",
5657
"noPostingPermission",
5758
"mentionNotResolved",
5859
"repostNotAllowed",

0 commit comments

Comments
 (0)