Skip to content

Latest commit

 

History

History
172 lines (124 loc) · 22 KB

File metadata and controls

172 lines (124 loc) · 22 KB

Search

Overview

Available Operations

advanced

Perform advanced Twitter search with cursor-based pagination. Each page returns up to 20 tweets. Pass next_cursor from the previous response to continue. Pricing: $0.10 per 1,000 tweets. 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.search.advanced(search_terms=[
        "<value 1>",
        "<value 2>",
        "<value 3>",
    ], sort_by="<value>", next_cursor="")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
search_terms List[str] ✔️ List of search terms used to build the Twitter query.
sort_by str ✔️ Sort mode for search results. Supported values: 'Latest' or 'Top'.
next_cursor OptionalNullable[str] ➖ Cursor returned by the previous page. Leave empty to fetch the first page.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.AdvancedSearchCursorResponse

Errors

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

cashtags

Search for tweets containing specific cashtags (stock symbols), $0.10/1000 tweets. 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.search.cashtags(cashtags=[
        "AAPL",
        "TSLA",
    ], start_time="1775726400", end_time="1775727300", language="en")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
cashtags List[str] ➖ Cashtag to search for (with or without $ prefix) [
"AAPL",
"TSLA"
]
start_time OptionalNullable[str] ➖ Start time for search in UNIX timestamp 1775726400
end_time OptionalNullable[str] ➖ End time for search in UNIX timestamp 1775727300
sort_by OptionalNullable[models.CashtagsQuerySortBy] ➖ Sort order for results
max_items OptionalNullable[int] ➖ Maximum number of tweets to return
mininum_likes OptionalNullable[int] ➖ Minimum number of likes required
mininum_retweets OptionalNullable[int] ➖ Minimum number of retweets required
mininum_replies OptionalNullable[int] ➖ Minimum number of replies required
blue_verified OptionalNullable[bool] ➖ Filter for blue verified accounts only
verified OptionalNullable[bool] ➖ Filter for verified accounts only
language OptionalNullable[models.CashtagsQueryLanguage] ➖ Language filter for tweets en
only_image OptionalNullable[bool] ➖ Filter for images only
only_video OptionalNullable[bool] ➖ Filter for videos only
only_quote OptionalNullable[bool] ➖ Filter for quotes only
only_reply OptionalNullable[bool] ➖ Filter for replies only
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.SearchResponse

Errors

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

hashtags

Search for tweets containing specific hashtags. 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.search.hashtags(hashtags=[
        "btc",
        "eth",
    ], start_time="1775726400", end_time="1775727300", language="en")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
hashtags List[str] ➖ Hashtag to search for (with or without # prefix) [
"btc",
"eth"
]
start_time OptionalNullable[str] ➖ Start time for search in UNIX timestamp 1775726400
end_time OptionalNullable[str] ➖ End time for search in UNIX timestamp 1775727300
sort_by OptionalNullable[models.HashtagsQuerySortBy] ➖ Sort order for results
max_items OptionalNullable[int] ➖ Maximum number of tweets to return
mininum_likes OptionalNullable[int] ➖ Minimum number of likes required
mininum_retweets OptionalNullable[int] ➖ Minimum number of retweets required
mininum_replies OptionalNullable[int] ➖ Minimum number of replies required
blue_verified OptionalNullable[bool] ➖ Filter for blue verified accounts only
verified OptionalNullable[bool] ➖ Filter for verified accounts only
language OptionalNullable[models.HashtagsQueryLanguage] ➖ Language filter for tweets en
only_image OptionalNullable[bool] ➖ Filter for images only
only_video OptionalNullable[bool] ➖ Filter for videos only
only_quote OptionalNullable[bool] ➖ Filter for quotes only
only_reply OptionalNullable[bool] ➖ Filter for replies only
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.SearchResponse

Errors

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