SocialData.Tools: API Documentation
  • Getting Started
  • Authentication
  • Pricing
  • SDKs and Code Examples
  • Twitter: Tweets
    • Retrieve tweet details
    • Retrieve thread
    • Retrieve article details
    • Retrieve all users who retweeted a tweet
    • Retrieve search results by keyword
    • Retrieve all users who liked a tweet
  • Twitter: Users
    • Retrieve user profile details
    • Retrieve profile's affiliated users
    • Retrieve tweets and replies made by a specific user
    • Retrieve likes made by a specific user
    • Retrieve user's articles
    • Retrieve user's highlighted tweets
    • Retrieve user's followers
    • Retrieve user's following
    • Retrieve user's lists
    • Check if a user is following another user
    • Check if a user retweeted a specific tweet
    • Check if a user commented on a specific tweet
    • Check if a user liked a specific tweet
    • Retrieve users search results by screenname
  • Twitter: Lists
    • Retrieve list details
    • Retrieve list members
  • Twitter: Spaces
    • Retrieve Twitter spaces stream details
  • Twitter / X: Communities
    • Retrieve community tweets timeline
    • Retrieve community members
Powered by GitBook
On this page
  • Endpoint
  • Endpoint parameters
  • Approach
  • Known Limitations
  • Pricing
  • Response codes
  • Rate limits
  • Example request
  • Example response
  1. Twitter: Users

Check if a user commented on a specific tweet

PreviousCheck if a user retweeted a specific tweetNextCheck if a user liked a specific tweet

Last updated 1 day ago

WARNING:

You are viewing an outdated version of our documentation. For the latest and most accurate information, please visit .

This endpoint provides a convenient way to check if a user identified by user_id posted a comment in response to a tweet identified by tweet_id. This endpoint only detects direct replies to a target tweet, and not comments posted under other comments.

The endpoint returns an array of comment_ids taking into account that a single user may have posted more than a single reply.

Endpoint

GET https://api.socialdata.tools/twitter/tweets/[tweet_id]/commented_by/[user_id]

Endpoint parameters

Name
Description
Example

tweet_id (Required)

The numeric ID of the target tweet

1625802236571033602

user_id (Required)

The numeric ID of the user

1489552236571048124

Common Issues and Best Practices

  • In languages where the tweet_id or user_id value exceeds the default Integer type limit (e.g., Node.js), store tweet_id and user_id as strings. Use the id_str property returned by the API for these values

Approach

This endpoint performs a number of tests to detect the relevant comment with high accuracy and low latency:

  1. SocialData will attempt to retrieve a user's and check if any of their recent replies were posted in response to the target tweet_id (i.e. where in_reply_to_status_id == tweet_id) - this requires that a user's profile privacy is set to public and not "protected"

  2. If the previous test fails, SocialData will also for the following query conversation_id:TWEET_ID from:USERNAME (i.e. any comments posted by the user under the target tweet)

  3. With each request SocialData will also dispatch an async job to retrieve the latest search results for conversation_id:TWEET_ID (i.e. any comments posted by any users in response to the target tweet_id) - the job with cache all user_ids and their corresponding comment_ids and use this cache to verify actions on future requests

Before running tests #1 and #2, SocialData will check if the target user_id is already present in cache (e.g. if found by an async job earlier). If any records found in cache - SocialData will immediately return the response and skip both tests #1 and #2 to minimize the latency of this endpoint.

Known Limitations

While in general this endpoint provides highly accurate results, it may occasionally fail to detect any relevant comments, even if the user commented on the target tweet, in the following cases:

  • A comment was posted a long time ago and it is not found in the first few pages of the user's tweets and replies page, or in their comment search results

  • A comment was posted by a shadow-banned user (i.e. marked by Twitter as spam/bot account) and their comments don't show up in search

However, you are unlikely to experience any of these issues if the endpoint is called shortly after the user posted their comment.

Pricing

This endpoint has a flat-rate pricing of $0.008 per request regardless of how many tweets were scraped to detect the relevant comment.

Response codes

  • HTTP 200 OK - succeeded

  • HTTP 402 Payment Required - not enough credits to perform this request

  • HTTP 404 Not Found - requested target tweet does not exist

  • HTTP 422 Unprocessable Content - validation failed (e.g. one of the required parameters was not provided)

  • HTTP 500 Internal Server Error - other error, typically means that SocialData API failed to obtain the requested information and you should try again later

Rate limits

By default each user has a limit of 120 requests per minute shared across all endpoints. Please reach out to support@socialdata.tools if you need to raise your rate limit.

Example request

curl "https://api.socialdata.tools/twitter/tweet/456456456/commented_by/123123123
-H 'Authorization: Bearer API_KEY'
-H 'Accept: application/json

Example response

// If comment found: 
{
    "status": "success",
    "is_commented": true,
    "comment_ids": [
        "1111111...",
        "2222222...",
    ]
}

// If comment not found:
{
    "status": "success",
    "is_commented": false,
    "comment_ids": [
    ]
}

Keep in mind that the endpoint will not detect any deleted comments - if a comment_id was detected earlier, it will be stored in cache even if the user deletes it, and will be returned in subsequent endpoint responses. If your app needs to detect if any of the relevant comments was deleted - use the endpoint to retrieve the comment. Any deleted comments will result in error 404 Not Found

docs.socialdata.tools
Tweets and replies page
retrieve Twitter search results
tweet details