Twitter WOEID
trends/available endpoint directly.
1.0.3 Update - This package might not be useful - Instead useTwitter uses Yahoo! WOEID for all of their Trends related API endpoints. But that Yahoo! service has been shutdown.
This NPM module offers methods to get WOEID of all locations that Twitter has trending topic information for.
Contents:
Available Methods
getSingleWOEID(cityName)
Use the above method for getting the WOEID of a City (Local Trends).
Use the above method for getting the WOEID of a Country (National Trends).
getAllWOEID(countryName)
Use the above method for getting the WOEIDs of all cities (that Twitter has trending topic information for) of that country.
Each of the above methods returns an array of matching city/country.
Example
City
console.log(getSingleWOEID('new york'));
// RETURNS
[{ name: 'New York', country: 'United States', woeid: 2459115 }];
Country
console.log(getSingleWOEID('india'));
// RETURNS
[{ name: 'India', country: 'India', woeid: 23424848 }];
All (Available) cities of a Country
console.log(getAllWOEID('japan'));
// RETURNS
[
{ name: 'Kitakyushu', country: 'Japan', woeid: 1110809 },
{ name: 'Saitama', country: 'Japan', woeid: 1116753 },
...
{ name: 'Okayama', country: 'Japan', woeid: 90036018 },
];
Usage with Twit
Using destructuring
const [{ woeid }] = getSingleWOEID('chennai');
twit.get('trends/place', { id: woeid })
.then(res => console.log(res.data[0]))
.catch(e => console.log(e));