In this lesson we will learn what an api is, the data formats that api's typically use, and how to consume a web api using Ruby.
A web api is a programmatic interface to request and deliver data using HTTP. Typically api data is JSON or XML. Most modern web API's use JSON, but plenty of XML api's are still in use. There isn't much difference between an api and the applications we've been making so far, except the responses aren't in HTML and usually the request is not coming from a browser. A few example api's are:
http://openweathermap.org/API is used for current weather data, forecasting, searching, and weather maps.
- Documentation: http://openweathermap.org/API
- Base URI: http://api.openweathermap.org/data/2.5/
- Example:
The google books api is used to request and information about books.
- Base URI: https://www.googleapis.com/books/v1
- Documentation: Google API
- Example: https://www.googleapis.com/books/v1/volumes?q=twain
Used to retrieve photos by album, collection, user, and search.