<img height="1" width="1" src="https://www.facebook.com/tr?id=1101141206686180&amp;ev=PageView &amp;noscript=1">

Rest API's (Get Requests)

I have spent a reasonable amount of time fiddling around with REST API’s and they have been very fun to use when developing pet projects. REST, in this context, stands for representational state transfer. In typical web design, this is used to describe the state that the website is in while you are browsing. Some examples include, how many items are in your shopping cart, your account name, membership status, your notifications, etc. This data lives on a server, and when you load a website that uses REST API’s. The website then asks the server, over HTTP Protocol, for data to show you when it is “finished loading”. It simply is an elegant way of reading/writing data from/to a server (reading messages or adding a friend for example). Today, I will only cover the GET Request, which essentially means to read data through a REST API.

 

It starts to get interesting when software developers give you access to the REST API’s that normally stay under the hood (sometimes referred to as public REST APIs). Postman.com gives you access to software to consume(use) REST API’s without writing a line of code, just to test that it is working. They also have a list of some of the most popular REST APIs on their front page!

When I downloaded postman, the first public API that I tested was from,

https://jsonplaceholder.typicode.com.

It is a very simple website that is used just for a free intro to REST API’s.

Following the documentation guide written from https://jsonplaceholder.typicode.com/guide/ and using postman, I made a GET Request with the postman to the address of https://jsonplaceholder.typicode.com/posts/1

Here is the data I received as a JSON object

Once you have a JSON object you can do pretty much do anything with the data that you could do in your own program.

Still a bit boring? Things can get interesting quickly. Yelp offers a public API to search all nearby restaurants just like you can do on yelp.com normally. Their guide can be found here https://www.yelp.com/developers.

 

Every once and a while at Erdos Miller, a few members of the team would get lunch together. Often times nobody really had anything in mind and couldn’t decide on a place to go. I had a great idea! I used Yelp’s REST API to make a program that would randomly choose a restaurant nearby and then pick it for us with the click of a button!

I even made a standalone website with React.js to show us a picture with a yelp link!

Using Yelp’s API, I made a simpler version of their own website.

http://wherever.herokuapp.com/

It was a fun little pet project that we all had a good laugh from and even made pretty good use of.

 

There are many fun public REST API’s out there, such as creating bots on Reddit that point out people's typos, automating stock trading, or just getting random pictures of kittens.

With all the REST API’s out there the possibilities are endless, good luck!