Query Requests

Query requests are simply HTTP GET requests that return XML.

Here is an sample request that searches for documents about cats:


The AWSAccessKeyID, Timestamp, SignatureVersion and Signature parameters are used to authenticate and authorize your request. The Timestamp and Signature values must be generated anew for each request.

The Action, ResponseGroup, and Query parameters control what results the search engine returns for your query.

AWS uses request authentication to verify that a request came from a registered developer and then identify the account for billing.

The following parameters are required to authenticate each request:

ParameterDescription
AWSAccessKeyId Your AWS Access Key Id
TimestampThe current time in UTC format. Authorization fails if the time stamp differs by more than 15 minutes from the clock on the Amazon servers. The Timestamp must be URL encoded.
Signature A request signature calculated by concatenating the Action name and Timestamp then calculating an RFC 2104-compliant HMAC-SHA1 hash of that string using the Secret Access Key as the key as described below.
[Note]Note

The best way to learn how to sign requests is to see the code samples in the Resource Center for examples using Java, C#, PHP, Perl and Ruby.

If there is no code sample in your language of choice, the following steps describe how to calculate the Timestamp and Signature:

  1. Calculate the Timestamp value in UTC time with format: yyyy-MM-ddTHH:mm:ss.fffZ. For more information see: http://www.w3.org/TR/xmlschema-2/#dateTime
  2. Concatenate the Action name and the Timestamp value.
  3. Create an RFC 2104 compliant HMAC-SHA1 hash on the Action+Timestamp string, using the Secret Access Key as the "key". For more information see: http://www.ietf.org/rfc/rfc2104.txt.
  4. Base64 encode the hash to get the signature.
  5. URL encode the signature. Note: The resulting signature cannot contain any "+"'s. So, for example in C# you must use HttpUtility.UrlPathEncode instead of HttpUtility.UrlEncode. You can find reference charts for URL encoding at i-Technica and W3 Schools.
  6. Pass the computed signature in the Signature parameter of your request.
  7. URL encode the Timestamp value and pass it in the with your request.