Application Programming Interfaces

What is it?

Application programming interfaces (API) are a set of standardized requests that have been defined for the program being called upon.

 

We can structure requests per the specifications of the API so that we can get responses back.  Building an application with no APIs is basically like building a house with no doors.

Graphical User Interface

Underlying implementation

One way to think of it...

eg: Linux Kernal API

Representational state transfer (REST)

A way of providing interoperability between computer systems on the Internet using a uniform and predefined set of operations

Resource

The key abstraction of a RESTful API, a resource is a conceptual mapping to a set of entities, not the entity that corresponds to the mapping at any particular point in time.

Parts of an RESTful API

  • A base URL, such as http://api.example.com/resources/
  • A media type (also MIME type and content type)
    • ​Two-part identifier for file formats and format contents transmitted on the Internet
      • text/html
      • image/png
    • https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types
  • HTTP verbs GET, POST, PUT, DELETE and so on
  • filters/parameters ...?type=foo&keyword=bar

CRUD

  • Create
  • Read
  • Update
  • Delete

CRUD

  • Create or add new entries
  • Read, retrieve, search, or view existing entries
  • Update or edit existing entries
  • Delete/deactivate existing entries

Hypertext Transfer Protocol (HTTP) Request

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi nec metus justo. Aliquam erat volutpat.

Some readings:

  • Let's Build a Web Server! https://ruslanspivak.com/lsbaws-part1/
  • What RESTful Actually Means https://codewords.recurse.com/issues/five/what-restful-actually-means
  • APIs Behind the Scenes: https://medium.com/@michaelrbock/apis-how-the-internet-works-behind-the-scenes-690288634c32
  • Rest CookBook: http://restcookbook.com/

Project (due May 1)

 

  1. Research and choose a recommended API or one that interests you
    1. Read its documentation thoroughly to make an informed decision
    2. Look at examples of other successful uses of the API such as YouTubeInstant (warning the videos autoplay) built by Standford student Feross Aboukhadijeh
  2. Brainstorm and outline an approach for using the API.  Be able to answer what you’d like to build with it and how you plan to tackle the work by next week.  (We will do one-on-one approach discussions April 10)
  3. Design and build a single-page app using data requested from your chosen API using Javascript/Jquery and/or any libraries and frameworks of your choosing.

Some suggested APIs

Made with Slides.com