> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fetchin.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Post Comments

> Fetch comments from a professional post with author information and replies

## Endpoint

```
GET /api/v1/post/comments
```

## Authentication

Include your API key in the request header:

```bash theme={null}
X-API-Key: your-api-key-here
```

## Parameters

<ParamField query="postUrlOrUrn" type="string" required>
  Professional post URL or URN.

  Examples:

  * `https://www.linkedin.com/posts/username_some-post-slug-1234567890-abcd`
  * `urn:li:activity:7287782484287606784`
  * `urn:li:ugcPost:7287782484287606784`
</ParamField>

<ParamField query="count" type="integer" default="100">
  Number of comments to fetch per page.

  * Minimum: 1
  * Maximum: 100
  * Default: 100
</ParamField>

<ParamField query="start" type="integer" default="0">
  Offset for pagination.

  * Default: 0
</ParamField>

<ParamField query="paginationToken" type="string">
  Token for fetching the next page of comments. Returned from previous request when more comments are available.
</ParamField>

## Response

<ResponseField name="comments" type="array">
  Array of professional comments

  <Expandable title="Comment object">
    <ResponseField name="urn" type="string">
      Unique comment identifier
    </ResponseField>

    <ResponseField name="text" type="string">
      Comment text content
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      ISO 8601 timestamp of when the comment was posted
    </ResponseField>

    <ResponseField name="reactionCount" type="integer">
      Number of reactions on the comment
    </ResponseField>

    <ResponseField name="author" type="object" required>
      Information about the comment author

      <Expandable title="Author object">
        <ResponseField name="id" type="string" required>
          Professional profile URN of the comment author
        </ResponseField>

        <ResponseField name="name" type="string" required>
          Full name of the comment author
        </ResponseField>

        <ResponseField name="headline" type="string" required>
          Professional headline of the comment author
        </ResponseField>

        <ResponseField name="profilePictureUrl" type="string" required>
          Profile picture URL of the comment author
        </ResponseField>

        <ResponseField name="profileUrl" type="string" required>
          Professional profile URL of the comment author
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="replies" type="array">
      Array of reply comments (subcomments). Each reply has the same structure as a comment, but with an empty replies array.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="paginationToken" type="string">
  Token for fetching the next page of comments. Only present when more comments are available.
</ResponseField>

<ResponseField name="hasMore" type="boolean">
  Indicates whether there are more comments to fetch.
</ResponseField>

## Example Request

<CodeGroup>
  ```bash cURL theme={null}
  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"
  ```

  ```javascript JavaScript theme={null}
  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);
  ```

  ```python Python theme={null}
  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 PHP theme={null}
  <?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);
  ?>
  ```
</CodeGroup>

## Example Response

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "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
  }
  ```

  ```json 400 Bad Request theme={null}
  {
    "error": "Missing postUrlOrUrn parameter",
    "code": "MISSING_PARAMETER"
  }
  ```

  ```json 401 Unauthorized theme={null}
  {
    "error": "Invalid API key",
    "code": "INVALID_API_KEY"
  }
  ```

  ```json 404 Not Found theme={null}
  {
    "error": "Unable to find post from url",
    "code": "POST_NOT_FOUND"
  }
  ```

  ```json 402 Payment Required theme={null}
  {
    "error": "Quota exceeded. Upgrade your plan or wait for renewal.",
    "code": "QUOTA_EXHAUSTED"
  }
  ```

  ```json 500 Internal Server Error theme={null}
  {
    "error": "Internal server error",
    "code": "INTERNAL_ERROR"
  }
  ```

  ```json 503 Service Unavailable theme={null}
  {
    "error": "Service temporarily unable to serve this request. Please retry.",
    "code": "SERVICE_UNAVAILABLE"
  }
  ```
</ResponseExample>

## Errors

See [Error Handling](/concepts/error-handling) for the full list of error codes and recommended handling.

* `400` — `MISSING_PARAMETER` / `INVALID_URN`
* `401` — `INVALID_API_KEY`
* `404` — `POST_NOT_FOUND`
* `402` — `QUOTA_EXHAUSTED`
* `429` — `RATE_LIMITED`
* `500` — `INTERNAL_ERROR`
* `503` — `SERVICE_UNAVAILABLE`

## Pagination

To fetch all comments from a post with many comments, use pagination:

1. Make an initial request without `paginationToken`
2. If `hasMore` is `true`, use the returned `paginationToken` in your next request
3. Continue until `hasMore` is `false`

```javascript theme={null}
async function fetchAllComments(postUrlOrUrn) {
  const allComments = [];
  let paginationToken = null;
  let hasMore = true;

  while (hasMore) {
    const params = new URLSearchParams({ postUrlOrUrn, count: '100' });
    if (paginationToken) {
      params.set('paginationToken', paginationToken);
    }

    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();
    allComments.push(...data.comments);
    paginationToken = data.paginationToken;
    hasMore = data.hasMore;
  }

  return allComments;
}
```

## Notes

<Info>
  This endpoint consumes 1 credit from your monthly quota per API call, regardless of the `count` parameter value.
</Info>

<Warning>
  Comments are returned in relevance order by default. Each comment includes its replies (subcomments) nested within.
</Warning>

<Tip>
  Use the `paginationToken` to efficiently paginate through large comment sections without re-fetching already retrieved comments.
</Tip>


## OpenAPI

````yaml GET /api/v1/post/comments
openapi: 3.1.0
info:
  title: Fetchin API
  version: 1.0.0
  description: Public B2B data API for fetching posts and profile information
servers:
  - url: https://api.fetchin.io
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /api/v1/post/comments:
    get:
      summary: Get comments from a post
      description: >-
        Fetch comments from a professional post including author information and
        replies (subcomments)
      parameters:
        - name: postUrlOrUrn
          in: query
          required: true
          description: Professional post URL or URN
          schema:
            type: string
            example: https://www.linkedin.com/posts/username_post-slug-1234567890-abcd
        - name: count
          in: query
          required: false
          description: 'Number of comments to fetch (default: 100)'
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 100
        - name: start
          in: query
          required: false
          description: 'Offset for pagination (default: 0)'
          schema:
            type: integer
            minimum: 0
            default: 0
        - name: paginationToken
          in: query
          required: false
          description: Token for fetching the next page of comments
          schema:
            type: string
      responses:
        '200':
          description: Successfully fetched comments
          content:
            application/json:
              schema:
                type: object
                properties:
                  comments:
                    type: array
                    items:
                      type: object
                      properties:
                        urn:
                          type: string
                          example: >-
                            urn:li:comment:(ugcPost:7287782484287606784,7287957733851484162)
                        text:
                          type: string
                          example: Great post! Thanks for sharing.
                        createdAt:
                          type: string
                          format: date-time
                        reactionCount:
                          type: integer
                        author:
                          type: object
                          required:
                            - id
                            - name
                            - headline
                            - profilePictureUrl
                            - profileUrl
                          properties:
                            id:
                              type: string
                              example: urn:li:fsd_profile:ACoAABCDEFG
                            name:
                              type: string
                              example: Jane Doe
                            headline:
                              type: string
                              example: Software Engineer at Tech Company
                            profilePictureUrl:
                              type: string
                              example: https://media.licdn.com/dms/image/...
                            profileUrl:
                              type: string
                              example: https://www.linkedin.com/in/janedoe
                        replies:
                          type: array
                          description: Array of reply comments (subcomments)
                          items:
                            type: object
                            properties:
                              urn:
                                type: string
                              text:
                                type: string
                              createdAt:
                                type: string
                                format: date-time
                              reactionCount:
                                type: integer
                              author:
                                type: object
                                properties:
                                  id:
                                    type: string
                                  name:
                                    type: string
                                  headline:
                                    type: string
                                  profilePictureUrl:
                                    type: string
                                  profileUrl:
                                    type: string
                              replies:
                                type: array
                                items: {}
                  paginationToken:
                    type: string
                    description: Token for fetching the next page
                  hasMore:
                    type: boolean
                    description: Whether more comments are available
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalError'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
components:
  responses:
    BadRequest:
      description: Bad request - a required parameter is missing or a value is invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            missingParameter:
              value:
                error: Missing profileUrlOrUrn parameter
                code: MISSING_PARAMETER
            invalidParameter:
              value:
                error: limit must be a number between 1 and 100
                code: INVALID_PARAMETER
            invalidUrn:
              value:
                error: 'Invalid URN format: foo'
                code: INVALID_URN
    Unauthorized:
      description: Unauthorized - the X-API-Key header is missing or invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            missingApiKey:
              value:
                error: Missing API key. Include X-API-Key header.
                code: UNAUTHENTICATED
            invalidApiKey:
              value:
                error: Invalid API key
                code: INVALID_API_KEY
    PaymentRequired:
      description: >-
        Payment required - your monthly credit quota is exhausted
        (QUOTA_EXHAUSTED). Upgrade your plan or wait for renewal; retrying will
        not help and no Retry-After is sent. Distinct from the per-second rate
        limit, which is a 429 (RATE_LIMITED).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            quotaExhausted:
              value:
                error: Quota exceeded. Upgrade your plan or wait for renewal.
                code: QUOTA_EXHAUSTED
    NotFound:
      description: >-
        Not found - the request was served successfully but the requested
        professional entity does not exist.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            profileNotFound:
              value:
                error: LinkedIn profile not found
                code: PROFILE_NOT_FOUND
            postNotFound:
              value:
                error: Unable to find post from url
                code: POST_NOT_FOUND
            companyNotFound:
              value:
                error: Unable to find company slug from urn
                code: COMPANY_NOT_FOUND
    TooManyRequests:
      description: >-
        Too many requests - your per-second rate limit (RATE_LIMITED) was
        exceeded. Back off and retry, honoring the Retry-After header. (Monthly
        credit quota exhaustion is a separate 402 PaymentRequired /
        QUOTA_EXHAUSTED.)
      headers:
        Retry-After:
          description: Number of seconds to wait before retrying the request.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            rateLimited:
              value:
                error: Rate limit exceeded. Try again later.
                code: RATE_LIMITED
    InternalError:
      description: >-
        Internal server error - an unexpected error occurred in our API. Safe to
        retry; contact support if it persists.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            internalError:
              value:
                error: Internal server error
                code: INTERNAL_ERROR
    ServiceUnavailable:
      description: >-
        Service unavailable - our API is temporarily unable to serve this
        request (capacity exhausted or overloaded). This is on our side, not
        yours and not an upstream service outage. Retry with backoff, honoring
        the Retry-After header.
      headers:
        Retry-After:
          description: Number of seconds to wait before retrying the request.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            serviceUnavailable:
              value:
                error: >-
                  Service temporarily unable to serve this request. Please
                  retry.
                code: SERVICE_UNAVAILABLE
  schemas:
    Error:
      type: object
      required:
        - error
        - code
      properties:
        error:
          type: string
          description: >-
            Human-readable description of what went wrong. For display/logging;
            do not branch on this string.
        code:
          type: string
          enum:
            - MISSING_PARAMETER
            - INVALID_PARAMETER
            - INVALID_URN
            - UNAUTHENTICATED
            - INVALID_API_KEY
            - FORBIDDEN
            - NOT_FOUND
            - PROFILE_NOT_FOUND
            - POST_NOT_FOUND
            - COMPANY_NOT_FOUND
            - RATE_LIMITED
            - QUOTA_EXHAUSTED
            - INTERNAL_ERROR
            - UPSTREAM_ERROR
            - SERVICE_UNAVAILABLE
            - UPSTREAM_TIMEOUT
          description: >-
            Stable, machine-readable error code. Branch your integration on this
            value, not on the HTTP status alone or the message text.
        details:
          type: object
          additionalProperties: true
          description: Optional structured context (e.g. creditsNeeded on quota errors).
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

````