Get the supported country and global options that can be used to filter trending tweets.
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)
| Parameter |
Type |
Required |
Description |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.StandardResponse
| Error Type |
Status Code |
Content Type |
| errors.XapiScraperDefaultError |
4XX, 5XX |
*/* |
Get the topic categories available for filtering global trending tweets.
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)
| Parameter |
Type |
Required |
Description |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.StandardResponse
| Error Type |
Status Code |
Content Type |
| errors.XapiScraperDefaultError |
4XX, 5XX |
*/* |
Get content tags for a selected country and topic so tweets can be filtered more precisely.
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)
| 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. |
models.StandardResponse
| 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.
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)
| 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. |
models.SearchResponse
| Error Type |
Status Code |
Content Type |
| errors.HTTPValidationError |
422 |
application/json |
| errors.XapiScraperDefaultError |
4XX, 5XX |
*/* |
Get X Explore trending topics for a given country. Use 'worldwide' for account-default trends or a country slug such as 'united-states'.
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)
| 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. |
|
models.StandardResponse
| Error Type |
Status Code |
Content Type |
| errors.HTTPValidationError |
422 |
application/json |
| errors.XapiScraperDefaultError |
4XX, 5XX |
*/* |