DEV Community

Cover image for 🌎 Track Twitter Trends of any country or town in the world
Ayush Singh
Ayush Singh

Posted on

🌎 Track Twitter Trends of any country or town in the world

The Problem

When it comes to viewing what's trending on twitter of some other location other than your own it's very hard. Also, you can't really see twitter trends below 30 or sometimes 10 even after changing the location.

The solution

Even though there were solutions there I still wanted to work with twitter API to provide everything for free and in better UI than everybody else and if you ask me at the end I did. Here's how?

The first thing I did was to get the approval of twitter developers API. Then I used the api to get the JSON data of all the countries and town in the world that are live. You can get upto 50 trends for any country and town.

Now, I created a search bar using AJAX + PHP because I wanted to filter and echo results based upon users input. You can try typing your country or town to see what's trending there right now. It works amazing even I like it even after developing it. Link is in twitter trends above you will find as there is a single link in this post.

I also added an Index page so that the user can see how many countries and towns we can track. Right now you can see twitter trends of 62 countries and 462 towns on global twitter trends. These are live and are updated every 30 minutes.

I created a HTML table to echo JSON data of each country and town but there was a problem it used to get unresponsive on small screens I handled this by changing table design when users uses it on small screens. You can see yourself. For this I used media tag in css.

I used w3css framework in order to make the entire design because I liked it. It was fast.

Logo is simply created on canva if you are interested in that too.

That's it using all the things above I created global twitter trends.

I would love to interact with anyone on dev.to so please ask question in comments.

Discussion (8)

Collapse
mburakerman profile image
Mehmet Burak Erman

i created an app for this need: 🦄 twitter-trends.vercel.app/

Collapse
ayush_singh_dev profile image
Ayush Singh Author

Quite similar. I think I need to implement the map but for small screen users there needs to a faster and better approach so that everyone can access it. Or showing maps based on trends could be a different feature as well like an add-on to the site as most people will just come for looking for trends.

Collapse
garikaib profile image
garikaib

Wow that's awesome. Word from a third world country-Twitter's ability to generate Trends doesn't work in small countries.

Collapse
ayush_singh_dev profile image
Ayush Singh Author

You can see trends of any country or town twitter is present it no matter how small or big they are. First world or third world every country or town twitter is present in is covered by global twitter trends.

Collapse
stesants8 profile image
Sté Sants

wow!man you were a genius, this was something that frustrated me in the trends, I'll access it, twitter needs to tell you about your project

Collapse
ayush_singh_dev profile image
Ayush Singh Author

Thanks man just share it with people so that the project can grow and I will add more and more free features

Collapse
andypiper profile image
Andy Piper

Nice, have you shared the code for your project anywhere?

Collapse
ayush_singh_dev profile image
Ayush Singh Author

No actually I have not shared it anywhere