Facebook Pixel
APILinkedIn Posts

Scrape LinkedIn post details

Extract detailed information from a LinkedIn post URL including content, author, engagement metrics, and media. Uses caching to reduce API calls. Supports both authenticated and public scraping with proxy rotation for reliability. Use forceRefresh to bypass cache.

POST/posts/scrape
Authentication requiredPosts

Code Examples

curl -X POST 'https://api.connectsafely.ai/linkedin/posts/scrape' \
-H 'Authorization: Bearer <your_api_key>' \
-H 'Content-Type: application/json' \
-d '{"postUrl":"https://www.linkedin.com/posts/john-doe-123_example-post-activity-7430667226199830528-Cu89"}'

Parameters

No parameters.

Request Body

FieldTypeRequiredDescription
postUrlstringYesFull LinkedIn post URL to scrape
accountIdstringNoLinkedIn account ID for authenticated scraping (gets more data than public)
useCachebooleanNoWhether to use cached results if available
maxCacheAgenumberNoMaximum age of cached data in hours before refresh
maxProxyRetriesnumberNoNumber of proxy rotation attempts on failure
forceRefreshbooleanNoForce fresh scrape ignoring cache

Example

{
  "postUrl": "https://www.linkedin.com/posts/john-doe-123_example-post-activity-7430667226199830528-Cu89",
  "forceRefresh": false
}

Responses

StatusDescription
200Post details scraped successfully
400Bad request - Missing or invalid postUrl
401Unauthorized - Invalid or missing API key
500Server error - Failed to scrape post after all retry attempts

200 Response Parameters

NameTypeDescription
successbooleanWhether the scrape was successful
originalUrlstringOriginal URL provided in the request
finalUrlstringFinal URL after any redirects
scrapeDurationnumberTime taken to scrape in milliseconds
dataobjectScraped post data
usingAuthenticatedScrapingbooleanWhether authenticated scraping was used
messagestringSuccess message

200 Example

{
  "success": true,
  "originalUrl": "https://www.linkedin.com/posts/john-doe-123_example-post-activity-7430667226199830528-Cu89",
  "finalUrl": "https://www.linkedin.com/posts/john-doe-123_example-post-activity-7430667226199830528-Cu89",
  "scrapeDuration": 4092,
  "data": {
    "content": "This is an example post content with insights about technology and business...",
    "ugcPostUrn": "urn:li:ugcPost:7430667225633550337",
    "activityUrn": "urn:li:activity:7430667226199830528",
    "shareUrn": null,
    "featuredActivityUrn": null,
    "author": {
      "name": "John Doe",
      "headline": "Software Engineer at Tech Company",
      "profileUrl": "https://www.linkedin.com/in/john-doe-123"
    },
    "timestamp": "2d",
    "engagement": {
      "likes": 86,
      "comments": 12,
      "shares": 3
    },
    "media": {
      "hasImages": true,
      "hasVideo": false,
      "hasDocument": false,
      "hasArticle": false,
      "hasLink": true,
      "hasPoll": false
    },
    "permissions": {
      "canComment": true
    },
    "url": "https://www.linkedin.com/posts/john-doe-123_example-post-activity-7430667226199830528-Cu89",
    "scraped": true,
    "scrapedAt": "2026-02-24T12:56:58.220Z"
  },
  "usingAuthenticatedScraping": true,
  "message": "Successfully scraped post content"
}

400 Response Parameters

NameTypeDescription
successboolean
errorobject

400 Example

{
  "success": false,
  "error": {
    "issues": [
      {
        "code": "invalid_type",
        "expected": "string",
        "received": "undefined",
        "path": [
          "postUrl"
        ],
        "message": "Required"
      }
    ],
    "name": "ZodError"
  }
}

401 Response Parameters

NameTypeDescription
errorstring

401 Example

{
  "error": "Unauthorized - Invalid credentials"
}

500 Response Parameters

NameTypeDescription
errorstringError message describing the failure
successboolean
statusnumber
originalUrlstringThe URL that failed to scrape

500 Example

{
  "error": "Scraping error: Failed to scrape LinkedIn post after all attempts. Errors: Rotating proxy attempt 1: partial/no data; Rotating proxy attempt 2: partial/no data",
  "success": false,
  "status": 500,
  "originalUrl": "https://www.linkedin.com/posts/invalid-post-12345"
}