HTTP 1.1 • Can be used with other transfer protocols • In practice, used almost exclusively with HTTP web APIs • RESTful APIs use HTTP to the fullest: methods, headers, error codes, hypermedia
to other resources, and defined operations • Similar in principle to object instances in object-oriented programming • Must be uniquely identifiable (to be addressable)
The same resource may be represented in a number of ways (e.g.: XML, JSON) • The client can request the desired representation format (e.g., using the Accept HTTP header)
Contain information about resources and about the HTTP transaction • Especially important for content negotiation and conditional requests • The “X-” prefix used to be recommended for non-standard headers – not anymore
are accepted • Accept-Encoding Which compression schemes are accepted • Content-Type The representation format of the content • Content-Encoding The compression scheme of the content
specific version of a resource • If-Match / If-None-Match Process request if version identifier matches/doesn't match • If-Modified-Since / If-Unmodified-Since Process request if resource has/hasn't been modified since the specified date/time
representation of a resource: Accept: application/json • Retrieve the resource only if it was modified: If-Modified-Since: Sat, 30 May 2015... • Send basic HTTP authentication data: Authorization: Basic QWxhZGRpbjpv...
of a newly POSTed resource: Location: .../invoices/2015-05-125 • Return the date/time of last modification: Last-Modified: Sat, 30 May 2015... • Tell the client to authenticate: WWW-Authenticate: Basic realm="...”
new resource: 201 Created • POST or PUT with invalid data: 400 Bad Req. / 422 Unprocessable Entity • PUT on a read-only resource: 405 Method Not Allowed • Resource DELETEd: 204 No Content
/statuses/update.json • Retrieving user information: GET /users/show.json?screen_name=alice • Deleting a tweet: POST /statuses/destroy/789123456.json Pffft!
on the server means there's no concept of an authenticated client • Authentication state must be maintained elsewhere • Effectively, authentication data must be sent by the client with every request
a shared secret (e.g. client's private API key) • Client uses the secret key to sign requests • Server verifies if the provided signature matches the contents of the request • Can be timestamped to avoid replay attacks