Common REST API Elements

S3 REST Operations are in fact HTTP requests, as defined by RFC 2616 (http://www.ietf.org/rfc/rfc2616.txt). This section describes how S3 uses HTTP, and the parts of HTTP requests and responses that all S3 REST operations have in common. Detailed descriptions of individual operations are provided later in this guide.

A typical REST operation consists of a sending a single HTTP request to S3, followed by waiting for the HTTP response sent from S3 back to you. Like any HTTP request, a request to S3 contains a request method, a URI, a query string, request headers, and sometimes a request body. The response contains a status code, response headers, and sometimes a response body.

Example

Here's an example of a request to get an object named "Nelson" in the "quotes" bucket:

Sample Request

GET /quotes/Nelson HTTP/1.0
Authorization: AWS 15B4D3461F177624206A:Iuyz3d3P0aTou39dzbq7RrtSFmw=
Date: Thu, 17 Nov 2005 02:23:04 GMT

Sample Response

HTTP/1.1 200 OK
x-amz-id-2: qBmKRcEWBBhH6XAqsKU/eg24V3jf/kWKN9dJip1L/FpbYr9FDy7wWFurfdQOEMcY
x-amz-request-id: F2A8CCCA26B4B26D
Date: Thu, 17 Nov 2005 02:23:04 GMT
Last-Modified: Thu, 17 Nov 2005 02:23:06 GMT
ETag: "828ef3fdfa96f00ad9f27c383fc9ac7f"
Content-Type: text/plain
Content-Length: 5
Connection: close
Server: AmazonS3

ha-ha

REST Endpoint

All REST requests to Amazon S3 should be sent to the host s3.amazonaws.com.

Request Method

The GET operation in the preceding example indicates the operation you are trying to carry out. The same operation can have slightly different meanings depending on the URI.

URI

The URI indicates the target of the request. If it contains only one slash, as in =/quotes=, then the URI refers to a bucket. A URI that begins and ends with a slash, and has no slashes in between, like /quotes/, also refers to a bucket. If the URI contains a second slash, with characters after the second slash, as in /quotes/Nelson, then it refers to a specific object.

Request Headers

The following request header can be used with any request: