apis web services

APIs and web services

For many popular online applications, it’s important to have an architecture that allows webpage data to be read by both humans and machines – and I’m not talking about the Terminator scrolling through his Twitter timeline.

As well as allowing human end users to interact with webpages, large-scale applications like Instagram and Google allow other authorised applications access to their API (application programming interface). A web service allows this connection between client-side programs, and server-side programs.

This enables other developers to use Instagram/Google’s data directly when programming their own applications.

For example, Google Maps allows access to their API, and developers can use this data to pull through addresses into their own applications.

On the following URL from Google’s API you can access the location information for Disneyland Paris, displayed as text through HTTP and JSON:
https://maps.googleapis.com/maps/api/geocode/json?address=disneyland,paris

"formatted_address" : "77777 Marne-la-Vallée, France",
     "geometry" : {
          "location" : {
              "lat" : 48.8722344,
              "lng" : 2.7758079

This information contains street address as well as latitude and longitude coordinates. Developers can use the Google Maps API to automatically include addresses of customers or businesses. This automatic architecture means that if an address ever changes, the information is updated automatically without the developer having to go back in and update their database.

This location information can then be used in conjunction with data from other web services and APIs.

If, for example, a developer is commissioned by Disney to build an application that shows all Instagram photos taken at Disneyland Paris they can combine the location information acquired through the Google API with information from Instagram’s API.

When a photo is uploaded to Instagram, location data about the photo is also uploaded – assuming that the user has given permission, and they were connected to a GPS signal when the photo was taken.

App developers can request access to this data from Instagram, and can use it in conjunction with the data from Google Maps to build their program that shows Instagram photos taken at Disneyland Paris.

In our example, to find photos taken at Disneyland Paris, the developer can then take the latitude and longitude acquired through the Google Maps API and input a GET request to the Instagram API that will return photos from that location.

"lat" : 48.8722344,               
"lng" : 2.7758079

https://api.instagram.com/v1/media/search?lat=48.8722344&lng=2.7758079&access_token=ACCESS-TOKEN

For security reasons, this request can only be executed if the developer has been given an access token from Instagram. This stops anyone from being able to access photos from anywhere. But a program developer with an access token would be able to pull through the photos from that specific location, and build them into their own application.

This technique of applications retrieving data from multiple web services, and combining the data to display something new is known as a Web Application Hybrid (informally known as a ‘Mashup’).

When developing an application in an increasingly interconnected world it’s important to consider APIs and web services when thinking about how the application will interact with other programs.

With leading technology, intelligent load balancing and scalable configurations, cloud servers from Fasthosts are a reliable platform for hosting large scale online applications.

Be Sociable, Share!