Skip to content

Latest commit

 

History

History
216 lines (138 loc) · 13 KB

File metadata and controls

216 lines (138 loc) · 13 KB

Trending

Overview

Available Operations

countries

Get the supported country and global options that can be used to filter trending 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.trending.countries()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.StandardResponse

Errors

Error Type Status Code Content Type
errors.XapiScraperDefaultError 4XX, 5XX */*

topics

Get the topic categories available for filtering global trending 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.trending.topics()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.StandardResponse

Errors

Error Type Status Code Content Type
errors.XapiScraperDefaultError 4XX, 5XX */*

contents

Get content tags for a selected country and topic so tweets can be filtered more precisely.

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.trending.contents(country="Monaco", topic="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
country str ✔️ Country name or slug returned by /twitter/global-trending/countries
topic str ✔️ Topic name or slug returned by /twitter/global-trending/topics
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.StandardResponse

Errors

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

tweets

Get trending tweets for a country, with optional topic and content tag filters.

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.trending.tweets(country="Lithuania", count=20)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
country str ✔️ Country name or slug returned by /twitter/global-trending/countries
topic OptionalNullable[str] Optional topic name or slug returned by /twitter/global-trending/topics
content OptionalNullable[str] Optional content tag returned by /twitter/global-trending/contents
count Optional[int] Maximum number of tweets to return.
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 */*

by_country

Get X Explore trending topics for a given country. Use 'worldwide' for account-default trends or a country slug such as 'united-states'.

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.trending.by_country(country="worldwide")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
country models.Country ✔️ Country slug or 'worldwide' for default explore trends Example 1: worldwide
Example 2: united-states
Example 3: japan
Example 4: united-kingdom
Example 5: zimbabwe
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.StandardResponse

Errors

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