twitterapi.trends.trends module
trends.py: Implementation of X Trends lookup endpoint.
The Trends lookup endpoint allows developers to get trends for a location, specified using the where-on-earth id (WOEID). WOIEDs can be found in https://github.com/UnibwSparta/twitterapi/blob/main/src/sparta/twitterapi/trends/woeids.json
Endpoint documentation: https://developer.x.com/en/docs/x-api/trends/introduction
Example
import os os.environ[“BEARER_TOKEN”] = “xxxxxxxxxxx” from sparta.twitterapi.trends.trends import get_trends_by_woeid
- async def main():
- woeid = 26062 trends = await get_trends_by_woeid(woeid, max_trends=10) print(trends) 
- async sparta.twitterapi.trends.trends.get_trends_by_woeid(woeid: int, max_trends: int = 20) List[Trend]
- Asynchronously retrieves trending topics for a specified WOEID. - Parameters:
- woeid (int) – The where-on-earth identifier for the location. 
- max_trends (int, optional) – The maximum number of trends to return. Default is 20. 
 
- Returns:
- A list of trends, each containing requested fields. 
- Return type:
- List[Dict] 
- Raises:
- Exception – If an HTTP error occurs or if the request parameters are invalid.