• 6 hours
  • Easy

Free online content available in this course.

Videos available in this course

Certificate of achievement available at the end this course

Got it!

Last updated on 2/4/19

Identify examples of REST APIs

Log in or subscribe for free to enjoy all this course has to offer!

Real examples of REST APIs

Let’s explore some real-life REST APIs and what you, as a developer, can do with them! We’ll discuss the following APIs: Instagram, Gmail, GitHub, and Weather Underground.

One of the hardest things about APIs is understanding what they really are, since the concept is very abstract. These examples use familiar services just to show what's possible with various APIs; no need to understand all the technical underpinnings quite yet! Know that your favorite services that you use every day probably have an API available, and it's yours to use.

Instagram

The Instagram API allows your applications to retrieve user accounts, photos, tags and more! For example, here are the possible options for interacting with a user account:

User endpoints
User endpoints

As you can see, you can access a user’s recent media, media that a particular user has liked, and have even more options once you go beyond users to interacting with likes, comments, and locations. This content can then be displayed in your application, used for data purposes, etc.

For example, here’s a GET request that you might make to the Instagram API for photo locations from a set of longitude and latitude coordinates for New York City (40.7127° N, 74.0059° W):

GET /v1/locations/search?access_token=ACCESS_TOKEN&lat=40.7127&lng=74.0059

Here’s the JSON response from Instagram:

HTTP/1.1 200 OK

{
 "meta": {
   "code": 200
 },
 "data": [
   {
     "latitude": 40.714198749,
     "id": "93496093",
     "longitude": 74.006001183,
     "name": "John's Pizzeria 278 Bleecker St NY, NY"
   },
   {
     "latitude": 40.7142,
     "id": "46371155",
     "longitude": 74.0064,
     "name": "Thunderpocalypse 2012"
   },
   {
     "latitude": 40.714201754,
     "id": "35932492",
     "longitude": 74.006397137,
     "name": "Avenue of the Americas, New York"
   },
   {
     "latitude": 40.71296389,
     "id": "1023103828",
     "longitude": 74.00388611,
     "name": "Manhattan Municipal Building"
   },
   {
     "latitude": 40.71322,
     "id": "92582758",
     "longitude": 74.003963,
     "name": "Sleepers Filming Location"
   },
   {
     "latitude": 40.716833,
     "id": "97921846",
     "longitude": 74.005833,
     "name": "Atera"
   }
 ]
}

Once you have this response, you can take the Instagram data and integrate it into your own code base. Other functionalities of the API include the ability to retrieve popular photos and videos, retrieve photos with certain tags like “cats” or “sunset,” and more.

For more information, see their documentation here: https://www.instagram.com/developer/

Gmail

The Gmail API revolves around five main aspects: messages, labels, drafts, history, and threads. These will be familiar concepts if you’ve ever used Gmail or another email tool!

According to their documentation, here’s how you’d build the ability to send a Gmail message within your own application. This is a bit tricky and high-level programmatically, but you don’t need to understand the technicalities -- just that it’s possible!

Gmail API message options
Gmail API message options

Here’s an example given by Google developers of something you might do with their API. First, the request your application generates:

GET https://www.googleapis.com/gmail/v1/users/me/messages?q="in:sent after:2014/01/01 before:2014/01/30"

This request would ping Gmail for messages sent between 1/1/2014 and 1/30/2014. You'd of course need to be authenticated to have access to these messages -- having access to an API doesn't mean you have unfettered access to all data in an external application -- but once you were logged in via the API you could do many things you might do on actual gmail.com.

For more information, see their documentation here: https://developers.google.com/gmail/api/

GitHub

GitHub is a code hosting platform used super widely by many websites big and small. Accordingly, they have a super REST API! Using their API, you can perform such actions as tracking user activity, following GitHub issues, and creating repositories from your own application.

For example, if we want all the details on a certain user, you’d set up your application to ping the GitHub API with the HTTP GET method to retrieve a certain user:

GET /users/:username

The server would send back this JSON response of the user’s associated information. You’d then decide how you want to use the data in your own application! For example you could integrate GitHub transactions in a group messaging app.

{
  "login": "octocat",
  "id": 1,
  "avatar_url": "https://github.com/images/error/octocat_happy.gif",
  "gravatar_id": "",
  "url": "https://api.github.com/users/octocat",
  "html_url": "https://github.com/octocat",
  "followers_url": "https://api.github.com/users/octocat/followers",
  "following_url": "https://api.github.com/users/octocat/following{/other_user}",
  "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
  "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
  "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
  "organizations_url": "https://api.github.com/users/octocat/orgs",
  "repos_url": "https://api.github.com/users/octocat/repos",
  "events_url": "https://api.github.com/users/octocat/events{/privacy}",
  "received_events_url": "https://api.github.com/users/octocat/received_events",
  "type": "User",
  "site_admin": false,
  "name": "monalisa octocat",
  "company": "GitHub",
  "blog": "https://github.com/blog",
  "location": "San Francisco",
  "email": "octocat@github.com",
  "hireable": false,
  "bio": "There once was...",
  "public_repos": 2,
  "public_gists": 1,
  "followers": 20,
  "following": 0,
  "created_at": "2008-01-14T04:33:35Z",
  "updated_at": "2008-01-14T04:33:35Z",
  "total_private_repos": 100,
  "owned_private_repos": 100,
  "private_gists": 81,
  "disk_usage": 10000,
  "collaborators": 8,
  "plan": {
    "name": "Medium",
    "space": 400,
    "private_repos": 20,
    "collaborators": 0
  }
}

There are many other uses of the API certainly worth looking at if you’re already familiar with GitHub functionalities: https://developer.github.com/ 

Weather Underground

The last REST API we’ll look at is Weather Underground’s (this teacher's personal favorite). Weather information can be super useful in many types of applications, and luckily there are services like this that make their data easy to access and use in your own software.

For example, if you’re building an app that suggests what users should wear to go running, you’ll need access to temperate data, precipitation conditions, sunrise and sunset times, and more in order for your app to make the predictions. Building your own weather service to get this information would be much too arduous. You’d use the API of a weather service to get this data instead and then use the data for your own purposes!

Here’s a sample request to ping Weather Underground’s API for the current conditions in San Francisco:

GET http://api.wunderground.com/api/Your_Key/conditions/q/CA/San_Francisco.json

Here’s the JSON response from Weather Underground:

{
  "response": {
  "version": "0.1",
  "termsofService": "http://www.wunderground.com/weather/api/d/terms.html",
  "features": {
  "conditions": 1
  }
  },
  "current_observation": {
  "image": {
  "url": "http://icons-ak.wxug.com/graphics/wu2/logo_130x80.png",
  "title": "Weather Underground",
  "link": "http://www.wunderground.com"
  },
  "display_location": {
  "full": "San Francisco, CA",
  "city": "San Francisco",
  "state": "CA",
  "state_name": "California",
  "country": "US",
  "country_iso3166": "US",
  "zip": "94101",
  "latitude": "37.77500916",
  "longitude": "-122.41825867",
  "elevation": "47.00000000"
  },
  "observation_location": {
  "full": "SOMA - Near Van Ness, San Francisco, California",
  "city": "SOMA - Near Van Ness, San Francisco",
  "state": "California",
  "country": "US",
  "country_iso3166": "US",
  "latitude": "37.773285",
  "longitude": "-122.417725",
  "elevation": "49 ft"
  },
  "estimated": {},
  "station_id": "KCASANFR58",
  "observation_time": "Last Updated on June 27, 5:27 PM PDT",
  "observation_time_rfc822": "Wed, 27 Jun 2012 17:27:13 -0700",
  "observation_epoch": "1340843233",
  "local_time_rfc822": "Wed, 27 Jun 2012 17:27:14 -0700",
  "local_epoch": "1340843234",
  "local_tz_short": "PDT",
  "local_tz_long": "America/Los_Angeles",
  "local_tz_offset": "-0700",
  "weather": "Partly Cloudy",
  "temperature_string": "66.3 F (19.1 C)",
  "temp_f": 66.3,
  "temp_c": 19.1,
  "relative_humidity": "65%",
  "wind_string": "From the NNW at 22.0 MPH Gusting to 28.0 MPH",
  "wind_dir": "NNW",
  "wind_degrees": 346,
  "wind_mph": 22.0,
  "wind_gust_mph": "28.0",
  "wind_kph": 35.4,
  "wind_gust_kph": "45.1",
  "pressure_mb": "1013",
  "pressure_in": "29.93",
  "pressure_trend": "+",
  "dewpoint_string": "54 F (12 C)",
  "dewpoint_f": 54,
  "dewpoint_c": 12,
  "heat_index_string": "NA",
  "heat_index_f": "NA",
  "heat_index_c": "NA",
  "windchill_string": "NA",
  "windchill_f": "NA",
  "windchill_c": "NA",
  "feelslike_string": "66.3 F (19.1 C)",
  "feelslike_f": "66.3",
  "feelslike_c": "19.1",
  "visibility_mi": "10.0",
  "visibility_km": "16.1",
  "solarradiation": "",
  "UV": "5",
  "precip_1hr_string": "0.00 in ( 0 mm)",
  "precip_1hr_in": "0.00",
  "precip_1hr_metric": " 0",
  "precip_today_string": "0.00 in (0 mm)",
  "precip_today_in": "0.00",
  "precip_today_metric": "0",
  "icon": "partlycloudy",
  "icon_url": "http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
  "forecast_url": "http://www.wunderground.com/US/CA/San_Francisco.html",
  "history_url": "http://www.wunderground.com/history/airport/KCASANFR58/2012/6/27/DailyHistory.html",
  "ob_url": "http://www.wunderground.com/cgi-bin/findweather/getForecast?query=37.773285,-122.417725"
  }
}

}

You receive useful information on San Francisco weather conditions including wind speed, precipitation predictions, UV strength. Other possibilities with this API include getting tidal information, moon details, temperature records, and more! Think about how annoying it would be to create your own weather service just to get weather information in your own app. Luckily, you don't have to.

Check out Weather Underground's API documentation here: http://www.wunderground.com/weather/api

Example of certificate of achievement
Example of certificate of achievement