1 of 10

Web APIs and Services

Sami Rollins

2 of 10

Web Service

A web service is a software system designed to support interoperable machine-to-machine interaction over a network.

— W3C, Web Services Glossary[1]

A web site serves HTML pages designed for human consumption. A web service (or API) serves content intended for consumption by a machine.

3 of 10

Web API

Web 2.0 Web APIs often use machine-based interactions such as REST and SOAP. RESTful web APIs are typically loosely based on HTTP methods to access resources via URL-encoded parameters and the use of JSON or XML to transmit data. By contrast, SOAP protocols are standardized by the W3C and mandate the use of XML as the payload format, typically over HTTP

— Wikipedia

4 of 10

SOAP

  • Initially, the World Wide Web Consortium (W3C) tried to standardize web services
        • Simple Object Access Protocol (SOAP)
        • Web Services Description Language (WSDL)
        • eXtensible Markup Language (XML)
        • HTTP

5 of 10

REpresentational State Transfer (REST)

  • REST is a pattern for building web services
        • Everything on the web is a resource
        • Web API allows you to create/read/update/delete (CRUD) a resource

6 of 10

Pure (original) REST

  • HTTP methods specify the remote methods you may invoke on the service
        • GET/PUT/POST/HEAD/DELETE
  • Scoping information provided in the URI
        • http://www.flickr.com/photos/interesting/2008/01/05
  • Query parameters used for algorithmic resources
        • http://www.google.com/search?q=computer

7 of 10

Using a web API

  • Flickr Example
        • https://www.flickr.com/services/api/
  • Slack API
        • https://api.slack.com/methods

8 of 10

RESTful or Not RESTful

POST /api/createUser

POST /api/updateUser

GET /api/findUser

9 of 10

RESTful or Not RESTful

POST /api/createUser

POST /api/updateUser

GET /api/findUser

POST /api/users/create

GET /api/users/{id}/find

POST /api/users/{id}/update

10 of 10

RESTful or Not RESTful

POST /api/users/create

GET /api/users/{id}/find

POST /api/users/{id}/update

POST /api/users

PUT /api/users/{id}

GET /api/users/{id}