Using REST APIs
A quick post to explain what a REST API is and how it can be used. I’m clearly making no assumptions about what you know and this is a very brief explanation of a can be very complex topic.
A REST API defines a set of functions which developers can perform requests and receive responses via HTTP protocol such as GET and POST.
Because REST API’s use HTTP, they can be used by practically any programming language and easy to test (it’s a requirement of a REST API that the client and server are independent of each other allowing either to be coded in any language and improved upon supporting longevity and evolution).
The World Wide Web (WWW) is an example of a distributed system that uses REST protocol architecture to provide a hypermedia driven interface for websites. I’m saying hypermedia (instead of hypertext) as an expansion term to avoid confusion about the REST API supporting other formats to be provided not just HTML.
A Real World Example
Twitter provides a REST API which you can query to get the latest tweets, you can provide a search query (or hash tag) and it will return the results in JSON format. Example of this HTTP request to the Twitter API to get the latest 3 tweets matching “jQuery”. Try it.
http://search.twitter.com/search.json?q=jQuery&result_type=recent&rpp=3
And to expand on what a REST API should provide:
The REST API should specify what it can provide and how to use it, details such as query parameters, response format, request limitations, public use/API keys, method (GET/POST/PUT/DELETE), language support, callback usage, HTTPS support and resource representations should be self-descriptive…
This is the information provided for the GET search/tweets REST API.
Leave a Reply
You must be logged in to post a comment.