100 free credits. No credit card required. Get a key

How to scrape TikTok comment with PHP

One TikTok comment by id, with its current likes and reply count.

The examples use PHP’s curl extension and json_decode(..., true), so the response is a plain associative array. No Composer packages needed.

GET /v1/tiktok/videos/{id}/comments/{comment_id}2 credits per callRefunded on failure

Before you start

  1. Get an API keySign up for 100 free credits, no card. Keys start with gs_live_.
  2. Put it in the environmentEvery example reads it from GROUNDSOCIAL_API_KEY: export GROUNDSOCIAL_API_KEY=gs_live_…
  3. Set up PHPphp -m | grep curl # the curl extension ships with most PHP builds

Call TikTok comment API from PHP

GET /v1/tiktok/videos/{id}/comments/{comment_id}. Save this as main.php and run php main.php. It prints comment.text and comment.digg_count.

main.php
<?php

function groundsocial(string $path, array $params = []): array
{
    $url = 'https://api.groundsocial.dev' . $path . ($params ? '?' . http_build_query($params) : '');
    $ch = curl_init($url);
    curl_setopt_array($ch, [
        CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('GROUNDSOCIAL_API_KEY')],
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_TIMEOUT => 60,
    ]);
    $raw = curl_exec($ch);
    $status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
    curl_close($ch);
    $data = json_decode($raw, true);
    if ($status !== 200) {
        $e = $data['error'];
        throw new RuntimeException($e['code'] . ': ' . ($e['hint'] ?? $e['message']));
    }
    return $data;
}

$data = groundsocial('/v1/tiktok/videos/7707446852798549279/comments/7707556469470167839', []);

echo $data['comment']['text'], ' ', $data['comment']['digg_count'], PHP_EOL;

The response

A real TikTok response to this call, recorded from the live source and shortened for display: arrays keep their first items and … marks every cut. Live calls return current data in the same shape.

200 OK
{
  "comment": {
    "cid": "7707556469470167839",
    "aweme_id": "7707446852798549279",
    "text": "this with broccoli 😻",
    "create_time": 1794555420,
    "digg_count": 5269,
    "reply_comment_total": 6,
    "reply_id": "0",
    "user": {
      "uid": "6925204018239423494",
      "unique_id": "neiaiko",
      "nickname": "️",
      "sec_uid": "MS4wLjABAAAAEo1OPo8CphE2eSfko8lzW0EfSFPmJBGkkYNI7RlwtaKZyZ0_luvXgJmxhYAGrfbM",
      "account_labels": null,
      "ad_cover_url": null,
      "advance_feature_item_order": null,
      "advanced_feature_info": null,
      "avatar_thumb": {
        "uri": "tos-useast8-avt-0068-tx2/ed7196c0669bb6debe0de857aec546ad",
        "url_list": [
          "https://p19-common-sign.tiktokcdn-us.com/tos-useast8-avt-0068-tx2/ed7196c0669bb6debe0de857aec546ad~tplv-tiktokx-cropcent…",
          "https://p16-common-sign.tiktokcdn-us.com/tos-useast8-avt-0068-tx2/ed7196c0669bb6debe0de857aec546ad~tplv-tiktokx-cropcent…",
          "… 1 more"
        ],
        "url_prefix": null
      },
      "bold_fields": null,
      "can_message_follow_status_list": null,
      "can_set_geofencing": null,
      "cha_list": null,
      "cover_url": null,
      "custom_verify": "",
      "enterprise_verify_reason": "",
      "events": null,
      "followers_detail": null,
      "geofencing": null,
      "homepage_bottom_toast": null,
      "item_list": null,
      "mutual_relation_avatars": null,
      "need_points": null,
      "platform_sync_info": null,
      "…": "8 more fields"
    },
    "comment_language": "en",
    "is_author_digged": true,
    "author_pin": false,
    "allow_download_photo": true,
    "collect_stat": 0,
    "comment_post_item_ids": null,
    "content_type": 1,
    "fold_status": -1,
    "image_list": null,
    "is_comment_translatable": true,
    "is_high_purchase_intent": false,
    "label_list": [
      {
        "text": "Liked by creator",
        "type": 20
      }
    ],
    "no_show": false,
    "reply_comment": [
      {
        "allow_download_photo": true,
        "author_pin": false,
        "aweme_id": "7707446852798549279",
        "cid": "7707639744872497951",
        "collect_stat": 0,
        "comment_language": "en",
        "comment_post_item_ids": null,
        "content_type": 1,
        "create_time": 1794574801,
        "digg_count": 1689,
        "fold_status": 0,
        "image_list": null,
        "is_author_digged": false,
        "is_comment_translatable": true,
        "is_high_purchase_intent": false,
        "label_list": [
          {
            "text": "Creator",
            "type": 1
          }
        ],
        "label_text": "Creator",
        "label_type": 1,
        "no_show": false,
        "reply_comment": null,
        "reply_id": "7707556469470167839",
        "reply_to_reply_id": "0",
        "seeking_help_model_type": 0,
        "service_id": "-1",
        "…": "14 more fields"
      }
    ],
    "reply_to_reply_id": "0",
    "seeking_help_model_type": 0,
    "…": "15 more fields"
  },
  "pagesScanned": 1
}

Top-level fields

FieldTypeDescription
commentTikTokCommentA comment, in the shape of TikTok’s comment API.
pagesScannednumber–

Parameters

NameInTypeDescription
id (required)pathstringA video (or photo post) id, or its URL (www.tiktok.com/@user/video/<id>). Example: 7707446852798549279.
comment_id (required)pathstringThe comment’s cid. Example: 7707556469470167839.
parent_comment_idquerystringFor a reply: the cid of the comment it replies to.

Errors and retries

Every error is JSON with error.code (stable: branch on it), message, hint (what to do next), docs_url and retryable. A failed call is never charged. Retry only when retryable is true, after the Retry-After header.

Errors
try {
    $data = groundsocial('/v1/tiktok/videos/7707446852798549279/comments/7707556469470167839', []);
} catch (RuntimeException $e) {
    // "code: hint", e.g. "target_not_found: ..." (never charged).
    fwrite(STDERR, $e->getMessage() . PHP_EOL);
    exit(1);
}
StatusMeaning
200The comment.
400Invalid input. Nothing was charged.
401Missing or invalid API key.
402Not enough credits, a spend cap was reached, or payment is required.
403The target is private, or the account is suspended.
404The account, video, comment, hashtag or sound does not exist on TikTok, or was removed.
429Too many requests. Wait for Retry-After seconds.
503TikTok is temporarily unavailable. Retryable; nothing was charged.

Every error code and what to do about it.

Pricing

Cost
Per call2 credits per call
1,000 calls$2.00 on the starter pack, $0.80 at volume
No key (MPP or x402)$0.02 per call
Failed callRefunded, never charged

Every response has x-credits-charged and x-credits-remaining headers. Credits never expire. Packs and calculator.

From an AI agent (MCP)

The same call is the tiktok_comment_get tool on the hosted MCP server, so Claude, Cursor or any MCP client can make it without code. Add the server once:

bash
claude mcp add --transport http groundsocial https://api.groundsocial.dev/mcp

Then ask for it in words (“One TikTok comment by id, with its current likes and replies”), or call the tool directly:

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "tiktok_comment_get",
    "arguments": {
      "id": "7707446852798549279",
      "comment_id": "7707556469470167839"
    }
  }
}

MCP setup for Claude Desktop, Cursor, VS Code and ChatGPT.

Track a comment

Re-read a pinned or viral comment to follow its likes.

Keep going

Run it on your own data

One key for TikTok and 76 more platforms, over REST or MCP. Free credits on signup, no card.

TikTok is a trademark of ByteDance Ltd. We are not affiliated with or endorsed by TikTok or ByteDance.