Skip to content

Latest commit

 

History

History
180 lines (117 loc) · 9.3 KB

File metadata and controls

180 lines (117 loc) · 9.3 KB

Tweets

Overview

Available Operations

detail

Retrieve detailed information for one or more tweets by ID (no cookie required). The maximum input quantity is limited by your plan's QPS. To pass larger input quantity limits, upgrade your plan to get higher QPS.

Example Usage

import os
from x_api_scraper import XapiScraper


with XapiScraper(
    bearer_auth=os.getenv("X_API_SCRAPER_BEARER_AUTH", ""),
) as xapi_scraper:

    res = xapi_scraper.tweets.detail(request=[
        "2076874251915743687",
    ])

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
request List[str] ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

Any

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.XapiScraperDefaultError 4XX, 5XX */*

thread

Retrieve all tweets in a thread by tweet ID, sorted by latest.

Example Usage

import os
from x_api_scraper import XapiScraper


with XapiScraper(
    bearer_auth=os.getenv("X_API_SCRAPER_BEARER_AUTH", ""),
) as xapi_scraper:

    res = xapi_scraper.tweets.thread(tweet_id="<id>", max_items=40)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
tweet_id str ✔️ The root tweet ID to fetch the thread for
max_items Optional[int] ➖ Max number of thread tweets to return
fields List[str] ➖ Fields to include in each tweet. If omitted, all fields are returned.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

Any

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.XapiScraperDefaultError 4XX, 5XX */*

lookup

Retrieve detailed information for multiple Tweets by their IDs. The maximum input quantity is limited by your plan's QPS. To pass larger input quantity limits, upgrade your plan to get higher QPS.

Example Usage

import os
from x_api_scraper import XapiScraper


with XapiScraper(
    bearer_auth=os.getenv("X_API_SCRAPER_BEARER_AUTH", ""),
) as xapi_scraper:

    res = xapi_scraper.tweets.lookup(request=[
        "1803006263529541838",
    ])

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
request List[str] ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.GetTweetsByIDResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.XapiScraperDefaultError 4XX, 5XX */*

similar

Get similar tweets

Example Usage

import os
from x_api_scraper import XapiScraper


with XapiScraper(
    bearer_auth=os.getenv("X_API_SCRAPER_BEARER_AUTH", ""),
) as xapi_scraper:

    res = xapi_scraper.tweets.similar(tweet_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
tweet_id str ✔️ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.GetTweetsByIDResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.XapiScraperDefaultError 4XX, 5XX */*