Chapter    22

Consuming RESTful Services

If you have a Twitter account or a Facebook account, when you use their mobile applications you are consuming their services via a REST API.

Representational State Transfer (REST) defines an architecture, not a protocol, for designing Web services that consume system resources. It defines how the resource states are accessed and transferred over HTTP.

The key features of REST Web services are:

  • They use HTTP methods only.
  • They are stateless.
  • Endpoints are defined as directory structures.
  • Data is transferred using XML, JSON or both.

HTTP Methods

There are four HTTP methods we will be using today, GET, PUT, POST and DELETE. These methods are defined by the HTTP protocol. There are other methods but we will ...

Get Learn Swift 2 on the Mac, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.