Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Using Twitter's RESTful API with pure JavaScript?

Hey guys, I've been researching for a couple of days now and haven't really been able to find a solution, due to the fact that this is my first time using a RESTful API. I'm going to start with an overview of my idea and then go into the questions that I have so far.

Overview: I want to create a website using GitHub pages and JavaScript(along with HTML and CSS) that will request a certain keyword search from Twitter and then display the data retrieved, live on a map, shown at the location the tweet was tweeted from.. I want to use the RESTful API because it seems like I will be able to run the script on my site without deploying a server.

Questions: I'm honestly just really confused with the whole process of using the RESTful API after retrieving all of my consumer keys/secrets. I know I will have to use jQuery.. But I also haven't done that before either. Can anybody explain to me how to set up my JavaScript file so that I can retrieve data from Twitter, if pure JavaScript is possible?

To help future students, I will add a solution whether someone helps or I end up figuring it out myself! :)

Hi Ryan,

It's going to probably be difficult for anyone to say exactly how you should setup your files, typically it's better if you get started and if you hit a wall you post your code for review and further advice. It would probably be of benefit to you since you haven't done it before to have a more solid understanding of REST. Perhaps you could start with:

1 Answer

Chris Shaw
Chris Shaw
26,676 Points

Hi Ryan,

Sadly you need a backend language such as PHP in order to make calls to v1.1 of the Twitter API, this is because they now use authenticated requests across all endpoints whereas the now deprecated API allows unauthenticated requests to specific endpoints such as getting a list of tweets.

It's probably not what you were hoping for as an answer but sadly Twitter has made it harder to get data so they can keep their costs down.