0
votes

I'm looking to make an React app that compares some local data with Twitter hashtags using the Twitter API to pull local trending hashtags based on a user's location.

The Twitter API I'm looking to use is the trends/places ( https://developer.twitter.com/en/docs/trends/trends-for-location/api-reference/get-trends-place ) which is at: https://api.twitter.com/1.1/trends/place.json?id=30079

Where id is a WOEID (Where On Earth ID) but actually obtaining this seems to be difficult. There are many stack overflow questions but they're mainly dated several years ago and reference now defunct APIs.

I can get this by using the Yahoo Weather api with a text search: https://www.yahoo.com/news/_tdnews/api/resource/WeatherSearch;text=birmingham,%20uk

But this would mean getting the Lat/Long from the user, processing this to get the City / Area, querying the weather API with a text search, extracting the WOEID from the response and then querying the Twitter API wit it.

It seems like I'm missing an easy and obvious endpoint somewhere, or there is an already built solution I'm not finding - any help very much appreciated, and apologies if I've missed something here it's my first question!

1

1 Answers

1
votes

If anyone else comes along with this issue there is another endpoint to get this on the Twitter API:

https://api.twitter.com/1.1/trends/closest.json

takes lat and long parameters and returns JSON object with woeid included, which can then be used for the trends data at:

https://api.twitter.com/1.1/trends/place.json

Doesn't seem to be obvious in the API guide, going by all of the Q&A type results from a google search - hope this helps someone!