Get comments from a post
curl --request GET \
--url https://api.fetchin.io/api/v1/post/comments \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.fetchin.io/api/v1/post/comments"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.fetchin.io/api/v1/post/comments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.fetchin.io/api/v1/post/comments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.fetchin.io/api/v1/post/comments"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.fetchin.io/api/v1/post/comments")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fetchin.io/api/v1/post/comments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"comments": [
{
"urn": "urn:li:comment:(ugcPost:7287782484287606784,7287957733851484162)",
"text": "Great post! Thanks for sharing.",
"createdAt": "2024-01-22T14:22:07.458Z",
"reactionCount": 5,
"author": {
"id": "urn:li:fsd_profile:ACoAABCDEFG",
"name": "Jane Doe",
"headline": "Software Engineer at Tech Company",
"profilePictureUrl": "https://media.licdn.com/dms/image/...",
"profileUrl": "https://www.linkedin.com/in/janedoe"
},
"replies": [
{
"urn": "urn:li:comment:(ugcPost:7287782484287606784,7287960123456789012)",
"text": "Totally agree with you!",
"createdAt": "2024-01-22T14:35:00.000Z",
"reactionCount": 2,
"author": {
"id": "urn:li:fsd_profile:ACoAAHIJKLM",
"name": "John Smith",
"headline": "Product Manager",
"profilePictureUrl": "https://media.licdn.com/dms/image/...",
"profileUrl": "https://www.linkedin.com/in/johnsmith"
},
"replies": []
}
]
},
{
"urn": "urn:li:comment:(ugcPost:7287782484287606784,7287958844962595073)",
"text": "Very insightful perspective!",
"createdAt": "2024-01-22T14:25:30.000Z",
"reactionCount": 3,
"author": {
"id": "urn:li:fsd_profile:ACoAANOPQRS",
"name": "Alice Johnson",
"headline": "Marketing Director",
"profilePictureUrl": "https://media.licdn.com/dms/image/...",
"profileUrl": "https://www.linkedin.com/in/alicejohnson"
},
"replies": []
}
],
"paginationToken": "MTAtMTcwNjAwMDAwMDAwMA==",
"hasMore": true
}
{
"error": "Missing postUrlOrUrn parameter",
"code": "MISSING_PARAMETER"
}
{
"error": "Invalid API key",
"code": "INVALID_API_KEY"
}
{
"error": "Unable to find post from url",
"code": "POST_NOT_FOUND"
}
{
"error": "Quota exceeded. Upgrade your plan or wait for renewal.",
"code": "QUOTA_EXHAUSTED"
}
{
"error": "Internal server error",
"code": "INTERNAL_ERROR"
}
{
"error": "Service temporarily unable to serve this request. Please retry.",
"code": "SERVICE_UNAVAILABLE"
}
Posts
Get Post Comments
Fetch comments from a professional post with author information and replies
GET
/
api
/
v1
/
post
/
comments
Get comments from a post
curl --request GET \
--url https://api.fetchin.io/api/v1/post/comments \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.fetchin.io/api/v1/post/comments"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.fetchin.io/api/v1/post/comments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.fetchin.io/api/v1/post/comments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.fetchin.io/api/v1/post/comments"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.fetchin.io/api/v1/post/comments")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fetchin.io/api/v1/post/comments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"comments": [
{
"urn": "urn:li:comment:(ugcPost:7287782484287606784,7287957733851484162)",
"text": "Great post! Thanks for sharing.",
"createdAt": "2024-01-22T14:22:07.458Z",
"reactionCount": 5,
"author": {
"id": "urn:li:fsd_profile:ACoAABCDEFG",
"name": "Jane Doe",
"headline": "Software Engineer at Tech Company",
"profilePictureUrl": "https://media.licdn.com/dms/image/...",
"profileUrl": "https://www.linkedin.com/in/janedoe"
},
"replies": [
{
"urn": "urn:li:comment:(ugcPost:7287782484287606784,7287960123456789012)",
"text": "Totally agree with you!",
"createdAt": "2024-01-22T14:35:00.000Z",
"reactionCount": 2,
"author": {
"id": "urn:li:fsd_profile:ACoAAHIJKLM",
"name": "John Smith",
"headline": "Product Manager",
"profilePictureUrl": "https://media.licdn.com/dms/image/...",
"profileUrl": "https://www.linkedin.com/in/johnsmith"
},
"replies": []
}
]
},
{
"urn": "urn:li:comment:(ugcPost:7287782484287606784,7287958844962595073)",
"text": "Very insightful perspective!",
"createdAt": "2024-01-22T14:25:30.000Z",
"reactionCount": 3,
"author": {
"id": "urn:li:fsd_profile:ACoAANOPQRS",
"name": "Alice Johnson",
"headline": "Marketing Director",
"profilePictureUrl": "https://media.licdn.com/dms/image/...",
"profileUrl": "https://www.linkedin.com/in/alicejohnson"
},
"replies": []
}
],
"paginationToken": "MTAtMTcwNjAwMDAwMDAwMA==",
"hasMore": true
}
{
"error": "Missing postUrlOrUrn parameter",
"code": "MISSING_PARAMETER"
}
{
"error": "Invalid API key",
"code": "INVALID_API_KEY"
}
{
"error": "Unable to find post from url",
"code": "POST_NOT_FOUND"
}
{
"error": "Quota exceeded. Upgrade your plan or wait for renewal.",
"code": "QUOTA_EXHAUSTED"
}
{
"error": "Internal server error",
"code": "INTERNAL_ERROR"
}
{
"error": "Service temporarily unable to serve this request. Please retry.",
"code": "SERVICE_UNAVAILABLE"
}
Endpoint
GET /api/v1/post/comments
Authentication
Include your API key in the request header:X-API-Key: your-api-key-here
Parameters
string
required
Professional post URL or URN.Examples:
https://www.linkedin.com/posts/username_some-post-slug-1234567890-abcdurn:li:activity:7287782484287606784urn:li:ugcPost:7287782484287606784
integer
default:"100"
Number of comments to fetch per page.
- Minimum: 1
- Maximum: 100
- Default: 100
integer
default:"0"
Offset of the first comment to return. This is how you page this endpoint:
advance
start by the number of comments you received.- Default: 0
string
Returned for continuity with the other endpoints. It does not advance this
thread — page with
start.Response
array
Array of professional comments
Show Comment object
Show Comment object
string
Unique comment identifier
string
Comment text content
string
ISO 8601 timestamp of when the comment was posted
integer
Number of reactions on the comment
object
required
Information about the comment author
Show Author object
Show Author object
array
Array of reply comments (subcomments). Each reply has the same structure as a comment, but with an empty replies array.
string
Token for fetching the next page of comments. Only present when more comments are available.
boolean
Indicates whether there are more comments to fetch.
Example Request
curl -X GET "https://api.fetchin.io/api/v1/post/comments?postUrlOrUrn=urn:li:ugcPost:7287782484287606784&count=10" \
-H "X-API-Key: your-api-key-here"
const response = await fetch(
'https://api.fetchin.io/api/v1/post/comments?postUrlOrUrn=urn:li:ugcPost:7287782484287606784&count=10',
{
headers: {
'X-API-Key': 'your-api-key-here'
}
}
);
const data = await response.json();
console.log(data);
import requests
headers = {
'X-API-Key': 'your-api-key-here'
}
params = {
'postUrlOrUrn': 'urn:li:ugcPost:7287782484287606784',
'count': 10
}
response = requests.get(
'https://api.fetchin.io/api/v1/post/comments',
headers=headers,
params=params
)
data = response.json()
print(data)
<?php
$apiKey = 'your-api-key-here';
$postUrlOrUrn = 'urn:li:ugcPost:7287782484287606784';
$count = 10;
$url = "https://api.fetchin.io/api/v1/post/comments?postUrlOrUrn=" . urlencode($postUrlOrUrn) . "&count=" . $count;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-API-Key: ' . $apiKey
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
print_r($data);
?>
Example Response
{
"comments": [
{
"urn": "urn:li:comment:(ugcPost:7287782484287606784,7287957733851484162)",
"text": "Great post! Thanks for sharing.",
"createdAt": "2024-01-22T14:22:07.458Z",
"reactionCount": 5,
"author": {
"id": "urn:li:fsd_profile:ACoAABCDEFG",
"name": "Jane Doe",
"headline": "Software Engineer at Tech Company",
"profilePictureUrl": "https://media.licdn.com/dms/image/...",
"profileUrl": "https://www.linkedin.com/in/janedoe"
},
"replies": [
{
"urn": "urn:li:comment:(ugcPost:7287782484287606784,7287960123456789012)",
"text": "Totally agree with you!",
"createdAt": "2024-01-22T14:35:00.000Z",
"reactionCount": 2,
"author": {
"id": "urn:li:fsd_profile:ACoAAHIJKLM",
"name": "John Smith",
"headline": "Product Manager",
"profilePictureUrl": "https://media.licdn.com/dms/image/...",
"profileUrl": "https://www.linkedin.com/in/johnsmith"
},
"replies": []
}
]
},
{
"urn": "urn:li:comment:(ugcPost:7287782484287606784,7287958844962595073)",
"text": "Very insightful perspective!",
"createdAt": "2024-01-22T14:25:30.000Z",
"reactionCount": 3,
"author": {
"id": "urn:li:fsd_profile:ACoAANOPQRS",
"name": "Alice Johnson",
"headline": "Marketing Director",
"profilePictureUrl": "https://media.licdn.com/dms/image/...",
"profileUrl": "https://www.linkedin.com/in/alicejohnson"
},
"replies": []
}
],
"paginationToken": "MTAtMTcwNjAwMDAwMDAwMA==",
"hasMore": true
}
{
"error": "Missing postUrlOrUrn parameter",
"code": "MISSING_PARAMETER"
}
{
"error": "Invalid API key",
"code": "INVALID_API_KEY"
}
{
"error": "Unable to find post from url",
"code": "POST_NOT_FOUND"
}
{
"error": "Quota exceeded. Upgrade your plan or wait for renewal.",
"code": "QUOTA_EXHAUSTED"
}
{
"error": "Internal server error",
"code": "INTERNAL_ERROR"
}
{
"error": "Service temporarily unable to serve this request. Please retry.",
"code": "SERVICE_UNAVAILABLE"
}
Errors
See Error Handling for the full list of error codes and recommended handling.400—MISSING_PARAMETER/INVALID_URN401—INVALID_API_KEY404—POST_NOT_FOUND402—QUOTA_EXHAUSTED429—RATE_LIMITED500—INTERNAL_ERROR503—SERVICE_UNAVAILABLE
Pagination
This endpoint pages by offset:- Make an initial request with
start=0 - If
hasMoreistrue, add the number of comments you received tostart - Continue until
hasMoreisfalseor a page comes back empty
count and still not be the last one — the first
page of a busy thread often returns a handful of comments while hundreds remain.
Trust hasMore, not the number of items returned.
async function fetchAllComments(postUrlOrUrn) {
const allComments = [];
let start = 0;
let hasMore = true;
while (hasMore) {
const params = new URLSearchParams({
postUrlOrUrn,
count: '100',
start: String(start),
});
const response = await fetch(
`https://api.fetchin.io/api/v1/post/comments?${params}`,
{ headers: { 'X-API-Key': 'your-api-key-here' } }
);
const data = await response.json();
if (data.comments.length === 0) break;
allComments.push(...data.comments);
start += data.comments.length;
hasMore = data.hasMore;
}
return allComments;
}
Notes
This endpoint consumes 1 credit from your monthly quota per API call, regardless of the
count parameter value.Comments are returned in relevance order by default. Each comment includes its replies (subcomments) nested within.
Use the
paginationToken to efficiently paginate through large comment sections without re-fetching already retrieved comments.Authorizations
Query Parameters
Professional post URL or URN
Example:
"https://www.linkedin.com/posts/username_post-slug-1234567890-abcd"
Number of comments to fetch (default: 100)
Required range:
1 <= x <= 100Offset of the first item to return. This endpoint pages by offset: advance start by the number of items you received. Keep requesting while hasMore is true; an empty page ends the list.
Required range:
x >= 0Token for fetching the next page of comments