1.0.3 Update - This package might not be useful - Instead use trends/available endpoint directly.
Twitter 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.
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.
console.log(getSingleWOEID('new york'));
// RETURNS
[{ name: 'New York', country: 'United States', woeid: 2459115 }];
console.log(getSingleWOEID('india'));
// RETURNS
[{ name: 'India', country: 'India', woeid: 23424848 }];
console.log(getAllWOEID('japan'));
// RETURNS
[
{ name: 'Kitakyushu', country: 'Japan', woeid: 1110809 },
{ name: 'Saitama', country: 'Japan', woeid: 1116753 },
...
{ name: 'Okayama', country: 'Japan', woeid: 90036018 },
];
Using destructuring
const [{ woeid }] = getSingleWOEID('chennai');
twit.get('trends/place', { id: woeid })
.then(res => console.log(res.data[0]))
.catch(e => console.log(e));