sdb-dg

107
Amazon SimpleDB Developer Guide API Version 2009-04-15

Transcript of sdb-dg

Page 1: sdb-dg

Amazon SimpleDBDeveloper Guide

API Version 2009-04-15

Page 2: sdb-dg

Amazon SimpleDB: Developer GuideCopyright © 2010 Amazon Web Services LLC or its affiliates. All rights reserved.

Amazon SimpleDB Developer Guide

Page 3: sdb-dg

Table of ContentsWelcome to Amazon SimpleDB ......................................................................................................................... 1Introduction to Amazon SimpleDB ...................................................................................................................... 2Amazon SimpleDB Concepts ............................................................................................................................. 5

Data Model ............................................................................................................................................. 5Operations .............................................................................................................................................. 7API Summary ......................................................................................................................................... 7Consistency ............................................................................................................................................ 7Concurrent Applications .......................................................................................................................... 8Limits ...................................................................................................................................................... 9Data Set Partitioning ............................................................................................................................. 10AWS Identity and Access Management ................................................................................................ 10

Using Amazon SimpleDB ................................................................................................................................. 12Making API Requests ........................................................................................................................... 12

Region Endpoints ........................................................................................................................ 12Making REST Requests .............................................................................................................. 13Making SOAP Requests .............................................................................................................. 14

Request Authentication ......................................................................................................................... 16What Is Authentication? .............................................................................................................. 17Creating an AWS Account ........................................................................................................... 17Your AWS Identifiers .................................................................................................................... 18HMAC-SHA Signature ................................................................................................................ 19Authenticating REST Requests ................................................................................................... 23SOAP Request Authentication .................................................................................................... 24

SOAP with WS-Security ..................................................................................................... 25SOAP without WS-Security ................................................................................................ 29

Working with Domains .......................................................................................................................... 30Creating a Domain ...................................................................................................................... 30Verifying the Domain ................................................................................................................... 31Deleting a Domain ....................................................................................................................... 32

Working with Data ................................................................................................................................. 32Putting Data into a Domain ......................................................................................................... 32Getting Data from a Domain ........................................................................................................ 33Deleting Data from a Domain ...................................................................................................... 33

Conditionally Putting and Deleting Data ............................................................................................... 34Performing a Conditional Put ....................................................................................................... 34Performing a Conditional Delete .................................................................................................. 37

Using Select to Create Amazon SimpleDB Queries ............................................................................. 38Comparison Operators ................................................................................................................ 39Sample Query Data Set .............................................................................................................. 42Simple Queries ............................................................................................................................ 42Range Queries ............................................................................................................................ 43Queries on Attributes with Multiple Values .................................................................................. 44Multiple Attribute Queries ............................................................................................................ 44Sort .............................................................................................................................................. 45Count ........................................................................................................................................... 46Select Quoting Rules ................................................................................................................... 47

Working with Numerical Data ............................................................................................................... 48Negative Numbers Offsets .......................................................................................................... 48Zero Padding ............................................................................................................................... 48Dates ........................................................................................................................................... 49

Tuning Queries ..................................................................................................................................... 49BoxUsage .................................................................................................................................... 50Data Set Partitioning .................................................................................................................. 50

Working with XML-Restricted Characters ............................................................................................. 51Available AWS Libraries ........................................................................................................................ 52

Amazon SimpleDB Developer Guide

Page 4: sdb-dg

API Reference .................................................................................................................................................. 53API Usage ............................................................................................................................................. 53

API Conventions .......................................................................................................................... 53WSDL Location and API Version ................................................................................................. 54API Error Retries ......................................................................................................................... 55

Common Parameters ............................................................................................................................ 57Common Response Elements .............................................................................................................. 59Common Error Responses ................................................................................................................... 59Operations ............................................................................................................................................ 59

BatchPutAttributes ....................................................................................................................... 60CreateDomain ............................................................................................................................. 64DeleteAttributes ........................................................................................................................... 66DeleteDomain .............................................................................................................................. 71DomainMetadata ......................................................................................................................... 73GetAttributes ............................................................................................................................... 75ListDomains ................................................................................................................................. 78PutAttributes ................................................................................................................................ 80Select .......................................................................................................................................... 86

API Error Codes ............................................................................................................................................... 89Document Conventions .................................................................................................................................... 96Document History ............................................................................................................................................. 99Amazon SimpleDB Glossary ............................................................................................................................ 94Index ............................................................................................................................................................... 101

Amazon SimpleDB Developer Guide

Page 5: sdb-dg

Welcome to Amazon SimpleDB

This is the Developer Guide for Amazon SimpleDB.This guide provides a conceptual overview of AmazonSimpleDB, programming reference material, and a detailed API reference. For a quick overview of AmazonSimpleDB with code samples, go to the Amazon SimpleDB Getting Started Guide.

Amazon SimpleDB is a web service for running queries on structured data in real time.This service worksin close conjunction with Amazon Simple Storage Service (Amazon S3) and Amazon Elastic ComputeCloud (Amazon EC2), collectively providing the ability to store, process and query data sets in the cloud.These services are designed to make web-scale computing easier and more cost-effective for developers.

Relevant SectionsHow Do I...?

Amazon SimpleDB Detail PageLearn if Amazon SimpleDB is right for my use case

Amazon SimpleDB Concepts (p. 5)Learn about Amazon SimpleDB concepts

Using Amazon SimpleDB (p. 12)Learn how to use Amazon SimpleDB

API Reference (p. 53)Find information about Amazon SimpleDBoperations

Amazon SimpleDB Sample Code and LibrariesFind information about Amazon SimpleDB libraries

Amazon SimpleDB ForumsGet help from other developers

API Version 2009-04-151

Amazon SimpleDB Developer Guide

Page 6: sdb-dg

Introduction to Amazon SimpleDB

Topics

• Features (p. 2)

• How Amazon Charges for Amazon SimpleDB (p. 3)

• Viewing Your Bill (p. 4)

This introduction to Amazon SimpleDB is intended to give you a detailed summary of this web service.After reading this section, you should have a good idea of what it offers and how it can fit in with yourbusiness.

Traditionally, the type of functionality provided by Amazon SimpleDB has been accomplished with aclustered relational database that requires a sizable upfront investment, brings more complexity than istypically needed, and often requires a DBA to maintain and administer. In contrast, Amazon SimpleDBis easy to use and provides the core functionality of a database - real-time lookup and simple queryingof structured data - without the operational complexity. Amazon SimpleDB requires no schema,automatically indexes your data and provides a simple API for storage and access. This eliminates theadministrative burden of data modeling, index maintenance, and performance tuning. Developers gainaccess to this functionality within Amazon's proven computing environment, are able to scale instantly,and pay only for what they use.

FeaturesFollowing are some of the major Amazon SimpleDB attributes:

Features

• Simple to use—Amazon SimpleDB provides streamlined access to the lookup and query functionsthat traditionally are achieved using a relational database cluster while leaving out other complex,often-unused database operations.The service allows you to quickly add data and easily retrieve or edit that data through a simple set ofAPI calls. Accessing these capabilities through a web service also eliminates the complexity ofmaintaining and scaling these operations

• Flexible—With Amazon SimpleDB, it is not necessary to pre-define all of the data formats you willneed to store; simply add new attributes to your Amazon SimpleDB data set when needed, and thesystem will automatically index your data accordingly.

API Version 2009-04-152

Amazon SimpleDB Developer GuideFeatures

Page 7: sdb-dg

The ability to store structured data without first defining a schema provides developers with greaterflexibility when building applications.

• Scalable—Amazon SimpleDB allows you to easily scale your application.You can quickly create newdomains as your data grows or your request throughput increases.Currently, you can store up to 10 GB per domain and you can create up to 100 domains.

• Fast—Amazon SimpleDB provides quick, efficient storage and retrieval of your data to support highperformance web applications.

• Reliable—The service runs within Amazon's high-availability data centers to provide strong andconsistent performance.To prevent data from being lost or becoming unavailable, your fully indexed data is stored redundantlyacross multiple servers and data centers.

• Designed for use with other Amazon Web Services—Amazon SimpleDB is designed to integrateeasily with other web-scale services such as Amazon EC2 and Amazon S3.For example, developers can run their applications in Amazon EC2 and store their data objects inAmazon S3. Amazon SimpleDB can then be used to query the object metadata from within the applicationin Amazon EC2 and return pointers to the objects stored in Amazon S3.

• Inexpensive—Amazon SimpleDB passes on to you the financial benefits of Amazon's scale.You payonly for resources you actually consume.Compare this with the significant up-front expenditures traditionally required to obtain software licensesand purchase and maintain hardware, either in-house or hosted. This frees you from many of thecomplexities of capacity planning, transforms large capital expenditures into much smaller operatingcosts, and eliminates the need to over-buy "safety net" capacity to handle periodic traffic spikes.

How Amazon Charges for Amazon SimpleDBAmazon SimpleDB pricing is based on your actual usage.Your usage is measured and rounded up tothe nearest cent.

Amazon SimpleDB charges you for the following types of usage:

• Structured Data Storage—Measures the size of your billable data by adding the raw byte size of thedata you upload + 45 bytes of overhead for each item, attribute name and attribute-value pair.

• Data Transfer—Measures the amount of data transferred for every operation.Data transferred between Amazon SimpleDB and other Amazon Web Services (e.g., Amazon S3,Amazon EC2, Amazon SQS, and others) is free of charge.

• Machine Utilization—Measures the machine utilization of each request and charges based on theamount of machine capacity used to complete the particular request (SELECT, GET, PUT, etc.).

Note

Amazon Web Services provides a free tier of Amazon SimpleDB usage.The free tier is a monthlyoffer. Free usage does not accumulate.

Any data stored as part of the free tier program must be actively used. If a domain is not accessedfor a period of 6 months, it will be subject to removal at the discretion of Amazon Web Services.

StorageYou are charged for the amount of storage your data uses each month which can be considered anaverage of the month. For example, if you use one gigabyte for the month, you are charged for one

API Version 2009-04-153

Amazon SimpleDB Developer GuideHow Amazon Charges for Amazon SimpleDB

Page 8: sdb-dg

gigabyte of storage. If you use zero gigabytes for the first half of the month and two gigabytes for thesecond half, you are also charged for one gigabyte of storage.

Several times each day, Amazon SimpleDB measures the amount of storage used by all of the objectsin your account. Amazon SimpleDB stores this information in byte-hours and averages it with all otherrecorded measurements at the end of the billing cycle.

Data TransferAmazon charges you for the amount of data transferred into and out of Amazon SimpleDB. For everyoperation, Amazon SimpleDB monitors the amount of data sent and received and records the data. Onceper hour, the usage total is recorded to your account. This information is stored and totaled at the end ofthe billing cycle.

Viewing Your BillYou can view the charges for your current billing period at any time by going to the AWS Portal.

To view your activity

1. Log in to your AWS account.

2. Move the pointer over Your Web Services Account.

3. Click Account Activity.

A list of services to which you subscribe appears.

4. Locate the Amazon SimpleDB service.

DescriptionBilling Component

Enables you to view or change settings associated with the Amazon SimpleDBservice.

View/Edit Service Button

Shows the machine hour usage cost, current number of hours consumed,and billing for the current cycle.

Machine Hour Usage

Shows the data transfer cost, current amount of data transferred, and billingfor the current cycle.

Data Transferred

Shows the storage usage cost, average amount of storage consumed, andbilling for the current cycle.

Storage

Shows detailed data used to calculate your bill.Usage Report

API Version 2009-04-154

Amazon SimpleDB Developer GuideData Transfer

Page 9: sdb-dg

Amazon SimpleDB Concepts

Topics

• Data Model (p. 5)

• Operations (p. 7)

• API Summary (p. 7)

• Consistency (p. 7)

• Concurrent Applications (p. 8)

• Limits (p. 9)

• Data Set Partitioning (p. 10)

• AWS Identity and Access Management (p. 10)

This section describes the key concepts that you should understand before using Amazon SimpleDB.

Data ModelWhen using Amazon SimpleDB, you organize your structured data in domains within which you can putdata, get data, or run queries.

Domains consist of items which are described by attribute name-value pairs. For a better understanding,consider the spreadsheet model shown in the following image.

API Version 2009-04-155

Amazon SimpleDB Developer GuideData Model

Page 10: sdb-dg

The components correspond to each part of a spreadsheet:

• Customer Account—Represented by the entire spreadsheet, it refers to the Amazon Web Servicesaccount to which all domains are assigned.

• Domains—Represented by the domain worksheet tabs at the bottom of the spreadsheet, domains aresimilar to tables that contain similar data.You can execute queries against a domain, but cannot execute queries across different domains.

• Items—Represented by rows, items represent individual objects that contain one or more attributename-value pairs.

• Attributes—Represented by columns, attributes represent categories of data that can be assigned toitems.

• Values—Represented by cells, values represent instances of attributes for items. An attribute can havemultiple values.

Unlike a spreadsheet, however, multiple values can be associated with a cell. For example, an item canhave both the color value red and blue. Additionally, Amazon SimpleDB does not require the presenceof specific attributes.You can create a single domain that contains completely different product types.For example, the following table contains clothing, automotive parts, and motorcycle parts.

ModelMakeSizeColorNameSubcat.CategoryID

Small,Medium,Large

SiameseCathairSweater

SweaterClothesItem_01

30x32,32x32,32x34

PaisleyAcid Wash

DesignerJeans

PantsClothesItem_02

LargeBlue,Yellow,Pink

SweatpantsPantsClothesItem_03

S4AudiTurbosEngineCar PartsItem_04

S4Audi02 SensorEmissionsCar PartsItem_05

R1YamahaBlueFenderEliminator

BodyworkMotorcycleParts

Item_06

API Version 2009-04-156

Amazon SimpleDB Developer GuideData Model

Page 11: sdb-dg

ModelMakeSizeColorNameSubcat.CategoryID

Small,Medium,Large

BlackLeatherPants

ClothingMotorcycleParts,Clothing

Item_07

Regardless of how you store your data, Amazon SimpleDB automatically indexes your data for quick andaccurate retrieval.

OperationsThe following describes components of Amazon SimpleDB operations.

• Subscriber—Any application, script, or software making a call to the Amazon SimpleDB service.The AWS Access Key ID uniquely identifies each subscriber for billing and metering purposes.

• Amazon SimpleDB Request—A single web service API call and its associated data that the subscribersends to the Amazon SimpleDB service to perform one or more operations.

• Amazon SimpleDB Response—The response and any results returned from the Amazon SimpleDBservice to the subscriber after processing the request.The AWS Platform handles authentication success and failure; failed requests are not sent to theAmazon SimpleDB service.

API SummaryThe Amazon SimpleDB service consists of a small group of API calls that provide the core functionalityyou need to build your application. Detailed information is provided later in this guide.

• CreateDomain—Create domains to contain your data; you can create up to 100 domains. If you requireadditional domains, go to http://aws.amazon.com/contact-us/simpledb-limit-request/.

• DeleteDomain—Delete any of your domains

• ListDomains—List all domains within your account

• PutAttributes—Add, modify, or remove data within your Amazon SimpleDB domains

• BatchPutAttributes—Generate multiple put operations in a single call

• DeleteAttributes—Remove items, attributes, or attribute values from your domain

• GetAttributes—Retrieve the attributes and values of any item ID that you specify

• Select—Query the specified domain using a SQL SELECT expression

• DomainMetadata—View information about the domain, such as the creation date, number of itemsand attributes, and the size of attribute names and values

ConsistencyAmazon SimpleDB keeps multiple copies of each domain. A successful write (using PutAttributes,BatchPutAttributes, DeleteAttributes, CreateDomain, or DeleteDomain) guarantees that all copies of thedomain will durably persist.

Amazon SimpleDB supports two read consistency options: eventually consistent read and consistentread.

API Version 2009-04-157

Amazon SimpleDB Developer GuideOperations

Page 12: sdb-dg

An eventually consistent read (using Select or GetAttributes) might not reflect the results of a recentlycompleted write (using PutAttributes, BatchPutAttributes, or DeleteAttributes). Consistency across allcopies of the data is usually reached within a second; repeating a read after a short time should returnthe updated data.

A consistent read (using Select or GetAttributes with ConsistentRead=true) returns a result thatreflects all writes that received a successful response prior to the read.

By default, GetAttributes and Select perform an eventually consistent read.

The following table describes the characteristics of eventually consistent read and consistent read.

Consistent ReadEventually Consistent Read

No stale readsStale reads possible

Potential higher read latencyLowest read latency

Potential lower read throughputHighest read throughput

Concurrent ApplicationsThis section provides examples of eventually consistent and consistent read requests when multipleclients are writing to the same items.

In this example, both W1 (write 1) and W2 (write 2) complete before the start of R1 (read 1) and R2 (read2). For a consistent read, R1 and R2 both return color = ruby. For an eventually consistent read, R1and R2 might return color = red, color = ruby, or no results, depending on the amount of time thathas elapsed.

In the next example, W2 does not complete before the start of R1. Therefore, R1 might return color =ruby or color = garnet for either a consistent read or an eventually consistent read. Also, dependingon the amount of time that has elapsed, an eventually consistent read might return no results.

For a consistent read, R2 returns color = garnet. For an eventually consistent read, R2 might returncolor = ruby, color = garnet, or no results depending on the amount of time that has elapsed.

In the last example, Client 2 performs W2 before Amazon SimpleDB returns a success for W1, so theoutcome of the final value is unknown (color = garnet or color = brick). Any subsequent reads

API Version 2009-04-158

Amazon SimpleDB Developer GuideConcurrent Applications

Page 13: sdb-dg

(consistent read or eventually consistent) might return either value. Also, depending on the amount oftime that has elapsed, an eventually consistent read might return no results.

LimitsFollowing is a table that describes current limits within Amazon SimpleDB.

RestrictionParameter

10 GB per domainDomain size

1 billion attributes per domainDomain size

3-255 characters (a-z, A-Z, 0-9, '_', '-', and '.')Domain name

100Domains per account

256Attribute name-value pairs per item

1024 bytesAttribute name length

1024 bytesAttribute value length

1024 bytesItem name length

All UTF-8 characters that are valid in XML documents.

Control characters and any sequences that are not valid inXML are returned Base64-encoded. For more information,see Working with XML-Restricted Characters (p. 51).

Attribute name, attribute value, and itemname allowed characters

256Attributes per PutAttributesoperation

256Attributes requested per Selectoperation

25Items perBatchPutAttributesoperation

2500Maximum items in Selectresponse

5 secondsMaximum query execution time

20Maximum number of unique attributesper Selectexpression

20Maximum number of comparisons perSelectexpression

1MBMaximum response size for Select

API Version 2009-04-159

Amazon SimpleDB Developer GuideLimits

Page 14: sdb-dg

Data Set PartitioningAmazon SimpleDB is designed to support highly parallel applications. To improve performance, you canpartition your dataset among multiple domains to parallelize queries and have them operate on smallerindividual datasets. Although you can only execute a single query against a single domain, you canperform aggregation of the result sets in the application layer. The following is a list of applications thatlend themselves to parallelized queries:

• Natural Partitions—The data set naturally partitions along some dimension. For example, a productcatalog might be partitioned in the "Book", "CD" and "DVD" domains. Although you can store all theproduct data in a single domain, partitioning can improve overall performance.

• High Performance Application—Useful when the application requires higher throughput than a singledomain can provide.

• Large Data Set—Useful when timeout limits are reached because of the data size or query complexity.

In cases where data sets do not partition easily (e.g., logs, events, web crawler data), you can use hashingalgorithms to create a uniform distribution of items among multiple domains.

For example, you can determine the hash of an item name using a well-behaved hash function, such asMD5 and use the last 2 bits of the resulting hash value to place each item in a specified domain.

• If last two bits equal 00, place item in Domain0

• If last two bits equal 01, place item in Domain1

• If last two bits equal 10, place item in Domain2

• If last two bits equal 11, place item in Domain3

This algorithm provides a distribution of items among domains, uniformity of which is directly controlledby the hash function. The additional advantage of this scheme is the ease with which it can be adjustedto partition your data among larger number of domains by considering more and more bits of the hashvalue (3 bits will distribute to 8 domains, 4 bits to 16 domains and so on).

AWS Identity and Access ManagementAmazon SimpleDB integrates with AWS Identity and Access Management (IAM), a service that lets yourorganization do the following:

• Create users and groups under your organization's AWS Account

• Easily share your AWS Account resources between the users in the account

• Assign unique security credentials to each user

• Granularly control users access to services and resources

• Get a single AWS bill for all users in the AWS Account

For example, you can use IAM to control access to a specific domain that your AWS Account owns.

For general information about IAM, go to:

• Identity and Access Management (IAM)

• AWS Identity and Access Management Getting Started Guide

• Using AWS Identity and Access Management

API Version 2009-04-1510

Amazon SimpleDB Developer GuideData Set Partitioning

Page 15: sdb-dg

For specific information about how you can control User access to Amazon SimpleDB, go to Integratingwith Other AWS Products in Using AWS Identity and Access Management.

API Version 2009-04-1511

Amazon SimpleDB Developer GuideAWS Identity and Access Management

Page 16: sdb-dg

Using Amazon SimpleDB

Topics

• Making API Requests (p. 12)

• Request Authentication (p. 16)

• Working with Domains (p. 30)

• Working with Data (p. 32)

• Conditionally Putting and Deleting Data (p. 34)

• Using Select to Create Amazon SimpleDB Queries (p. 38)

• Working with Numerical Data (p. 48)

• Tuning Queries (p. 49)

• Working with XML-Restricted Characters (p. 51)

• Available AWS Libraries (p. 52)

This section describes major concepts you should understand before building your Amazon SimpleDBapplication.

Making API RequestsTopics

• Region Endpoints (p. 12)

• Making REST Requests (p. 13)

• Making SOAP Requests (p. 14)

This section describes how to make REST and SOAP requests.

Region EndpointsTo improve latency and to store data in a location that meets your requirements, Amazon SimpleDBenables you to select different region endpoints.

Amazon SimpleDB supports the following endpoints:

• sdb.amazonaws.com—Endpoint located in the US-East (Northern Virginia) Region

API Version 2009-04-1512

Amazon SimpleDB Developer GuideMaking API Requests

Page 17: sdb-dg

• sdb.us-west-1.amazonaws.com—Endpoint located in the US-West (Northern California) Region

• sdb.eu-west-1.amazonaws.com —Endpoint located in the EU (Ireland) Region

• sdb.ap-southeast-1.amazonaws.com —Endpoint located in the Asia Pacific (Singapore) Region

For example, to create a SimpleDB domain in Europe, you would generate a REST request similar to thefollowing:

https://sdb.eu-west-1.amazonaws.com/?Action=CreateDomain&DomainName=MyDomain&<authentication parameters>

Each Amazon SimpleDB endpoint is entirely independent. For example, if you have two domains called"MyDomain," one in sdb.amazonaws.com and one in sdb.eu-west-1.amazonaws.com, they are completelyindependent and do not share any data.

Making REST RequestsTopics

• About REST Requests (p. 13)

• Using Parameters with REST (p. 13)

• Parameters Specific to REST Requests (p. 13)

• Sample REST Request (p. 14)

This section provides information on making REST requests with the Amazon SimpleDB web service.

About REST RequestsAmazon SimpleDB REST calls are made using HTTP GET requests.The Action query parameter providesthe method called and the URI specifies the target of the call. Additional call parameters are specified asHTTP query parameters. The response is an XML document that conforms to a schema.

Note

If the length of the query string that you are constructing exceeds the maximum length of theHTTP GET URL, use HTTP POST and submit the query string parameters in the body of themessage.

Using Parameters with RESTIn a REST request, the components are specified as separate parameters that are prefixed with anampersand (&). The following is an example of the DomainName parameter. &DomainName=MyDomain

Parameters that have components start with the main parameter name (such as Attribute), a dot, asequence number, a dot, and the component name (such as Name). For example:&Attribute.1.Name=Color.

Parameters Specific to REST RequestsIn addition to the parameters found in request data structures, REST requests have parameters to indicatethe name of the service and the version of the API. For more information about these parameters andtheir values, see API Conventions (p. 53) and WSDL Location and API Version (p. 54).

API Version 2009-04-1513

Amazon SimpleDB Developer GuideMaking REST Requests

Page 18: sdb-dg

Sample REST RequestThis section provides a sample REST request and response.

REST Request

The following shows a REST request that puts three attributes and values for an item named Item123into the domain named MyDomain.

https://sdb.amazonaws.com/?Action=PutAttributes&DomainName=MyDomain&ItemName=Item123&Attribute.1.Name=Color&Attribute.1.Value=Blue&Attribute.2.Name=Size&Attribute.2.Value=Med&Attribute.3.Name=Price&Attribute.3.Value=0014.99&AWSAccessKeyId=<valid_access_key>&Version=2009-04-15&Signature=[valid signature]&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A01%3A28-07%3A00

REST Response

The following is the sample response:

<PutAttributesResponse> <ResponseMetadata> <StatusCode>Success</StatusCode> <RequestId>f6820318-9658-4a9d-89f8-b067c90904fc</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></PutAttributesResponse>

Making SOAP RequestsTopics

• About SOAP Requests (p. 14)

• Using Parameters with SOAP (p. 15)

• Sample SOAP Request (p. 15)

This section provides information on making SOAP requests with the Amazon SimpleDB web service.

About SOAP RequestsThe Amazon SimpleDB web service supports the SOAP message protocol for calling service operationsover an HTTPS connection. The easiest way to use the SOAP interface with your application is to use aSOAP toolkit. SOAP toolkits are available for most popular programming languages and platforms.

The service's Web Services Definition Language (WSDL) file describes the operations and the formatand data types of their requests and responses.Your SOAP toolkit interprets the WSDL file to provideyour application access to the operations. For most toolkits, your application calls a service operationusing routines and classes provided or generated by the toolkit.

API Version 2009-04-1514

Amazon SimpleDB Developer GuideMaking SOAP Requests

Page 19: sdb-dg

For information on the WSDL file, see API Conventions (p. 53).

Using Parameters with SOAPThe API reference in this guide describes the parameters and their values for each operation.You mightfind it useful to view the WSDL file directly to see how the request parameters appear in the XML thatyour toolkit generates.You can also see how your toolkit makes the operations available to your applicationcode.

Sample SOAP RequestThis section provides a sample REST request and response.

The request element contains the AWSAccessKeyId, Timestamp, and Signature. These authenticatethat you sent the request. For more information on these values, see AWS Request Authentication.

In addition to the request authentication parameters, the request element contains the parameters of thespecific operation being called. For a description of an operation's parameters, see the appropriate pagefor the operation in the API reference.

For more information about these parameters and their values, see Common Parameters.

SOAP Request

The following example is the XML for a SOAP message that calls the PutAttributes operation. Whileyou probably don't need to build the SOAP message for a service request manually, it is useful to seewhat your SOAP toolkit tries to produce when provided with the appropriate values. Many SOAP toolkitsrequire that you build a request data structure similar to the XML to make a request.

In this example the PutAttributes element contains:

• DomainName element which is common to all operations

• ItemName element that is used in some, but not all operations

<?xml version='1.0' encoding='UTF-8'?><SOAP-ENV:Envelopexmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'xmlns:xsd='http://www.w3.org/2001/XMLSchema'> <SOAP-ENV:Body> <PutAttributesRequest xmlns='http://sdb.amazonaws.com/doc/2009-04-15'> <Attribute><Name>a1</Name><Value>2</Value></Attribute> <Attribute><Name>a2</Name><Value>4</Value></Attribute> <DomainName>domain1</DomainName> <ItemName>eID001</ItemName> <Version>2009-04-15</Version> </PutAttributesRequest> </SOAP-ENV:Body></SOAP-ENV:Envelope>

SOAP Response

Following is the sample response.

API Version 2009-04-1515

Amazon SimpleDB Developer GuideMaking SOAP Requests

Page 20: sdb-dg

<?xml version="1.0"?><SOAP-ENV:Envelopexmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body> <PutAttributesResponse> <ResponseMetadata> <RequestId>4c68e051-fe45-43b2-992a-a24017ffe7ab</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata> </PutAttributesResponse> </SOAP-ENV:Body></SOAP-ENV:Envelope>

Request AuthenticationTopics

• What Is Authentication? (p. 17)

• Creating an AWS Account (p. 17)

• Your AWS Identifiers (p. 18)

• HMAC-SHA Signature (p. 19)

• Authenticating REST Requests (p. 23)

• SOAP Request Authentication (p. 24)

This section explains how Amazon SimpleDB authenticates your requests.

API Version 2009-04-1516

Amazon SimpleDB Developer GuideRequest Authentication

Page 21: sdb-dg

What Is Authentication?Authentication is a process for identifying and verifying who is sending a request. The following diagramshows a simplified version of an authentication process.

General Process of Authentication

The sender obtains the necessary credential.

The sender sends a request with the credential to the recipient.

The recipient uses the credential to verify the sender truly sent the request.

If yes, the recipient processes the request. If no, the recipient rejects the request andresponds accordingly.

During authentication, Amazon Web Services (AWS) verifies both the identity of the sender and whetherthe sender is registered to use services offered by AWS. If either test fails, the request is not processedfurther.

For further discussion of authentication, go to the techencylopedia.com entry for authentication. Fordefinitions of common industry terms related to authentication, go to the RSA Laboratories Glossary.

The subsequent sections describe how Amazon SimpleDB implements authentication to protect you andyour customers' data.

Creating an AWS AccountTo access any web service AWS offers, you must first create an AWS account at http://aws.amazon.com.An AWS account is simply an Amazon.com account that is enabled to use AWS products; you can usean existing Amazon.com account login and password when creating the AWS account.

Important

If you have a personal Amazon.com account, you might want to have a separate Amazon.comaccount just for your AWS activity.You could provide a new e-mail address not already in theAmazon.com system, or provide an e-mail address for an existing Amazon.com account you

API Version 2009-04-1517

Amazon SimpleDB Developer GuideWhat Is Authentication?

Page 22: sdb-dg

have but use a different password.You can have multiple Amazon.com accounts that use thesame e-mail address, but different passwords.

From your AWS account you can view your AWS account activity, view usage reports, and manage yourAWS account access identifiers.

To set up a new account

1. Go to http://aws.amazon.com.

2. In the Sign Up for AWS box, click Sign up today.

The Sign In page is displayed.

3. Enter a valid e-mail address, select the button for No, I am a new customer, and click Continue.

The next page asks for the name you want associated with the account (e.g., Joe Smith) and apassword for the account. If you're using an e-mail address already in the Amazon.com system, thepage indicates that this is an existing address, but still lets you create a new account with it.

4. Enter the name you want associated with the account and a password and click Continue.

The Account Info page is displayed.

5. Enter your contact information and select how you learned about AWS.

6. Read the AWS Customer Agreement, select the check box to indicate that you've read and agreeto the terms of the customer agreement, and click Continue.

The process is complete and you've created your new AWS account.

Your AWS IdentifiersWhen you create an AWS account, AWS assigns you a pair of related identifiers:

• Access Key ID (a 20-character, alphanumeric sequence)For example: 022QF06E7MXBSH9DHM02

• Secret Access Key (a 40-character sequence)For example: kWcrlUX5JEDGM/LtmEENI/aVmYvHNif5zB+d9+ct

These are your AWS access key identifiers.

Caution

Your Secret Access Key is a secret, which only you and AWS should know. It is important tokeep it confidential to protect your account. Store it securely in a safe place. Never include it inyour requests to AWS, and never e-mail it to anyone. Do not share it outside your organization,even if an inquiry appears to come from AWS or Amazon.com. No one who legitimately representsAmazon will ever ask you for your Secret Access Key.

Never embed your Secret Access Key into client-side applications.

The Access Key ID is associated with your AWS account.You include it in AWS service requests toidentify yourself as the sender of the request.

The Access Key ID is not a secret, and anyone could use your Access Key ID in requests to AWS. Toprovide proof that you truly are the sender of the request, you must also include a digital signature. AWSuses the Access Key ID in the request to look up your Secret Access Key and then calculates a digitalsignature with the key. If the signature AWS calculates matches the signature you sent, the request is

API Version 2009-04-1518

Amazon SimpleDB Developer GuideYour AWS Identifiers

Page 23: sdb-dg

considered authentic. Otherwise, the request fails authentication and is not processed. For more details,see HMAC-SHA Signature (p. 19).

Viewing Your AWS IdentifiersYour Access Key ID and Secret Access Key are displayed to you when you create your AWS account.They are not e-mailed to you. If you need to see them again, you can view them at any time from yourAWS account.

To view your AWS access identifiers

1. Go to the Amazon Web Services web site at http://aws.amazon.com.

2. Point to Your Web Services Account to display a list of options.

3. Click AWS Access Identifiers and log in to your AWS account.

Your Access Key ID and Secret Access Key are displayed on the resulting AWS Access Identifierspage. Following is an example of this page.

HMAC-SHA Signature

Required Authentication InformationWhen accessing Amazon SimpleDB using SOAP (without using WS-Security) or REST, you must providethe following items so the request can be authenticated:

API Version 2009-04-1519

Amazon SimpleDB Developer GuideHMAC-SHA Signature

Page 24: sdb-dg

Authentication

• AWSAccessKeyId—Your AWS account is identified by your Access Key ID, which AWS uses to lookup your Secret Access Key.

• Signature—Each request must contain a valid HMAC-SHA signature, or the request is rejected.A request signature is calculated using your Secret Access Key, which is a shared secret known onlyto you and AWS.

• Date—Each request must contain the time stamp of the request.Depending on the API you're using, you can provide an expiration date and time for the request insteadof or in addition to the time stamp. For details of what is required and allowed for each API, see theauthentication topic for the particular API.

Authentication ProcessFollowing is the series of tasks required to authenticate requests to AWS using an HMAC-SHA requestsignature. It is assumed you have already created an AWS account and received an Access Key ID andSecret Access Key. For more information about those, see Creating an AWS Account (p. 17) and YourAWS Identifiers (p. 18).

You perform the first three tasks.

Process for Authentication:Tasks You Perform

You construct a request to AWS.

You calculate a keyed-hash message authentication code (HMAC-SHA) signature usingyour Secret Access Key (for information about HMAC, go tohttp://www.faqs.org/rfcs/rfc2104.html)

You include the signature and your Access Key ID in the request, and then send the requestto AWS.

AWS performs the next three tasks.

API Version 2009-04-1520

Amazon SimpleDB Developer GuideHMAC-SHA Signature

Page 25: sdb-dg

Process for Authentication:Tasks AWS Performs

AWS uses the Access Key ID to look up your Secret Access Key.

AWS generates a signature from the request data and the Secret Access Key using thesame algorithm you used to calculate the signature you sent in the request.

If the signature generated by AWS matches the one you sent in the request, the request isconsidered authentic. If the comparison fails, the request is discarded, and AWS returns anerror response.

The procedure for creating the HMAC-SHA signature varies based on the API you're using. See theAPI-specific authentication topic for instructions on how to create the signature:

• Authenticating REST Requests (p. 23)

• SOAP without WS-Security (p. 29)

About the Time StampThe time stamp (or expiration time) you use in the request must be a dateTime object, with the completedate plus hours, minutes, and seconds (for more information, go tohttp://www.w3.org/TR/xmlschema-2/#dateTime). For example: 2010-01-31T23:59:59Z. Although it is notrequired, we recommend you provide the time stamp in the Coordinated Universal Time (GreenwichMean Time) time zone.

If you specify a time stamp (instead of an expiration time), the request automatically expires 15 minutesafter the time stamp (in other words, AWS does not process a request if the request time stamp is morethan 15 minutes earlier than the current time on AWS servers). Make sure your server's time is setcorrectly.

Important

If you are using .NET you must not send overly specific time stamps, due to different interpretationsof how extra time precision should be dropped. To avoid overly specific time stamps, manuallyconstruct dateTime objects with no more than millisecond precision.

API Version 2009-04-1521

Amazon SimpleDB Developer GuideHMAC-SHA Signature

Page 26: sdb-dg

Java Sample Code for Base64 EncodingHMAC-SHA request signatures must be base64 encoded. The following Java sample code shows howto perform base64 encoding.

package amazon.webservices.common; /** * This class defines common routines for encoding * data in AWS Platform re quests. */ public class Encoding { /** * Performs base64-encoding of input bytes. * * @param rawData * Array of bytes to be encoded. * @return * The base64 encoded string representation of rawData. */ public static String EncodeBase64(byte[] rawData) { return Base64.encodeBytes(rawData); } }

Java Sample Code for Calculating HMAC-SHA1 SignaturesThe following Java code sample shows how to calculate an HMAC request signature.

package amazon.webservices.common;

import java.security.SignatureException; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec;

/** * This class defines common routines for generating * authentication signatures for AWS Platform requests. */ public class Signature { private static final String HMAC_SHA1_ALGORITHM = "HmacSHA1";

/** * Computes RFC 2104-compliant HMAC signature. * * @param data * The data to be signed. * @param key * The signing key. * @return * The Base64-encoded RFC 2104-compliant HMAC signature. * @throws * java.security.SignatureException when signature generation fails */ public static String calculateRFC2104HMAC(String data, String key) throws java.security.SignatureException { String result; try {

API Version 2009-04-1522

Amazon SimpleDB Developer GuideHMAC-SHA Signature

Page 27: sdb-dg

// get an hmac_sha1 key from the raw key bytes SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), HMAC_SHA1_AL GORITHM);

// get an hmac_sha1 Mac instance and initialize with the signing key Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM); mac.init(signingKey);

// compute the hmac on input data bytes byte[] rawHmac = mac.doFinal(data.getBytes());

// base64-encode the hmac result = Encoding.EncodeBase64(rawHmac);

} catch (Exception e) { throw new SignatureException("Failed to generate HMAC : " + e.getMessage()); } return result; } }

Authenticating REST RequestsYou can send REST requests over either HTTP or HTTPS. Regardless of which protocol you use, youmust include a signature in every REST request. This section describes how to create the signature. Themethod described in the following procedure is known as signature version 2.

API Version 2009-04-1523

Amazon SimpleDB Developer GuideAuthenticating REST Requests

Page 28: sdb-dg

Example PutAttributes Request

https://sdb.amazonaws.com/?Action=PutAttributes&DomainName=MyDomain&ItemName=Item123&Attribute.1.Name=Color&Attribute.1.Value=Blue&Attribute.2.Name=Size&Attribute.2.Value=Med&Attribute.3.Name=Price&Attribute.3.Value=0014.99&Version=2009-04-15&Timestamp=2010-01-25T15%3A01%3A28-07%3A00&SignatureVersion=2&SignatureMethod=HmacSHA256&AWSAccessKeyId=<Your AWS Access Key ID>

Following is the string to sign.

GET\nsdb.amazonaws.com\n/\nAWSAccessKeyId=<Your AWS Access Key ID>&Action=PutAttributes&Attribute.1.Name=Color&Attribute.1.Value=Blue&Attribute.2.Name=Size&Attribute.2.Value=Med&Attribute.3.Name=Price&Attribute.3.Value=0014.99&DomainName=MyDomain&ItemName=Item123&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2010-01-25T15%3A01%3A28-07%3A00&Version=2009-04-15

Following is the signed request.

https://sdb.amazonaws.com/?Action=PutAttributes&DomainName=MyDomain&ItemName=Item123&Attribute.1.Name=Color&Attribute.1.Value=Blue&Attribute.2.Name=Size&Attribute.2.Value=Med&Attribute.3.Name=Price&Attribute.3.Value=0014.99&Version=2009-04-15&Timestamp=2010-01-25T15%3A01%3A28-07%3A00&Signature=<URLEncode(Base64Encode(Signature))>&SignatureVersion=2&SignatureMethod=HmacSHA256&AWSAccessKeyId=<Your AWS Access Key ID>

SOAP Request AuthenticationTopics

• Requirements (p. 25)

• SOAP with WS-Security (p. 25)

API Version 2009-04-1524

Amazon SimpleDB Developer GuideSOAP Request Authentication

Page 29: sdb-dg

• SOAP without WS-Security (p. 29)

You can authenticate SOAP requests with WS-Security version 1.0 or without WS-Security. WS-Securityis the more secure method. The main factor affecting whether you choose to use WS-Security is whetheryour current SOAP toolkit supports WS-Security.

RequirementsYou must send all SOAP requests over HTTPS regardless of whether you're using WS-Security.

If you are using WS-Security, you must use an X.509 certificate for authentication (Amazon Web Servicescan provide you with a certificate if you do not have one).

If you aren't using WS-Security, you must use SOAP 1.1; SOAP 1.2 is not supported.

SOAP with WS-SecurityWS-Security, which is officially called Web Services Security: SOAP Message Security, is an openstandard published by OASIS that defines mechanisms for signing and encrypting SOAP messages.Amazon SimpleDB supports version 1.0 of the WS-Security specification. For more information and alink to the WS-Security 1.0 specification, go to the OASIS-Open web site for WS-Security.

Tip

The easiest way to comply with the WS-Security requirements is to use a SOAP toolkit thatsupports WS-Security 1.0 and X.509 certificates. If you know your current SOAP toolkit doesn'tsupport WS-Security, we recommend you pursue the non-WS-Security method (for moreinformation, see SOAP without WS-Security (p. 29)).

HTTPS

For the purposes of request security and integrity, you must send all SOAP requests over HTTPS.

X.509 Certificates

When using SOAP with WS-Security, you must use an X.509 certificate for authentication (as opposedto your AWS Secret Access Key). An X.509 certificate is a security token designed to carry a public keyand bind that key to an identity. X.509 certificates are used in a public key infrastructure (PKI), which isa framework for allowing trusted third parties to vouch for a party's identity. PKIs are commonly used insituations that require authentication. For more information about PKIs and X.509 certificates, go to thetechencyclopedia.com entries for digital certificate and PKI.

Note

AWS does not implement a full public key infrastructure. The certificate information is used onlyto authenticate requests to AWS. AWS uses X.509 certificates only as carriers for public keysand does not trust or use in any way any identity binding that might be included in an X.509certificate.

The WS-Security 1.0 specification requires you to sign the SOAP message with the private key associatedwith the X.509 certificate and include the X.509 certificate in the SOAP message header. Specifically,you must represent the X.509 certificate as a BinarySecurityToken as described in the WS-SecurityX.509 token profile (also available if you go to the OASIS-Open web site).

API Version 2009-04-1525

Amazon SimpleDB Developer GuideSOAP Request Authentication

Page 30: sdb-dg

You can use your own X.509 certificate or one generated by AWS. Following are the procedures foruploading your own certificate to AWS and obtaining an AWS-generated certificate. To obtain an X.509certificate generated by an external certificate authority, follow the instructions provided by that CA.

Using Your Own Certificate

If you have an X.509 certificate you want to use, you can upload the certificate to AWS (without the privatekey value). Uploading the certificate automatically associates it with your AWS account.

AWS accepts any syntactically and cryptographically valid X.509 certificate. Certificates can be self-signedor signed by any key. The certificate must be in Privacy Enhanced Mail (PEM) format and include abase64 encoded Distinguished Encoding Rules (DER) certificate body.

Important

When you upload the certificate, AWS checks the certificate's contents to confirm that the certificatehas not expired. AWS doesn't check certificate revocation lists (CRLs) to determine if the certificatehas been revoked, nor does AWS validate the certificate with a certificate authority (CA) or anytrusted third parties.

To upload your own X.509 certificate

1. Go to the Amazon Web Services web site at http://aws.amazon.com.

2. Point to Your Web Services Account to display a list of options.

3. Click View Access Key Identifiers and log in to your AWS account.

The AWS Access Key Identifiers page is displayed.

4. Scroll down to the X.509 Certificate area of the page and click Upload.

5. Follow the instructions on the subsequent pages to upload your certificate.

Using a Certificate Generated by AWS

If you don't already have an X.509 certificate, or if you want a new certificate to use with AWS, you canhave AWS generate one and automatically associate it with your AWS account. Certificates generatedby AWS are signed by an AWS internal certificate authority.

To have AWS create an X.509 certificate for you

1. Go to the Amazon Web Services web site at http://aws.amazon.com.

2. Point to Your Web Services Account to display a list of options.

3. Click View Access Key Identifiers and log in to your AWS account.

The AWS Access Key Identifiers page is displayed.

4. Scroll down to the X.509 Certificate area of the page and click Create New.The Create a New Certificate page is displayed.

5. Read the information on the page and click Yes to create your certificate.

The Create Success page is displayed.

6. Download your private key file and X.509 certificate file.

What Needs to Be Signed

Each SOAP request must be signed with the private key associated with the X.509 certificate. To createthe signature, you sign the Timestamp element, and if you're using WS-Addressing, we recommend you

API Version 2009-04-1526

Amazon SimpleDB Developer GuideSOAP Request Authentication

Page 31: sdb-dg

also sign the Action header element. In addition, you can optionally sign the Body and the To headerelement.

Message Expiration

AWS requires request messages to expire so they can't be used in malicious replay attacks. The bestpractice for specifying the expiration of SOAP/WS-Security requests is to include a Timestamp elementwith an Expires child element. In this case, the message expires at the time established in the Expireselement.

If no Timestamp element is present in the request, the request is rejected as invalid. If you include aTimestamp element with a Created child element but no Expires child element, the message expires15 minutes after the value of the Created element.

Example Request to Use When Troubleshooting

The following example shows the initial portion of a SOAP request that uses WS-Security with an X.509certificate. If you're using a SOAP toolkit that supports WS-Security and X.509 certificates, the toolkitconstructs the request automatically for you, so you don't have to create a request like this yourself. Theexample is included here as a reference to use if you're troubleshooting authentication issues with yourSOAP requests. Several requirements are listed following the example; the numbers highlight where inthe example the requirements are satisfied.

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">

<wsse:BinarySecurityToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecur ity-utility-1.0.xsd"

EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"

ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="CertId-1064304">

[Your base64 encoded X.509 certificate…] </wsse:BinarySecurityToken>

<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <ds:SignedInfo>

<ds:CanonicalizationMethod http://www.w3.org/2001/10/xml-exc-c14n#"></ds:CanonicalizationMethod>

<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></ds:SignatureMethod>

<ds:Reference URI="#id-17984263"> <ds:Transforms>

<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></ds:Transform> </ds:Transforms>

API Version 2009-04-1527

Amazon SimpleDB Developer GuideSOAP Request Authentication

Page 32: sdb-dg

<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmld sig#sha1"></ds:DigestMethod> <ds:DigestValue>0pjZ1+TvgPf6uG7o+Yp3l2YdGZ4=</ds:DigestValue> </ds:Reference>

<ds:Reference URI="#id-15778003"> <ds:Transforms>

<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></ds:Transform> </ds:Transforms>

<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmld sig#sha1"></ds:DigestMethod> <ds:DigestValue>HhRbxBBmc2OO348f8nLNZyo4AOM=</ds:DigestValue> </ds:Reference>

</ds:SignedInfo>

<ds:SignatureValue>bmVx24Qom4kd9QQtclxWIlgLk4QsQBPaKESi79x479xgbO9PEStXMi HZuBAi9luuKdNTcfQ8UE/d jjHKZKEQRCOlLVy0Dn5ZL1RlMHsv+OzJzzvIJFTq3LQKNrzJzsNe</ds:SignatureValue>

<ds:KeyInfo Id="KeyId-17007273">

<wsse:SecurityTokenReference xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="STRId-22438818"> <wsse:Reference URI="#CertId-1064304" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"> </wsse:Reference> </wsse:SecurityTokenReference> </ds:KeyInfo>

</ds:Signature>

<wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecur

ity-utility-1.0.xsd" wsu:Id="id-17984263"> <wsu:Created>2006-06-09T10:57:35Z</wsu:Created> <wsu:Expires>2006-06-09T11:02:35Z</wsu:Expires> </wsu:Timestamp>

</wsse:Security></SOAP-ENV:Header>

Requirements for BinarySecurityToken and Signatures

The EncodingType attribute for the BinarySecurityToken element must behttp://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary.The ValueType attribute for the BinarySecurityToken element must behttp://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3orhttp://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509PKIPathv1.

API Version 2009-04-1528

Amazon SimpleDB Developer GuideSOAP Request Authentication

Page 33: sdb-dg

The BinarySecurityToken element must contain the base64 encoding of the leaf X.509 certificateif the ValueType is #X509v3, or it must contain the base64 encoding of the full X.509 certificatechain if the ValueType is #X509PKIPathv1.The Algorithm attribute of the CanonicalizationMethod element must behttp://www.w3.org/2001/10/xml-exc-c14n#.The Algorithm attribute of the SignatureMethod element must behttp://www.w3.org/2000/09/xmldsig#rsa-sha1.The Algorithm attribute of the Transform element for each Reference element must be eitherhttp://www.w3.org/2001/10/xml-exc-c14n# orhttp://www.w3.org/TR/2001/REC-xml-c14n-20010315.The Algorithm attribute of the DigestMethod element for each Reference element must behttp://www.w3.org/2000/09/xmldsig#sha1.The KeyInfo element must contain a SecurityTokenReference element. TheSecurityTokenReference element must contain a Reference element with a URI attribute.TheURI attribute must use a local particle reference to identify the BinarySecurityToken elementthat contains the X.509 certificate (for example: the URI attribute equals #CertId-1064304 in thepreceding example request).You must include a wsu:Id attribute in any message elements that you sign.You can sign anySOAP header and the entire SOAP Body. Do not sign any other elements (such as children of theBody element). AWS ignores those elements for the purposes of signature validation, even if youinclude a wsu:ID attribute in them. If you sign elements that shouldn't be signed, the signaturevalidation will fail.

SOAP without WS-SecurityThis section describes how to secure SOAP requests that don't use WS-Security.

HTTPS

For the purposes of request security and integrity, you must send all SOAP requests over HTTPS.

Required Authentication Information

Authentication of SOAP requests without WS-Security uses your AWS identifiers and an HMAC-SHA1signature. The request must include the parameters listed in the following table.

DescriptionParameter

Your AWS Access Key ID.AWSAccessKeyId

This must be a dateTime object with the complete date plus hours, minutes,and seconds (for more information, go tohttp://www.w3.org/TR/xmlschema-2/#dateTime). Although it is not required,we recommend you provide the time stamp in the Coordinated UniversalTime time zone (UTC, also known as Greenwich Mean Time). The requestexpires 15 minutes after the time stamp.

Note

Due to different interpretations regarding how extra time precisionshould be dropped, .NET users should take care not to send overlyspecific time stamps.You can do this by manually constructingdateTime objects with no more than millisecond precision.

Timestamp

API Version 2009-04-1529

Amazon SimpleDB Developer GuideSOAP Request Authentication

Page 34: sdb-dg

DescriptionParameter

The HMAC-SHA1 signature calculated from the concatenation of the Actionand Timestamp parameters, using your AWS Secret Access Key as the key(for information about authentication with HMAC signatures, see HMAC-SHASignature (p. 19)). For example, for a request to create a queue, the valueof the Signature element would be the HMAC-SHA1 digest of a string likethis: CreateQueue2008-02-10T00:00:00Z

Signature

Calculating the request signature

Concatenate the values of the Action and Timestamp request parameters, in that order.1

Calculate an RFC 2104-compliant HMAC-SHA Signature (p. 19), using the string youcreated and your Secret Access Key as the key.

For more information, go to http://www.faqs.org/rfcs/rfc2104.html.

2

Convert the resulting value to base64.3

Pass the final value in the Signature parameter of the SOAP request.4

Location of Authentication Information in the Request

The following shows an example of how to provide the authentication information as elements in theSOAP header (using the namespace http://security.amazonaws.com/doc/2007-01-01/).

<?xml version='1.0' encoding='UTF-8'?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<SOAP-ENV:Body> <ListDomainsRequest xmlns=" http://sdb.amazonaws.com/doc/2009-04-15"> <Signature>SZf1CHmQnrZbsrC13hCZS061ywsEXAMPLE&lt;</Signature> <Timestamp>2009-02-16T17:39:51.000Z</Timestamp> <AWSAccessKeyId>1D9FVRAYCP1VJS767E02EXAMPLE</AWSAccessKeyId> <Version>2009-04-15</Version> <Action>ListDomains</Action> </ListDomainsRequest> </SOAP-ENV:Body></SOAP-ENV:Envelope>

Working with DomainsThis section describes how to work create, list, and delete domains.

Creating a DomainThe following is an example of creating a domain using REST.

API Version 2009-04-1530

Amazon SimpleDB Developer GuideWorking with Domains

Page 35: sdb-dg

https://sdb.amazonaws.com/?Action=CreateDomain&AWSAccessKeyId=[valid access key id]&DomainName=MyDomain&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A01%3A28-07%3A00&Version=2009-04-15&Signature=[valid signature]

Amazon SimpleDB returns output similar to the following.

<CreateDomainResponse> <ResponseMetadata> <RequestId>2a1305a2-ed1c-43fc-b7c4-e6966b5e2727</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></CreateDomainResponse>

Verifying the DomainThe following is an example of listing domains using REST.

https://sdb.amazonaws.com/?Action=ListDomains&AWSAccessKeyId=[valid access key id]&MaxNumberOfDomains=2&NextToken=[valid next token]&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A02%3A19-07%3A00&Version=2009-04-15&Signature=[valid signature]

Amazon SimpleDB returns output similar to the following.

<ListDomainsResponse> <ListDomainsResult> <DomainName>MyDomain</DomainName> <DomainName>MyOtherDomain</DomainName> </ListDomainsResult> <ResponseMetadata> <RequestId>eb13162f-1b95-4511-8b12-489b86acfd28</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></ListDomainsResponse>

API Version 2009-04-1531

Amazon SimpleDB Developer GuideVerifying the Domain

Page 36: sdb-dg

Deleting a DomainThe following is an example of deleting a domain using REST.

https://sdb.amazonaws.com/?Action=DeleteDomain&AWSAccessKeyId=[valid access key id]&DomainName=MyOtherDomain&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A02%3A20-07%3A00&Version=2009-04-15&Signature=[valid signature]

Amazon SimpleDB returns output similar to the following.

<DeleteDomainResponse> <ResponseMetadata> <RequestId>c522638b-31a2-4d69-b376-8c5428744704</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></DeleteDomainResponse>

Working with DataThis section describes how to create, get, and delete attributes.

For detailed information about constructing queries, see Using Select to Create Amazon SimpleDBQueries (p. 38).

Putting Data into a DomainThe following is an example of putting data into a domain using REST.

https://sdb.amazonaws.com/?Action=PutAttributes&DomainName=MyDomain&ItemName=JumboFez&Attribute.1.Name=Color&Attribute.1.Value=Blue&Attribute.2.Name=Size&Attribute.2.Value=Med&Attribute.3.Name=Price&Attribute.3.Value=0014.99&Attribute.3.Replace=true&AWSAccessKeyId=[valid access key id]&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A03%3A05-07%3A00

API Version 2009-04-1532

Amazon SimpleDB Developer GuideDeleting a Domain

Page 37: sdb-dg

&Version=2009-04-15&Signature=[valid signature]

Amazon SimpleDB returns output similar to the following.

<PutAttributesResponse> <ResponseMetadata> <RequestId>490206ce-8292-456c-a00f-61b335eb202b</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></PutAttributesResponse>

Note

For information on performing multiple put operations at once, see BatchPutAttributes (p. 60).

Getting Data from a DomainThe following is an example of getting data from an item using REST.

https://sdb.amazonaws.com/?Action=GetAttributes&AWSAccessKeyId=[valid access key id]&DomainName=MyDomain&ItemName=JumboFez&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A03%3A07-07%3A00&Version=2009-04-15&Signature=[valid signature]

Amazon SimpleDB returns output similar to the following.

<GetAttributesResponse> <GetAttributesResult> <Attribute><Name>Color</Name><Value>Blue</Value></Attribute> <Attribute><Name>Size</Name><Value>Med</Value></Attribute> <Attribute><Name>Price</Name><Value>0014.99</Value></Attribute> </GetAttributesResult> <ResponseMetadata> <RequestId>b1e8f1f7-42e9-494c-ad09-2674e557526d</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></GetAttributesResponse>

Deleting Data from a DomainThe following is an example of deleting data from an item using REST.

API Version 2009-04-1533

Amazon SimpleDB Developer GuideGetting Data from a Domain

Page 38: sdb-dg

https://sdb.amazonaws.com/?Action=DeleteAttributes&DomainName=MyDomain&ItemName=JumboFez&Attribute.1.Name=color&Attribute.1.Value=red&Attribute.2.Name=color&Attribute.2.Value=brick&Attribute.3.Name=color&Attribute.3.Value=garnet&AWSAccessKeyId=[valid access key id]&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A03%3A07-07%3A00&Version=2009-04-15&Signature=[valid signature]

Amazon SimpleDB returns output similar to the following.

<DeleteAttributesResponse> <ResponseMetadata> <RequestId>05ae667c-cfac-41a8-ab37-a9c897c4c3ca</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></DeleteAttributesResponse>

Conditionally Putting and Deleting DataThis section describes how to update or delete data when a specific condition is met.

Performing a Conditional PutConditional put enables you to insert or replace values for one or more attributes of an item if the existingvalue of an attribute matches a value that you specify. If the value does not match or is not present, theinsert or update is rejected with a 409 (MultiValuedAttribute, ConditionalCheckFailed ) or 404(AttributeDoesNotExist) error code.

Conditional updates are useful for preventing lost updates when different sources concurrently write tothe same item.

Note

Conditional puts can only match single-valued attributes.

Optimistic Concurrency ControlApplications can implement optimistic concurrency control (OCC) by maintaining a version number (ortimestamp) attribute as part of an item and by performing a conditional update based on the value of thisversion number.

API Version 2009-04-1534

Amazon SimpleDB Developer GuideConditionally Putting and Deleting Data

Page 39: sdb-dg

To set up optimistic concurrency control, configure each writer to specify the expected name and expectedvalue in put requests. If the expected value changes between the time the writer reads and writes to thatvalue, the writer does not perform the update. The writer can then read the update to the value andperform another write based on the change.

Note

All writers must use conditional updates or updates can be lost

In the following example, the application does a conditional update of the item's state and sets the valueto "fuzzy" only if the value of VersionNumber is 30. If another application changes the value ofVersionNumber between this read and write, so that it is no longer 30, the updates fails.

https://sdb.amazonaws.com/?Action=PutAttributes&DomainName=MyDomain&ItemName=JumboFez&Attribute.1.Name=state&Attribute.1.Value=fuzzy&Attribute.1.Replace=true&Attribute.2.Name=VersionNumber&Attribute.2.Value=31&Attribute.2.Replace=true&Expected.1.Name=VersionNumber&Expected.1.Value=30&AWSAccessKeyId=[valid access key id]&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A03%3A05-07%3A00&Version=2009-04-15&Signature=[valid signature]

If the condition is met, Amazon SimpleDB returns output similar to the following.

<PutAttributesResponse> <ResponseMetadata> <RequestId>490206ce-8292-456c-a00f-61b335eb202b</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></PutAttributesResponse>

CountersYou can also use conditional puts to implement counters. For example, an application might issue aGetAttributes call to retrieve the current page counter for a web page and write the new value usingPutAttributes only if no other host has updated the value.

To set up counters, configure each writer to specify the expected name and expected value in put requests.If the counter value changes between the time the writer reads and writes to that value, the writer doesnot update the counter. The writer can then read the counter value and perform another write based onthe change.

Note

All writers must use conditional updates or updates can be lost

API Version 2009-04-1535

Amazon SimpleDB Developer GuidePerforming a Conditional Put

Page 40: sdb-dg

When updating a counter, you can use eventually consistent or consistent reads. If a stale valueis read, the write is rejected by the system.

If a counter is updated frequently, make sure to re-read the updated counter value on failure.

In the following example, the application updates the counter if the value did not change between theread and the write. If another application changes the value of PageHits between this read and write, sothat it is no longer 121, the updates fails.

https://sdb.amazonaws.com/?Action=PutAttributes&DomainName=MyDomain&ItemName=www.fezco.com&Attribute.1.Name=PageHits&Attribute.1.Value=122&Attribute.1.Replace=true&Expected.1.Name=PageHits&Expected.1.Value=121&AWSAccessKeyId=[valid access key id]&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A03%3A05-07%3A00&Version=2009-04-15&Signature=[valid signature]

If the condition is met, Amazon SimpleDB returns output similar to the following.

<PutAttributesResponse> <ResponseMetadata> <RequestId>490206ce-8292-456c-a00f-61b335eb202b</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></PutAttributesResponse>

Existence CheckYou can use conditional puts to only put an attribute if it does not exist.

To perform an existence check, specify expected name and set expected exists to false. If the specifiedattribute does not exist, Amazon SimpleDB performs the update.

In the following example, Amazon SimpleDB creates the quantity attribute and sets its value to 144for the PetiteFez item, if its quantity attribute does not exist.

https://sdb.amazonaws.com/?Action=PutAttributes&DomainName=MyDomain&ItemName=PetiteFez&Attribute.1.Name=quantity&Attribute.1.Value=144&Expected.1.Name=quantity&Expected.1.Exists=false

API Version 2009-04-1536

Amazon SimpleDB Developer GuidePerforming a Conditional Put

Page 41: sdb-dg

&AWSAccessKeyId=[valid access key id]&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A03%3A05-07%3A00&Version=2009-04-15&Signature=[valid signature]

If the condition is met, Amazon SimpleDB returns output similar to the following.

<PutAttributesResponse> <ResponseMetadata> <RequestId>490206ce-8292-456c-a00f-61b335eb202b</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></PutAttributesResponse>

Performing a Conditional DeleteConditional delete enables you to delete an item or one or more attributes of an item if the existing valueof an attribute matches a value that you specify. If value does not match or is not present, the insert orupdate is rejected with a 409 (MultiValuedAttribute, ConditionalCheckFailed ) or 404 (AttributeDoesNotExist)error code.

Note

Conditional deletes can only match single-valued attributes.

To perform a conditional delete, specify the expected name and expected value for a DeleteAttributesoperation. If the specified attribute does not exist, Amazon SimpleDB performs the delete.

In the following example, Amazon SimpleDB deletes the JumboFez product from the MyDomain domainif the quantity of the product reaches zero.

https://sdb.amazonaws.com/?Action=DeleteAttributes&DomainName=MyDomain&ItemName=JumboFez&Expected.1.Name=quantity&Expected.1.Value=0&AWSAccessKeyId=[valid access key id]&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A03%3A05-07%3A00&Version=2009-04-15&Signature=[valid signature]

If the condition is met, Amazon SimpleDB returns output similar to the following.

<PutAttributesResponse> <ResponseMetadata>

API Version 2009-04-1537

Amazon SimpleDB Developer GuidePerforming a Conditional Delete

Page 42: sdb-dg

<RequestId>490206ce-8292-456c-a00f-61b335eb202b</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></PutAttributesResponse>

Using Select to Create Amazon SimpleDBQueries

This section describes Select, a function that takes query expressions similar to the standard SQLSELECT statement.

Use the following format for the Select function.

select output_listfrom domain_name[where expression][sort_instructions][limit limit]

The output_list can be any of the following:

• * (all attributes)

• itemName() (the item name only)

• count(*)

• An explicit list of attributes (attribute1,..., attributeN)

DescriptionName

The domain to search.domain_name

The match expression.This rest of this section providesexamples of how to form select expressions.

expression

API Version 2009-04-1538

Amazon SimpleDB Developer GuideUsing Select to Create Amazon SimpleDB Queries

Page 43: sdb-dg

DescriptionName

Sorts the results on a single attribute, in ascending ordescending order. For information on sorting results,see Sort (p. 45).

The limit is the maximum number of results to return(default: 100, max. 2500).

Note

The total size of the response cannot exceed1 MB. Amazon SimpleDB automatically adjuststhe number of items returned per page toenforce this limit. For example, even if you askto retrieve 2500 items, but each individual itemis 10 KB in size, the system returns 100 itemsand an appropriate next token so you can getthe next page of results.

.

sort_instructions

The expression can be any of the following:

• <select expression> intersection <select expression>

• NOT <select expression>

• (<select expression>)

• <select expression> or <select expression>

• <select expression> and <select expression>

• <simple comparison>

Note

For information on how to use quotes with Amazon SimpleDB, see Select Quoting Rules (p. 47).

Comparison OperatorsComparison operators are applied to a single attribute and are lexicographical in nature. When designingan application, you should carefully think through storing data in its appropriate string representation. Formore information, see Working with Numerical Data (p. 48).

The following table shows all Amazon SimpleDB comparison operators.

Select ExampleDescriptionComparisonOperator

select * from mydomain where city= 'Seattle'

select * from mydomain where city= 'Seattle' or city = 'Portland'

Attribute value or itemName() equals thespecified constant.

=

API Version 2009-04-1539

Amazon SimpleDB Developer GuideComparison Operators

Page 44: sdb-dg

Select ExampleDescriptionComparisonOperator

select * from mydomain where name!= 'John'

select * from mydomain where name!= 'John' and name != 'Humberto'

Attribute value or itemName() does notequal to the specified constant.

!=

select * from mydomain whereweight > '0034'

Attribute value or itemName() is greaterthan the specified constant.

>

select * from mydomain whereweight >= '065'

Attribute value or itemName() is greaterthan or equal to the specified constant.

>=

select * from mydomain whereweight < '0034'

Attribute value or itemName() is less thanthe specified constant.

<

select * from mydomain where year<= '2000'

Attribute value or itemName() is less thanor equal to the specified constant.

<=

select * from mydomain whereauthor like 'Henry%' select * frommydomain where keyword = 'Book'and author like '%Miller'

Attribute value or itemName() contains thespecified constant.

The like operator can be used to evaluatethe start of a string ('string%'), the end ofa string ('%string'), or any part of a string('%string%').

Note

Using the like operator toevaluate the end of a string or anypart of a string is an expensiveoperation. Make sure to combineit with other predicates to reducenumber of items it has to evaluate.

To search for strings that containthe percent sign (%), you mustescape it. For example, to searchfor a string that ends in '3%', youenter select * from mydomainwhere name like '%3\%'. Tosearch for a string that begins with'3%', you enter select * frommydomain where name like'3\%%'. To search for a string thatcontains '3%', you enter select* from mydomain where namelike '%3\%%'.

like

API Version 2009-04-1540

Amazon SimpleDB Developer GuideComparison Operators

Page 45: sdb-dg

Select ExampleDescriptionComparisonOperator

select * from mydomain whereauthor not like 'Henry%' select* from mydomain where keyword ='Book' and author not like'%Miller'

Attribute value or itemName() does notcontain the specified constant.

The not like operator can be used toevaluate the start of a string ('string%'),the end of a string ('%string'), or any partof a string ('%string%').

Note

Using the not like operator toevaluate the end of a string or anypart of a string is an expensiveoperation. Make sure to combineit with other predicates to reducenumber of items it has to evaluate.

not like

select * from mydomain where yearbetween '1998' and '2000'

Attribute value or itemName() falls within arange, including the start and end value.

between

select * from mydomain where yearin('1998','2000','2003') select* from mydomain where itemName()in('0385333498','0802131786','B000T9886K')

Attribute value or itemName() is equal toone of the specified constants. When usedwith items, in acts as a batch get.

in

select * from mydomain where yearis null

Attribute does not exist. If an item has theattribute with an empty string, it is notreturned.

Note

Due to performance issues, thisoperator is not recommended whenmost items have the specifiedattribute.

is null

select * from mydomain where yearis not null

Attribute value or itemName() contains anyvalue.

is not null

select * from mydomain whereevery(keyword) = 'Book'

select * from mydomain whereevery(keyword) like '***%'

For multi-valued attributes, every attributevalue must satisfy the constraint.

Note

Due to the cost of running morecomplex queries, this operator isonly recommended for multi-valuedattributes.

every()

API Version 2009-04-1541

Amazon SimpleDB Developer GuideComparison Operators

Page 46: sdb-dg

Sample Query Data SetThe following table contains the data set used throughout this section.

RatingKeywordPagesYearAuthorTitleItem Name

*****

5 stars

Excellent

Book

Paperback

003361959KurtVonnegut

The Sirens of Titan0385333498

****Book003181934Henry MillerTropic of Cancer0802131786

****

4 stars

Book

Hardcover

American

003041979Tom WolfeThe Right Stuff1579124585

4 starsCD

Trance

2007Paul Van DykIn BetweenB000T9886K

***

3 stars

Not bad

DVD

Action

FrankMiller

2007Zack Snyder300B00005JPLW

*****2002ThieveryCorporation

Heaven's Gonna BurnYour Eyes

B000SF3NGK

Simple QueriesThis section shows simple queries and their results.

Note

To view the source data for the queries, see Sample Query Data Set (p. 42).

The following table shows some simple queries, how they are interpreted, and the results they returnfrom the sample dataset.

ResultDescriptionSelect Expression

1579124585Retrieves all items where the attribute "Title" equals"The Right Stuff."

select * from mydomainwhere Title = 'The RightStuff'

B000T9886K,B00005JPLW,B000SF3NGK

Retrieves all items where "Year" is greater than"1985."

Although this looks like a numerical comparison, itis lexicographical. Because the calendar won'tchange to five digits for nearly 8,000 years, "Year"is not zero padded.

select * from mydomainwhere Year > '1985'

API Version 2009-04-1542

Amazon SimpleDB Developer GuideSample Query Data Set

Page 47: sdb-dg

ResultDescriptionSelect Expression

0385333498,1579124585,0802131786,B000SF3NGK

Retrieves all items that have at least a 4 star (****)rating.

The prefix comparison is case-sensitive and exactand does not match attributes that only have the"4 star" value, such as item B000T9886K.

select * from mydomainwhere Rating like '****%'

1579124585,0802131786,

Retrieves all items that have less than 320 pages.

This attribute is zero padded in the data set andthe select expression, which allows for properlexicographical comparison between the strings.Items without this attribute are not considered.

select * from mydomainwhere Pages < '00320'

Range QueriesAmazon SimpleDB enables you to execute more than one comparison against attribute values within thesame predicate. This is most commonly used to specify a range of values.

This section shows range queries and their results.

Note

To view the source data for the queries, see Sample Query Data Set (p. 42).

The following table shows some range queries, how they are interpreted, and the results they return fromthe sample dataset.

ResultDescriptionSelect Expression

1579124585,B000T9886K,B00005JPLW,B000SF3NGK

Retrieves all items that have a "Year" valuebetween "1975" and "2008."

select * from mydomainwhere Year > '1975' andYear < '2008'

1579124585,B000T9886K,B00005JPLW,B000SF3NGK

Retrieves all items that have a "Year" valuebetween "1975" and "2008."

select * from mydomainwhere Year between '1975'and '2008'

0385333498,B00005JPLW,B000SF3NGK

Retrieves all items that have 3 (***) or 5 (*****) starrating

This is a discontiguous range query that consistsof two distinct values selected from the range of allpossible values for the attribute.

select * from mydomainwhere Rating = '***' orRating = '*****'

0385333498,0802131786,B000T9886K,B00005JPLW

Retrieves all items where the "Year" attribute iseither between "1950" and "1960," falls in thenineteen-thirties, or equals "2007."

select * from mydomainwhere (Year > '1950' andYear < '1960') or Yearlike '193%' or Year ='2007'

API Version 2009-04-1543

Amazon SimpleDB Developer GuideRange Queries

Page 48: sdb-dg

Queries on Attributes with Multiple ValuesOne of the unique features of Amazon SimpleDB is that it allows you to associate multiple values with asingle attribute. Internet-related attributes such as tag or keyword often contain multiple values, whichare easy to support through the Amazon SimpleDB data model and query language.

Important

Each attribute is considered individually against the comparison conditions defined in the predicate.Item names are selected if any of the values match the predicate condition. To change thisbehavior, use the every() operator to return results where every attribute matches the queryexpression.

This section shows queries on attributes with multiple values and their results.

Note

To view the source data for the queries, see Sample Query Data Set (p. 42).

The following table shows some queries on attributes with multiple values, how they are interpreted, andthe results they return from the sample dataset.

ResultDescriptionSelect Expression

1579124585,0802131786,B000T9886K

Retrieves all items with a 4 star (****) rating.

The data set has this rating stored as both "4 stars"and "****." Amazon SimpleDB returns items thathave either or both.

select * from mydomainwhere Rating = '4 stars'or Rating = '****'

<none>Retrieve all items that have the Keyword attributeas both "Book" and "Hardcover."

Based on the data set, you might be surprised thatthe result did not return the "1579124585" item. Asdescribed earlier, each value is evaluatedindividually against the predicate expression. Sinceneither of the values satisfies both comparisonsdefined in the predicate, the item name is notselected.

To get the desired results, you can use the select* from mydomain where Keyword = 'Book'intersection Keyword = 'Hardcover'expression. For more information, see MultipleAttribute Queries (p. 44).

select * from mydomainwhere Keyword = 'Book'and Keyword = 'Hardcover'

0385333498,0802131786

Retrieves all items where the only keyword is Bookor Paperback. If the item contains any otherkeyword entries, it is not returned.

select * from mydomainwhere every(keyword) in('Book', 'Paperback')

Multiple Attribute QueriesThe previous examples show how to create expressions for single predicates. The Amazon SimpleDBquery language also supports constructing expressions across multiple predicates using the intersectionoperator.

API Version 2009-04-1544

Amazon SimpleDB Developer GuideQueries on Attributes with Multiple Values

Page 49: sdb-dg

Multiple attribute queries work by producing a set of item names from each predicate and applying theintersection operator. The intersection operator only returns item names that appear in both resultsets.

This section shows multiple attribute queries and their results.

Note

To view the source data for the queries, see Sample Query Data Set (p. 42).

The following table shows some multiple attribute queries, how they are interpreted, and the results theyreturn from the sample dataset.

ResultDescriptionSelect Expression

0802131786,1579124585

Retrieves all items that have a "****" Rating.select * from mydomainwhere Rating = '****'

0802131786Retrieves all items that only have a "****" Rating.Items are not returned that have a multi-valuedRating attribute that contains any value other than'****.'

select * from mydomainwhere every(Rating) ='****'

1579124585Retrieves all items that have a "Book" Keywordand a "Hardcover" Keyword.

The first predicate produces 0385333498,0802131786, and 1579124585. The secondproduces 1579124585. The intersection operatorreturns results that appear in both queries.

select * from mydomainwhere Keyword = 'Book'intersection Keyword ='Hardcover'

SortAmazon SimpleDB supports sorting data on a single attribute or the item names, in ascending (default)or descending order. This section describes how to sort the result set returned from Select.

Note

All sort operations are performed in lexicographical order.

The sort attribute must be present in at least one of the predicates of the expression.

Because returned results must contain the attribute on which you are sorting, do not use isnull on the sort attribute. For example, select * from mydomain where author isnull and title is not null order by title will succeed. However, select * frommydomain where author is null order by title will fail because title is notconstrained by the not null predicate.

To view the source data for the queries, see Sample Query Data Set (p. 42).

The following table shows sort queries, how they are interpreted, and the results they return from thesample dataset.

API Version 2009-04-1545

Amazon SimpleDB Developer GuideSort

Page 50: sdb-dg

ResultDescriptionSelect Expression

0802131786,0385333498,1579124585

Retrieves all items released before 1980 and liststhem in ascending order.

select * from mydomainwhere Year < '1980' orderby Year asc

0802131786,0385333498,1579124585

Same as the previous entry, with "asc" (ascending)omitted.

select * from mydomainwhere Year < '1980' orderby Year

B00005JPLW,B000T9886K

Retrieves all items released in 2007 and sorts themby author name in descending order.

select * from mydomainwhere Year = '2007'intersection Author isnot null order by Authordesc

InvalidSortExpressionerror. See APIErrorCodes (p. 89).

Invalid because Year is not constrained by apredicate in the where clause.

select * from mydomainorder by Year asc

0802131786,0385333498

Retrieves two items that were released before 1980and lists them in ascending order.

select * from mydomainwhere Year < '1980' orderby Year limit 2

B00005JPLW,B000SF3NGK,B000T9886K

Retrieves all itemNames() that start with B000 andlists them in ascending order.

select itemName() frommydomain where itemName()like 'B000%' order byitemName()

CountIf you want to count the number of items in a result set instead of returning the items, use count(*).Instead of returning a list of items, Amazon SimpleDB returns a single item called Domain with a Countattribute.

Note

If the count request takes more than five seconds, Amazon SimpleDB returns the number ofitems that it could count and a next token to return additional results. The client is responsiblefor accumulating the partial counts.

If Amazon SimpleDB returns a 408 Request Timeout, please resubmit the request.

The default result limit of 100 and maximum result limit of 2500 do not apply to count(*). However,you can restrict the maximum number of counted results using the limit clause.

The next token returned by count(*) and select are interchangeable as long as the where and orderby clauses match. For example, if you want to return the 200 items after the first 10,000 (similar to anoffset), you can perform a count with a limit clause of 10,000 and use the next token to return the next200 items with select.

The following table shows count(*) queries and the results they return from the sample dataset.

Note

To view the source data for the queries, see Sample Query Data Set (p. 42).

API Version 2009-04-1546

Amazon SimpleDB Developer GuideCount

Page 51: sdb-dg

ResultDescriptionSelect Expression

1Counts all items where the attribute "Title" equals"The Right Stuff."

select count(*) frommydomain where Title ='The Right Stuff'

3Counts all items where "Year" is greater than"1985."

select count(*) frommydomain where Year >'1985'

6Counts all items in the domain, with a limit of 500.select count(*) frommydomain limit 500

4Counts all items in the domain, with a limit of 4.select count(*) frommydomain limit 4

Select Quoting RulesAttribute values must be quoted with a single or double quote. If a quote appears within the attributevalue, it must be escaped with the same quote symbol. These following two expressions are equivalent:

select * from mydomain where attr1 = 'He said, "That''s the ticket!"'select * from mydomain where attr1 = "He said, ""That's the ticket!"""

Attribute and domain names may appear without quotes if they contain only letters, numbers, underscores(_), or dollar symbols ($) and do not start with a number.You must quote all other attribute and domainnames with the backtick (`).

select * from mydomain where `timestamp-1` > '1194393600'

You must escape the backtick when it appears in the attribute or domain name by replacing it with twobackticks. For example, we can retrieve any items that have the attribute abc`123 set to the value 1 withthis select expression:

select * from mydomain where `abc``123` = '1'

The following is the list of reserved keywords that are valid identifiers that must be backtick quoted if usedas an attribute or domain name in the Select syntax.

• or

• and

• not

• from

• where

• select

• like

• null

• is

• order

• by

• asc

API Version 2009-04-1547

Amazon SimpleDB Developer GuideSelect Quoting Rules

Page 52: sdb-dg

• desc

• in

• between

• intersection

• limit

• every

Working with Numerical DataTopics

• Negative Numbers Offsets (p. 48)

• Zero Padding (p. 48)

• Dates (p. 49)

Amazon SimpleDB is a schema-less data store and everything is stored as a UTF-8 string value. Thisprovides application designers with the flexibility of enforcing data restrictions at the application layerwithout the data store enforcing constraints.

All comparisons are performed lexicographically. As a result, we highly recommend that you use negativenumber offsets, zero padding, and store dates in an appropriate format.

Negative Numbers OffsetsWhen choosing a numerical range, ensure that every number is positive. To do this, choose an offsetthat is larger than the smallest expected negative number in your data set. For example, if the smallestexpected number in your data set is -12,000, choosing offset = 100,000 might be safe.

The following is a sample original data set.

14.58, -12536.791, 20071109, 655378.34, -23

If you apply an offset of 100,000, the following is the resulting data set.

100014.58, 87463.209, 20171109, 755378.34, 99977

Zero PaddingAfter all the numbers in a data set are positive, ensure they are properly represented for lexicographicalcomparisons. For example, the string "10" comes before "2" in lexicographical order. If we zero pad thenumbers to five digits, "00002" comes before "00010" and are compared correctly. Additionally, the offsetis valid for numbers up to 5 digits and future numbers such as 00402 and 02987 are properly representedin this scheme.

To determine the right number of digits for zero padding, determine the largest number in your data set(accounting for negative number conversions), determine the offset number (maximum number of digitsfor that number without a decimal point), and convert all your numbers by appending zeros to them untilthey match the digit length of the offset number.

The following is sample data set with an offset applied.

API Version 2009-04-1548

Amazon SimpleDB Developer GuideWorking with Numerical Data

Page 53: sdb-dg

100014.58, 87463.209, 20171109, 755378.34, 99977

If you zero pad the data set as well, the following is the resulting data set.

00100014.58, 00087463.209, 20171109, 00755378.34, 00099977

From this result set, the original query 'attribute' > '500' is now 'attribute' > '00100500'.

DatesTo convert dates to strings, we recommend following the ISO 8601 format, which supports lexicographicalorder comparisons.

The following table describes formats for representing date-time values with differing degrees of granularity.You must use components exactly as they are shown here and with exactly this punctuation. Note thatthe "T" appears literally in the string, to indicate the beginning of the time element, as is specified in ISO8601.

StringGranularity

YYYY

(e.g., 1997)

Year

YYYY-MM

(e.g., 1997-07)

Year and month

YYYY-MM-DD

(e.g., 1997-07-16)

Complete date

YYYY-MM-DDThh:mmTZD

(e.g., 1997-07-16T19:20+01:00)

Complete date plushours and minutes

YYYY-MM-DDThh:mm:ssTZD

(e.g., 1997-07-16T19:20:30+01:00)

Complete date plushours, minutes andseconds

YYYY-MM-DDThh:mm:ss.sTZD

(e.g., 1997-07-16T19:20:30.45+01:00)

Complete date plushours, minutes, secondsand a decimal fraction ofa second

Tuning QueriesTopics

• BoxUsage (p. 50)

• Data Set Partitioning (p. 50)

This section describes steps you can take to tune queries and your data set.

API Version 2009-04-1549

Amazon SimpleDB Developer GuideDates

Page 54: sdb-dg

BoxUsageFor every call, Amazon SimpleDB returns a BoxUsage value that shows the amount of system resourcesused by a particular operation. BoxUsage is calculated based on the make-up of your data set and thecomplexity of the query.

You can benchmark and optimize queries using the returned BoxUsage values. Queries with a higherBoxUsage are generally more expensive and, given a well-defined data set, you can choose the queriesthat provide the best performance.

Note

The actual execution time of any given query might vary with the rate of requests executed againstyour domain.

Both execution time and BoxUsage are affected by the data set size. We recommend monitoringthe performance of queries as data sets grow over time.

Data Set PartitioningAmazon SimpleDB allows up to 100 domains per subscriber.You can partition your data set amongmultiple domains to parallelize queries and operate on smaller data sets. Although you can only executea single query against a single domain, you can aggregate result sets in the application layer.

Note

If you require additional domains, go to http://aws.amazon.com/contact-us/simpledb-limit-request/.

You might choose to partition data sets across a natural dimension (e.g., product type, country). Forexample, you can keep a product catalog in a single domain, but it might be more efficient to partition itinto "Book," "CD," and "DVD" domains. Additionally, you might need to partition data sets because yourdata requires higher throughput than a single domain, or the data set is very large and queries hit thetimeout limit.

In some cases, data sets do not naturally present themselves well for partitioning (e.g., logs, events, orweb-crawler data) and you might use a hashing algorithm to create a uniform distribution of items amongmultiple domains. For example, you could partition a data set into four different domains, determine thehash of items using a hash function such as MD5, and use the last two digits to place each item in thespecified domain:

• Last two bits equal to 00: places item in Domain0

• Last two bits equal to 01: places item in Domain1

• Last two bits equal to 10: places item in Domain2

• Last two bits equal to 11: places item in Domain3

The additional advantage of this scheme is the ease with which it can be adjusted to partition your dataacross a larger number of domains by considering more and more bits of the hash value (3 bits distributesto 8 domains, 4 bits to 16 domains and so on).

API Version 2009-04-1550

Amazon SimpleDB Developer GuideBoxUsage

Page 55: sdb-dg

Working with XML-Restricted CharactersYou can store data in Amazon SimpleDB through the REST and SOAP interfaces. All results are returnedin XML documents.

XML does not support certain Unicode characters (the NUL character, anything in XML's RestrictedCharcategory, and permanently undefined Unicode characters). For more information about these characters,go to section 2.2 of the XML 1.1 specification.

Because it is XML-based, you cannot submit these characters through the SOAP API. However, you canaccidentally send them through the REST API.

To ensure that you can read all the data you sent via REST, if a response contains invalid XML characters,Amazon SimpleDB automatically Base64-encodes the UTF-8 octets of the text.

When a returned element is Base64-encoded, its encoding element is set to base64. The followingexample shows Base64-encoded results from a GetAttributes operation.

<GetAttributesResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/"> <GetAttributesResult> <Attribute> <Name>...</Name> <Value encoding="base64">...</Value> </Attribute> <Attribute> <Name encoding="base64">...</Name> <Value encoding="base64">...</Value> </Attribute> </GetAttributesResult> </GetAttributesResponse>

The following example shows a Base64-encoded result from a Select operation.

<SelectResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/"> <SelectResult> <Item> <Name>...</Name> <Attribute> <Name>...</Name> <Value encoding="base64">...</Value> </Attribute> <Attribute> <Name encoding="base64">...</Name> <Value encoding="base64">...</Value> </Attribute> </Item> </SelectResult> </SelectResponse>

When designing your application, make sure to scrub any data for invalid characters or design yourapplication to handle Base64-encoded results.

API Version 2009-04-1551

Amazon SimpleDB Developer GuideWorking with XML-Restricted Characters

Page 56: sdb-dg

Available AWS LibrariesAWS provides libraries that call Amazon SimpleDB using the REST API. The libraries are posted in theCommunity Code section of the Resource Center at the following locations:

• Java sample code

• C# sample code

• Perl sample code

• PHP sample code

• VB.NET sample code

API Version 2009-04-1552

Amazon SimpleDB Developer GuideAvailable AWS Libraries

Page 57: sdb-dg

API Reference

Topics

• API Usage (p. 53)

• Common Parameters (p. 57)

• Common Response Elements (p. 59)

• Common Error Responses (p. 59)

• Operations (p. 59)

This chapter contains detailed descriptions of all Amazon SimpleDB operations, their request parameters,their response elements, any special errors, and examples of requests and responses. All sample requestsand responses are shown in a protocol-neutral format that displays the common elements for both SOAPand REST requests.

API UsageThis section provides a high-level overview of the Amazon SimpleDB API. It describes API conventions,API versioning used to minimize the impact of service changes, and API-specific information for makingREST and SOAP requests.

API Conventions

OverviewThis topic discusses the conventions used in the Amazon SimpleDB API reference. This includesterminology, notation, and any abbreviations used to describe the API.

The API reference is broken down into a collection of Actions and Data Types.

ActionsActions encapsulate the possible interactions with Amazon SimpleDB. These can be viewed as remoteprocedure calls and consist of a request and response message pair. Requests must be signed, allowingAmazon SimpleDB to authenticate the caller.

API Version 2009-04-1553

Amazon SimpleDB Developer GuideAPI Usage

Page 58: sdb-dg

Data TypesValues provided as parameters to the various operations must be of the indicated type. Standard XSDtypes (like string, boolean, int) are prefixed with xsd:. Complex types defined by the Amazon SimpleDBWSDL are prefixed with sdb:.

WSDL Location and API VersionThe Amazon SimpleDB API is published through a Web Services Description Language (WSDL) and anXML schema document. The version of the Amazon SimpleDB API supported with this document is2009-04-15.

The Amazon SimpleDB WSDL is located at:http://sdb.amazonaws.com/doc/2009-04-15/AmazonSimpleDB.wsdl.

The Amazon SimpleDB schema is located at:http://sdb.amazonaws.com/doc/2009-04-15/AmazonSimpleDB.xsd.

Some libraries can generate code directly from the WSDL. Other libraries require a little more work onyour part.

API VersionsAll Amazon SimpleDB API operations are versioned. This minimizes the impact of API changes on clientsoftware by sending back a response that the client can process. New versions are designed to bebackward-compatible with older API revisions. However, there might be occasions where an incompatibleAPI change is required. Additionally, newer API responses might include additional fields and, dependingon how the client software is written, it might not be able to handle additional fields. Including a versionin the request guarantees that it will always be sent a response that it expects.

Each API revision is assigned a version in date form. This version is included in the request as part ofthe document namespace when using SOAP and as a version parameter when using REST.The responsereturned by Amazon SimpleDB honors the version included in the request. Fields introduced in a laterAPI version are not returned in the response.

If your SOAP client retrieves the Amazon SimpleDB WSDL at runtime and generates the requests usingthat WSDL dynamically, you must reference the WSDL of the API version on which you built the client.This ensures the client software continues to operate if incompatible API changes are introduced. TheWSDL for each supported API version is available using the following URI format:

http://sdb.amazonaws.com/doc/<api-version>/AmazonSimpleDB.wsdl

Specifying the API VersionFor all requests, you must explicitly request the API version you want to use. Specifying the versionensures that the service does not return response elements that your application is not designed to handle.

In REST requests, you include the Version parameter.

http://sdb.amazonaws.com?Action=CreateDomain&AWSAccessKeyId=[valid access key id]&DomainName=MyDomain&SignatureVersion=2&SignatureMethod=HmacSHA256

API Version 2009-04-1554

Amazon SimpleDB Developer GuideWSDL Location and API Version

Page 59: sdb-dg

&Timestamp=2010-01-25T15%3A01%3A28-07%3A00&Version=2009-04-15&Signature=[valid signature]

In SOAP requests, the namespace of the first child element of the <Body> element specifies the version.

<?xml version="1.0" encoding="UTF-8" ?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Header xmlns:aws="http://security.amazonaws.com/doc/2007-01-01/"> <aws:AWSAccessKeyId>0PAP1H1P8JJVZEXAMPLE</AWSAccessKeyId> <aws:Timestamp>2010-01-26T00:00:00Z</Timestamp> <aws:Signature>SZf1CHmQ/nrZbsrC13hCZS061ywsEXAMPLE</Signature> </soapenv:Header> <soapenv:Body> <CreateDomain xmlns="http://sdb.amazonaws.com/doc/2009-04-15"> <DomainName>MyDomain</DomainName> </CreateDomain> </soapenv:Body></soapenv:Envelope>

API Error RetriesThis section describes how to handle client and server errors.

Note

For information on specific error messages, see API Error Codes (p. 89)

Client ErrorsDo not retry client errors. Client errors indicate that Amazon SimpleDB found a problem with the clientrequest and the application should address the issue before submitting the request again.

SOAP client errors are indicated by the Client prefix and REST client errors are indicated by a 4xxHTTP response code.

Server ErrorsFor server errors, you should retry the requests.

SOAP server errors are indicated by the Server prefix and REST server errors are indicated by a 5xxHTTP response code.

Retries and Exponential BackoffBuilding applications that work well in a networked environment with unpredictable latencies opens a newset of potential error conditions when compared to typical desktop or client-server applications. Invokingrequests to a web service such as Amazon SimpleDB, whether over the Internet or from an Amazon EC2instance within the Amazon cloud, requires application designers to consider issues such as network

API Version 2009-04-1555

Amazon SimpleDB Developer GuideAPI Error Retries

Page 60: sdb-dg

connectivity, request timeouts, and remote errors due to overload or throttling. There are numerouscomponents on the network, such as DNS servers, switches, load-balancers, and others that couldgenerate errors anywhere in the life of a given request.

After a request arrives at the service, Amazon SimpleDB uses the following standard HTTP error codesto communicate server and overload errors through the REST interface.

• HTTP 500 - Internal Server Error

• HTTP 503 - Service Unavailable (system overload message)

The following is a list of error codes that Amazon SimpleDB uses to communicate server and overloaderrors through the SOAP interface.

• Server.InternalError - Internal Server Error (equivalent to HTTP 500 error)

• Server.ServiceUnavailable - Service is currently unavailable (equivalent to HTTP 503 error)

The usual technique for dealing with these error responses in a networked environment is to implementretries in the client application layer, regardless of whether those errors come from the service itself orany component on the network between Amazon SimpleDB and client application.This technique increasesthe reliability of the applications and reduces operational costs for the developer.

In addition to simple retries, we recommend using an exponential backoff algorithm for better flow control.The concept behind exponential backoff is to use progressively longer waits between retries for consecutiveerror responses. For example, up to 400 milliseconds before the first retry, up to 1600 milliseconds beforethe second, up to 6400 milliseconds before third, and so on.

Following is a sample exponential backoff algorithm in Java.

currentRetry = 0 DO status = execute Amazon SimpleDB request IF status = success OR status = client error (4xx) set retry to false process the response or client error as appropriate ELSE set retry to true currentRetry = currentRetry + 1 wait for a random delay between 0 and (4^currentRetry * 100) milliseconds

END-IF WHILE (retry = true AND currentRetry < MaxNumberOfRetries)

Following is a snippet of Java code that implements the exponential backoff.

boolean shouldRetry = true; int retries = 0; do { try { /* Submit request to Amazon SimpleDB*/ if (status == HttpStatus.SC_OK) { shouldRetry = false; /* Process successful response from Amazon SimpleDB */ } else {

API Version 2009-04-1556

Amazon SimpleDB Developer GuideAPI Error Retries

Page 61: sdb-dg

if (status == HttpStatus.SC_INTERNAL_SERVER_ERROR || status == HttpStatus.SC_SERVICE_UNAVAILABLE) { shouldRetry = true; long delay = (long) (Math.random() * (Math.pow(4, retries++) * 100L)); try { Thread.sleep(delay); } catch (InterruptedException iex){ log.error("Caught InterruptedException exception", iex); } } else { shouldRetry = false; /* Process 4xx (Client) error */ } } } catch (IOException ioe) { log.error("Caught IOException exception", ioe); } catch (Exception e) { log.error("Caught Exception", e); } finally { /* Perform clean-up as necessary */ } } while (shouldRetry && retries < MAX_NUMBER_OF_RETRIES);

To download a complete Java code sample that implements the exponential backoff algorithm, go to theAmazon sample libraries.

Common ParametersThis section describes parameters used by Amazon SimpleDB operations.

Some parameters are required by all operations and are not repeated in the documentation unless theusage is unique for that operation. Other parameters are conditional which indicates they are requiredfor some operations and optional for others.

Request Parameters

TypeDescriptionName

RequiredName of the action.Action

ConditionalName of attribute associated with anitem. Required by PutAttributes andBatchPutAttributes. Optional forDeleteAttributes.

Attribute.X.Name (REST)

<Attribute><Name>...</Name></Attribute> (SOAP)

ConditionalValue of attribute associated with anitem. Required by PutAttributes andBatchPutAttributes. Optional forDeleteAttributes.

Attribute.X.Value (REST)

<Attribute><Value>...</Value></Attribute> (SOAP)

API Version 2009-04-1557

Amazon SimpleDB Developer GuideCommon Parameters

Page 62: sdb-dg

TypeDescriptionName

OptionalFlag to specify whether to replace theattribute/value or to add a newattribute/value. Used byPutAttributes andBatchPutAttributes. The defaultsetting is false.

Attribute.X.Replace (REST)

<Attribute><Replace>...</Replace></Attribute> (SOAP)

ConditionalName of attribute to return. Optional forGetAttributes.

AttributeName

RequiredFor more information, see RequestAuthentication (p. 16).

AWSAccessKeyId

RequiredName of the domain used in theoperation.

DomainName

ConditionalUnique identifier of an item. Required byPutAttributes,BatchPutAttributes,GetAttributes, andDeleteAttributes.

ItemName

OptionalThe maximum number of domain namesyou want returned. Used byListDomains. The range is 1 to 100.The default setting is 100.

MaxNumberOfDomains

OptionalMaximum number of items to return inthe response. The range is 1 to 2500.The default setting is 100.

MaxNumberOfItems

OptionalString that tells Amazon SimpleDBwhere to start the next list of domain oritem names. Used by ListDomains andGetAttributes.

NextToken

OptionalString that specifies the query that isexecuted against the domain.

SelectExpression

RequiredFor more information, see AuthenticatingREST Requests (p. 23).

Signature

ConditionalRequired when you use signatureversion 2 with REST requests. For moreinformation, see Authenticating RESTRequests (p. 23).

SignatureMethod

RequiredFor more information, see AuthenticatingREST Requests (p. 23).

SignatureVersion

RequiredFor more information, see RequestAuthentication (p. 16).

Timestamp

RequiredVersion of the API. The version of theAPI described in this document is2009-04-15.

Version

API Version 2009-04-1558

Amazon SimpleDB Developer GuideRequest Parameters

Page 63: sdb-dg

Request Parameter FormatsThe following are specifications for Amazon SimpleDB user data:

User Data Specifications

• Domain names—Allowed characters are a-z, A-Z, 0-9, '_', '-', and '.' .Domain names can be between 3 and 255 characters long.

• Item names, attribute names, and attribute values—Allowed characters are all UTF-8 charactersvalid in XML documents.Control characters and any sequences that are not valid in XML are returned Base64-encoded. Formore information, see Working with XML-Restricted Characters (p. 51).

Quotes and escape charactersUser data in query expressions must be enclosed in single quotes. If a single quote is used within theuser data, it must be escaped using a backslash. If a backslash is used within user data, it must beescaped as well. Examples:

Escaped StringOriginal String

'John\'s AWS account''John's AWS account'

'c:\\path\\constant'c:\path\constant

Common Response ElementsDescriptionName

A unique ID for tracking the request.RequestId

The measure of machine utilization for this request. This does notinclude storage or transfer usage.

BoxUsage

Common Error ResponsesRequest authentication errors are described in API Error Codes (p. 89). All other errors are listed withthe appropriate operations.

Operations

API Version 2009-04-1559

Amazon SimpleDB Developer GuideRequest Parameter Formats

Page 64: sdb-dg

BatchPutAttributes

DescriptionWith the BatchPutAttributes operation, you can perform multiple PutAttribute operations in asingle call. This helps you yield savings in round trips and latencies, and enables Amazon SimpleDB tooptimize requests, which generally yields better throughput.

You can specify attributes and values for items using a combination of the Item.Y.Attribute.X.Nameand Item.Y.Attribute.X.Value parameters. To specify attributes and values for the first item, youuse Item.1.Attribute.1.Name and Item.1.Attribute.1.Value for the first attribute,Item.1.Attribute.2.Name and Item.1.Attribute.2.Value for the second attribute, and so on.

To specify attributes and values for the second item, you use Item.2.Attribute.1.Name andItem.2.Attribute.1.Value for the first attribute, Item.2.Attribute.2.Name andItem.2.Attribute.2.Value for the second attribute, and so on.

Amazon SimpleDB uniquely identifies attributes in an item by their name/value combinations. For example,a single item can have the attributes { "first_name", "first_value" } and { "first_name",second_value" }. However, it cannot have two attribute instances where both theItem.Y.Attribute.X.Name and Item.Y.Attribute.X.Value are the same.

Optionally, you can supply the Replace parameter for each individual attribute. Setting this value to truecauses the new attribute value to replace the existing attribute value(s) if any exist. Otherwise, AmazonSimpleDB simply inserts the attribute values. For example, if an item has the attributes { 'a', '1' },{ 'b', '2'}, and { 'b', '3' } and the requester calls BatchPutAttributes using the attributes{ 'b', '4' } with the Replace parameter set to true, the final attributes of the item are changed to{ 'a', '1' } and { 'b', '4' }. This occurs because the new 'b' attribute replaces the old value.

Note

You cannot specify an empty string as an item or attribute name.

The BatchPutAttributes operation succeeds or fails in its entirety. There are no partial puts.

You can execute multiple BatchPutAttributes operations and other operations in parallel.However, large numbers of concurrent BatchPutAttributes calls can result in ServiceUnavailable (503) responses.

This operation is vulnerable to exceeding the maximum URL size when making a REST requestusing the HTTP GET method.

This operation does not support conditions using Expected.X.Name, Expected.X.Value, orExpected.X.Exists.

The following limitations are enforced for this operation:

• 256 attribute name-value pairs per item

• 1 MB request size

• 1 billion attributes per domain

• 10 GB of total user data storage per domain

• 25 item limit per BatchPutAttributes operation

API Version 2009-04-1560

Amazon SimpleDB Developer GuideBatchPutAttributes

Page 65: sdb-dg

Request Parameters

RequiredDescriptionName

YesThe name of the item.

Type: String.

Default: None.

Item.Y.ItemName

YesThe name of the attribute for the specifieditem.Y or X can be any positive integer or0.

Type: String.

Default: None.

Item.Y.Attribute.X.Name (REST)

<Attribute><Name>...</Name></Attribute> (SOAP)

YesThe value of the attribute for the specifieditem.Y or X can be any positive integer or0.

Type: String.

Default: None.

Item.Y.Attribute.X.Value (REST)

<Attribute><Value>...</Value></Attribute> (SOAP)

NoFlag to specify whether to replace theAttribute/Value or to add a newAttribute/Value. The replace parameter ismore resource intensive than non-replaceoperations and is not recommended unlessrequired.Y or X can be any positive integeror 0.

To reduce the request size and latencies,we recommend that you do not specify thisrequest parameter at all.

Type: Boolean.

Default: false.

Item.Y.Attribute.X.Replace (REST)

<Attribute><Replace>...</Replace></Attribute> (SOAP)

YesThe name of the domain in which to performthe operation.

Type: String

Default: None.

DomainName

Note

When using eventually consistent reads, a GetAttributes (p. 75) or Select (p. 86) request (read)immediately after a DeleteAttributes (p. 66) or PutAttributes (p. 80) request (write) might notreturn the updated data. Some items might be updated before others, despite the fact that theoperation never partially succeeds. A consistent read always reflects all writes that received asuccessful response prior to the read. For more information, see Consistency (p. 7).

Response ElementsSee Common Response Elements (p. 59).

API Version 2009-04-1561

Amazon SimpleDB Developer GuideBatchPutAttributes

Page 66: sdb-dg

Special Errors

DescriptionError

Item item_name was specified more than once.DuplicateItemName

Value value for parameter Name is invalid. Valueexceeds maximum length of 1024.

InvalidParameterValue

Value value for parameter Value is invalid. Valueexceeds maximum length of 1024.

InvalidParameterValue

Value value for parameter Item is invalid. Valueexceeds max length of 1024.

InvalidParameterValue

Value value for parameter Replace is invalid. TheReplace flag should be either true or false.

InvalidParameterValue

The request must contain the parameter DomainName.MissingParameter

The request must contain the parameter ItemName.MissingParameter

Attribute.Value missing forAttribute.Name=attribute_name.

MissingParameter

Attribute.Name missing forAttribute.Value=attribute_name.

MissingParameter

No attributes for item item_name.MissingParameter

The specified domain does not exist.NoSuchDomain

Too many attributes in this item.NumberItemAttributesExceeded

Too many attributes in this domain.NumberDomainAttributesExceeded

Too many bytes in this domain.NumberDomainBytesExceeded

Too many items in a single call. Up to 25 items per callallowed.

NumberSubmittedItemsExceeded

Too many attributes for item itemName in a single call.Up to 256 attributes per call allowed.

NumberSubmittedAttributesExceeded

Examples

Sample Request

The following example uses BatchPutAttributes on Shirt1, which has attributes (Color=Blue),(Size=Med), and (Price=0014.99) in MyDomain. If Shirt1 already had the Price attribute, thisoperation would replace the values for that attribute. Otherwise, a new (additional) Price attribute iscreated with the value 0014.99.

The example also uses BatchPutAttributes on Shirt2 which has attributes (Color=Red),(Size=Large), and (Price=0019.99).

https://sdb.amazonaws.com/

API Version 2009-04-1562

Amazon SimpleDB Developer GuideBatchPutAttributes

Page 67: sdb-dg

?Action=BatchPutAttributes&Item.1.ItemName=Shirt1&Item.1.Attribute.1.Name=Color&Item.1.Attribute.1.Value=Blue&Item.1.Attribute.2.Name=Size&Item.1.Attribute.2.Value=Med&Item.1.Attribute.3.Name=Price&Item.1.Attribute.3.Value=0014.99&Item.1.Attribute.3.Replace=true&Item.2.ItemName=Shirt2&Item.2.Attribute.1.Name=Color&Item.2.Attribute.1.Value=Red&Item.2.Attribute.2.Name=Size&Item.2.Attribute.2.Value=Large&Item.2.Attribute.3.Name=Price&Item.2.Attribute.3.Value=0019.99&AWSAccessKeyId=[valid access key id]&DomainName=MyDomain&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2009-01-12T15%3A03%3A05-07%3A00&Version=2009-04-15&Signature=[valid signature]

Sample Response

<BatchPutAttributesResponse> <ResponseMetadata> <RequestId>490206ce-8292-456c-a00f-61b335eb202b</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></BatchPutAttributesResponse>

Related Actions• PutAttributes (p. 80)

• DeleteAttributes (p. 66)

• GetAttributes (p. 75)

API Version 2009-04-1563

Amazon SimpleDB Developer GuideBatchPutAttributes

Page 68: sdb-dg

CreateDomain

DescriptionThe CreateDomain operation creates a new domain. The domain name must be unique among thedomains associated with the Access Key ID provided in the request.The CreateDomain operation mighttake 10 or more seconds to complete.

Note

CreateDomain is an idempotent operation; running it multiple times using the same domainname will not result in an error response.

You can create up to 100 domains per account.

If you require additional domains, go to http://aws.amazon.com/contact-us/simpledb-limit-request/.

Request Parameters

RequiredDescriptionName

YesThe name of the domain to create.The namecan range between 3 and 255 characters andcan contain the following characters: a-z, A-Z,0-9, '_', '-', and '.'.

Type: String

DomainName

Response ElementsSee Common Response Elements (p. 59).

Special Errors

DescriptionError

Value (" + value + ") for parameter DomainName is invalid.InvalidParameterValue

The request must contain the parameter DomainName.MissingParameter

Number of domains limit exceeded.NumberDomainsExceeded

Examples

Sample Request

https://sdb.amazonaws.com/?Action=CreateDomain&AWSAccessKeyId=[valid access key id]&DomainName=MyDomain&SignatureVersion=2&SignatureMethod=HmacSHA256

API Version 2009-04-1564

Amazon SimpleDB Developer GuideCreateDomain

Page 69: sdb-dg

&Timestamp=2010-01-25T15%3A01%3A28-07%3A00&Version=2009-04-15&Signature=[valid signature]

Sample Response

<CreateDomainResponse> <ResponseMetadata> <RequestId>2a1305a2-ed1c-43fc-b7c4-e6966b5e2727</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></CreateDomainResponse>

Related Actions• DeleteDomain (p. 71)

• ListDomains (p. 78)

API Version 2009-04-1565

Amazon SimpleDB Developer GuideCreateDomain

Page 70: sdb-dg

DeleteAttributes

DescriptionDeletes one or more attributes associated with the item. If all attributes of an item are deleted, the itemis deleted.

Note

If you specify DeleteAttributes without attributes or values, all the attributes for the item aredeleted.

Unless you specify conditions, the DeleteAttributes is an idempotent operation; running itmultiple times on the same item or attribute does not result in an error response.

Conditional deletes are useful for only deleting items and attributes if specific conditions are met.If the conditions are met, Amazon SimpleDB performs the delete. Otherwise, the data is notdeleted.When using eventually consistent reads, a GetAttributes (p. 75) or Select (p. 86) request (read)immediately after a DeleteAttributes (p. 66) or PutAttributes (p. 80) request (write) might notreturn the updated data. A consistent read always reflects all writes that received a successfulresponse prior to the read. For more information, see Consistency (p. 7).

You can perform the expected conditional check on one attribute per operation.

Request Parameters

RequiredDescriptionName

YesThe name of the item.

Type: String

ItemName

NoThe name of the attribute. X can be anypositive integer or 0.

Type: String

Attribute.X.Name (REST)

<Attribute><Name>...</Name></Attribute> (SOAP)

NoThe name of the attribute value (formulti-valued attributes). X can be anypositive integer or 0.

Type: String

Attribute.X.Value (REST)

<Attribute><Value>...</Value></Attribute> (SOAP)

YesThe name of the domain in which to performthe operation.

Type: String

DomainName

API Version 2009-04-1566

Amazon SimpleDB Developer GuideDeleteAttributes

Page 71: sdb-dg

RequiredDescriptionName

ConditionalName of the attribute to check. X can be anypositive integer or 0.

Type: String.

Conditions: Must be used with the expectedvalue or expected exists parameter.

When used with the expected valueparameter, you specify the value to check.

When expected exists is set to true and itis used with the expected value parameter,it performs similarly to just using theexpected value parameter. When expectedexists is set to false, the operation isperformed if the expected attribute is notpresent.

Can only be used with single-valuedattributes.

Expected.X.Name (REST)

<Expected><Name>...</Name></Expected> (SOAP)

ConditionalValue of the attribute to check. X can be anypositive integer or 0.

Type: String.

Conditions: Must be used with the expectedname parameter. Can be used with theexpected exists parameter if that parameteris set to true.

Can only be used with single-valuedattributes.

Expected.X.Value (REST)

<Expected><Value>...</Value></Expected> (SOAP)

ConditionalFlag to test the existence of an attribute whileperforming conditional updates. X can beany positive integer or 0.

Type: Boolean.

Conditions: Must be used with the expectedname parameter. When set to true, thismust be used with the expected valueparameter. When set to false, this cannotbe used with the expected value parameter.

Can only be used with single-valuedattributes.

Expected.X.Exists (REST)

<Expected><Exists>...</Exists></Expected> (SOAP)

Response ElementsSee Common Response Elements (p. 59).

Special Errors

DescriptionError

Attribute ("+ name + ") does not existAttributeDoesNotExist

Conditional check failed. Attribute (" + name + ") value exists.ConditionalCheckFailed

API Version 2009-04-1567

Amazon SimpleDB Developer GuideDeleteAttributes

Page 72: sdb-dg

DescriptionError

Conditional check failed. Attribute ("+ name +") value is ("+value +") but was expected ("+ expValue +")

ConditionalCheckFailed

Expected.Exists=false and Expected.Value cannot bespecified together

ExistsAndExpectedValue

If Expected.Exists=true or unspecified, then Expected.Valuehas to be specified

IncompleteExpectedExpression

Value (" + value + ") for parameter Expected.Exists is invalid.Expected.Exists should be either true or false.

InvalidParameterValue

Value (" + value + ") for parameter Name is invalid.The emptystring is an illegal attribute name

InvalidParameterValue

Value (" + value + ") for parameter Name is invalid. Valueexceeds maximum length of 1024.

InvalidParameterValue

Value (" + value + ") for parameter Value is invalid. Valueexceeds maximum length of 1024.

InvalidParameterValue

Value (" + value + ") for parameter Item is invalid. Valueexceeds max length of 1024.

InvalidParameterValue

Value (" + value + ") for parameter Value is invalid. Valueexceeds maximum length of 1024

InvalidParameterValue

Parameter (" + parameterName +") is only supported in WSDLversion 2009-04-15 or beyond. Please upgrade to new version

InvalidWSDLVersion

The request must contain the parameter DomainName.MissingParameter

The request must contain the parameter ItemName.MissingParameter

The request must contain the parameter NameMissingParameter

Only one Exists condition can be specifiedMultipleExistsConditions

Only one Expected.Name can be specifiedMultipleExpectedNames

Only one Expected.Value can be specifiedMultipleExpectedValues

Attribute (" + name + ") is multi-valued. Conditional check canonly be performed on a single-valued attribute

MultiValuedAttribute

The specified domain does not exist.NoSuchDomain

Examples

Sample Request

In this example, the Jumbo Fez has sold out in several colors. The following deletes the red, brick, andgarnet values from the color attribute of the JumboFez item.

https://sdb.amazonaws.com/?Action=DeleteAttributes

API Version 2009-04-1568

Amazon SimpleDB Developer GuideDeleteAttributes

Page 73: sdb-dg

&Attribute.1.Name=color&Attribute.1.Value=red&Attribute.2.Name=color&Attribute.2.Value=brick&Attribute.3.Name=color&Attribute.3.Value=garnet&AWSAccessKeyId=[valid access key id]&DomainName=MyDomain&ItemName=JumboFez&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A03%3A07-07%3A00&Version=2009-04-15&Signature=[valid signature]

Sample Response

<DeleteAttributesResponse"> <ResponseMetadata> <RequestId>05ae667c-cfac-41a8-ab37-a9c897c4c3ca</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></DeleteAttributesResponse>

Sample Request

In this example, the Micro Fez has sold out. The following deletes the Micro Fez if the quantity reaches0

Note

For more examples of conditional operations, see Conditionally Putting and Deleting Data (p. 34).

https://sdb.amazonaws.com/?Action=DeleteAttributes&ItemName=MicroFezExpected.1.Name=quantityExpected.1.Value=0&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A03%3A07-07%3A00&Version=2009-04-15&Signature=[valid signature]

Sample Response

<DeleteAttributesResponse> <ResponseMetadata> <RequestId>05ae667c-cfac-41a8-ab37-a9c897c4c3ca</RequestId> <BoxUsage>0.0000219907</BoxUsage>

API Version 2009-04-1569

Amazon SimpleDB Developer GuideDeleteAttributes

Page 74: sdb-dg

</ResponseMetadata></DeleteAttributesResponse>

Related Actions• GetAttributes (p. 75)

• PutAttributes (p. 80)

API Version 2009-04-1570

Amazon SimpleDB Developer GuideDeleteAttributes

Page 75: sdb-dg

DeleteDomain

DescriptionThe DeleteDomain operation deletes a domain. Any items (and their attributes) in the domain are deletedas well. The DeleteDomain operation might take 10 or more seconds to complete.

Note

Running DeleteDomain on a domain that does not exist or running the function multiple timesusing the same domain name will not result in an error response.

Request Parameters

RequiredDescriptionName

YesThe name of the domain to delete.

Type: String

DomainName

Response ElementsSee Common Response Elements (p. 59).

Special Errors

DescriptionError

The request must contain the parameter DomainName.MissingParameter

Examples

Sample Request

https://sdb.amazonaws.com/?Action=DeleteDomain&AWSAccessKeyId=[valid access key id]&DomainName=MyDomain&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A02%3A20-07%3A00&Version=2009-04-15&Signature=[valid signature]

Sample Response

<DeleteDomainResponse> <ResponseMetadata>

API Version 2009-04-1571

Amazon SimpleDB Developer GuideDeleteDomain

Page 76: sdb-dg

<RequestId>c522638b-31a2-4d69-b376-8c5428744704</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></DeleteDomainResponse>

Related Actions• CreateDomain (p. 64)

• ListDomains (p. 78)

API Version 2009-04-1572

Amazon SimpleDB Developer GuideDeleteDomain

Page 77: sdb-dg

DomainMetadata

DescriptionReturns information about the domain, including when the domain was created, the number of items andattributes, and the size of attribute names and values.

Request Parameters

RequiredDescriptionName

YesThe name of the domain for which to displaymetadata.

Type: String

DomainName

Response Elements

DescriptionName

The data and time when metadata was calculatedin Epoch (UNIX) time.

Timestamp

The number of all items in the domain.ItemCount

The number of all attribute name/value pairs in thedomain.

AttributeValueCount

The number of unique attribute names in thedomain.

AttributeNameCount

The total size of all item names in the domain, inbytes.

ItemNamesSizeBytes

The total size of all attribute values, in bytes.AttributeValuesSizeBytes

The total size of all unique attribute names, inbytes.

AttributeNamesSizeBytes

Special Errors

DescriptionError

The request must contain the parameter DomainName.MissingParameter

The specified domain does not exist.NoSuchDomain

API Version 2009-04-1573

Amazon SimpleDB Developer GuideDomainMetadata

Page 78: sdb-dg

Examples

Sample Request

https://sdb.amazonaws.com/?Action=DomainMetadata&AWSAccessKeyId=[valid access key id]&DomainName=MyDomain&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A03%3A07-07%3A00&Version=2009-04-15&Signature=[valid signature]

Sample Response

<DomainMetadataResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/"> <DomainMetadataResult> <ItemCount>195078</ItemCount> <ItemNamesSizeBytes>2586634</ItemNamesSizeBytes> <AttributeNameCount >12</AttributeNameCount > <AttributeNamesSizeBytes>120</AttributeNamesSizeBytes> <AttributeValueCount>3690416</AttributeValueCount> <AttributeValuesSizeBytes>50149756</AttributeValuesSizeBytes> <Timestamp>1225486466</Timestamp> </DomainMetadataResult> <ResponseMetadata> <RequestId>b1e8f1f7-42e9-494c-ad09-2674e557526d</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></DomainMetadataResponse>

Related Actions• CreateDomain (p. 64)

• ListDomains (p. 78)

API Version 2009-04-1574

Amazon SimpleDB Developer GuideDomainMetadata

Page 79: sdb-dg

GetAttributes

DescriptionReturns all of the attributes associated with the item. Optionally, the attributes returned can be limited toone or more specified attribute name parameters.

Amazon SimpleDB keeps multiple copies of each domain. When data is written or updated, all copies ofthe data are updated. However, it takes time for the update to propagate to all storage locations. Thedata will eventually be consistent, but an immediate read might not show the change. If eventuallyconsistent reads are not acceptable for your application, use ConsistentRead. Although this operationmight take longer than a standard read, it always returns the last updated value.

Note

If the item does not exist on the replica that was accessed for this operation, an empty set isreturned.

If you specify GetAttributes without any attribute names, all the attributes for the item arereturned.

Request Parameters

RequiredDescriptionName

YesThe name of the item.ItemName

NoThe name of the attribute.AttributeName

YesThe name of the domain in which to performthe operation.

Type: String

DomainName

NoWhen set to true, ensures that the mostrecent data is returned. For more information,see Consistency (p. 7)

Type: Boolean

Default: false

ConsistentRead

Response Elements

DescriptionName

The name of the attribute and value.<Attribute><Name>... </Name><Value>...</Value></Attribute>

Special Errors

DescriptionError

Value (" + value + ") for parameter Name is invalid. Valueexceeds maximum length of 1024.

InvalidParameterValue

API Version 2009-04-1575

Amazon SimpleDB Developer GuideGetAttributes

Page 80: sdb-dg

DescriptionError

Value (" + value + ") for parameter Item is invalid. Valueexceeds max length of 1024.

InvalidParameterValue

Value (" + value + ") for parameter ConsistentRead is invalid.The ConsistentRead flag should be either true or false.

InvalidParameterValue

The request must contain the parameter DomainName.MissingParameter

The request must contain the parameter ItemName.MissingParameter

The specified domain does not exist.NoSuchDomain

Examples

Sample Request

https://sdb.amazonaws.com/?Action=GetAttributes&AWSAccessKeyId=[valid access key id]&DomainName=MyDomain&ItemName=Item123&ConsistentRead=true&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A03%3A07-07%3A00&Version=2009-04-15&Signature=[valid signature]

Sample Response

<GetAttributesResponse> <GetAttributesResult> <Attribute><Name>Color</Name><Value>Blue</Value></Attribute> <Attribute><Name>Size</Name><Value>Med</Value></Attribute> <Attribute><Name>Price</Name><Value>14</Value></Attribute> </GetAttributesResult> <ResponseMetadata> <RequestId>b1e8f1f7-42e9-494c-ad09-2674e557526d</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></GetAttributesResponse>

Sample Request

https://sdb.amazonaws.com/?Action=GetAttributes&AWSAccessKeyId=[valid access key id]&DomainName=MyDomain&ItemName=Item123

API Version 2009-04-1576

Amazon SimpleDB Developer GuideGetAttributes

Page 81: sdb-dg

&AttributeName.0=Color&AttributeName.1=Size&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A03%3A07-07%3A00&Version=2009-04-15&Signature=[valid signature]

Sample Response

<GetAttributesResponse> <GetAttributesResult> <Attribute><Name>Color</Name><Value>Blue</Value></Attribute> <Attribute><Name>Size</Name><Value>Med</Value></Attribute> </GetAttributesResult> <ResponseMetadata> <RequestId>b1e8f1f7-42e9-494c-ad09-2674e557526d</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></GetAttributesResponse>

Related Actions• DeleteAttributes (p. 66)

• PutAttributes (p. 80)

API Version 2009-04-1577

Amazon SimpleDB Developer GuideGetAttributes

Page 82: sdb-dg

ListDomains

DescriptionThe ListDomains operation lists all domains associated with the Access Key ID. It returns domain namesup to the limit set by MaxNumberOfDomains. A NextToken is returned if there are more thanMaxNumberOfDomains domains. Calling ListDomains successive times with the NextToken returnsup to MaxNumberOfDomains more domain names each time.

Request Parameters

RequiredDescriptionName

NoThe maximum number of domain names youwant returned.

Type: String

The range is 1 to 100.

The default setting is 100.

MaxNumberOfDomains

NoString that tells Amazon SimpleDB where tostart the next list of domain names.

NextToken

Response Elements

DescriptionName

Domain names that match the expression.DomainName

An opaque token indicating that there are more thanMaxNumberOfDomains domains still available.

NextToken

Special Errors

DescriptionError

Value (" + value + ") for parameter MaxNumberOfDomainsis invalid. MaxNumberOfDomains must be between 1 and100.

InvalidParameterValue

The specified next token is not valid.InvalidNextToken

Examples

Sample Request

https://sdb.amazonaws.com/?Action=ListDomains&AWSAccessKeyId=[valid access key id]&MaxNumberOfDomains=2

API Version 2009-04-1578

Amazon SimpleDB Developer GuideListDomains

Page 83: sdb-dg

&NextToken=[valid next token]&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A02%3A19-07%3A00&Version=2009-04-15&Signature=[valid signature]

Sample Response

<ListDomainsResponse> <ListDomainsResult> <DomainName>Domain1-200706011651</DomainName> <DomainName>Domain2-200706011652</DomainName> <NextToken>TWV0ZXJpbmdUZXN0RG9tYWluMS0yMDA3MDYwMTE2NTY=</NextToken> </ListDomainsResult> <ResponseMetadata> <RequestId>eb13162f-1b95-4511-8b12-489b86acfd28</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></ListDomainsResponse>

Related Actions• CreateDomain (p. 64)

• DeleteDomain (p. 71)

API Version 2009-04-1579

Amazon SimpleDB Developer GuideListDomains

Page 84: sdb-dg

PutAttributes

DescriptionThe PutAttributes operation creates or replaces attributes in an item.You specify new attributes usinga combination of the Attribute.X.Name and Attribute.X.Value parameters.You specify the firstattribute by the parameters Attribute.1.Name and Attribute.1.Value, the second attribute by theparameters Attribute.2.Name and Attribute.2.Value, and so on.

Attributes are uniquely identified in an item by their name/value combination. For example, a single itemcan have the attributes { "first_name", "first_value" } and { "first_name",second_value" }. However, it cannot have two attribute instances where both the Attribute.X.Nameand Attribute.X.Value are the same.

Optionally, the requester can supply the Replace parameter for each individual attribute. Setting thisvalue to true causes the new attribute value to replace the existing attribute value(s). For example, if anitem has the attributes { 'a', '1' }, { 'b', '2'} and { 'b', '3' } and the requester callsPutAttributes using the attributes { 'b', '4' } with the Replace parameter set to true, the finalattributes of the item are changed to { 'a', '1' } and { 'b', '4' }, which replaces the previousvalues of the 'b' attribute with the new value.

Conditional updates are useful for ensuring multiple processes do not overwrite each other. To preventthis from occurring, you can specify the expected attribute name and value. If they match, AmazonSimpleDB performs the update. Otherwise, the update does not occur.

Note

Using PutAttributes to replace attribute values that do not exist will not result in an errorresponse.

You cannot specify an empty string as an attribute name.

When using eventually consistent reads, a GetAttributes (p. 75) or Select (p. 86) request (read)immediately after a DeleteAttributes (p. 66) or PutAttributes (p. 80) request (write) might notreturn the updated data. A consistent read always reflects all writes that received a successfulresponse prior to the read. For more information, see Consistency (p. 7).

You can perform the expected conditional check on one attribute per operation.

The following limitations are enforced for this operation:

• 256 total attribute name-value pairs per item

• One billion attributes per domain

• 10 GB of total user data storage per domain

Request Parameters

RequiredDescriptionName

YesThe name of the attribute. X can be anypositive integer or 0.

Type: String.

Attribute.X.Name (REST)

<Attribute><Name>...</Name></Attribute> (SOAP)

API Version 2009-04-1580

Amazon SimpleDB Developer GuidePutAttributes

Page 85: sdb-dg

RequiredDescriptionName

YesThe value of the attribute. X can be anypositive integer or 0.

Type: String.

Attribute.X.Value (REST)

<Attribute><Value>...</Value></Attribute> (SOAP)

YesThe name of the item.

Type: String.

ItemName

NoFlag to specify whether to replace theAttribute/Value or to add a newAttribute/Value. X can be any positive integeror 0.

Type: Boolean.

Default: false.

Attribute.X.Replace (REST)

<Attribute><Replace>...</Replace></Attribute> (SOAP)

YesThe name of the domain in which to performthe operation.

Type: String

DomainName

ConditionalName of the attribute to check. X can be anypositive integer or 0.

Type: String.

Conditions: Must be used with the expectedvalue or expected exists parameter.

When used with the expected valueparameter, you specify the value to check.

When expected exists is set to true and itis used with the expected value parameter,it performs similarly to just using theexpected value parameter. When expectedexists is set to false, the operation isperformed if the expected attribute is notpresent.

Can only be used with single-valuedattributes.

Expected.X.Name (REST)

<Expected><Name>...</Name></Expected> (SOAP)

ConditionalValue of the attribute to check. X can be anypositive integer or 0.

Type: String.

Conditions: Must be used with the expectedname parameter. Can be used with theexpected exists parameter if that parameteris set to true.

Can only be used with single-valuedattributes.

Expected.X.Value (REST)

<Expected><Value>...</Value></Expected> (SOAP)

API Version 2009-04-1581

Amazon SimpleDB Developer GuidePutAttributes

Page 86: sdb-dg

RequiredDescriptionName

ConditionalFlag to test the existence of an attribute whileperforming conditional updates. X can beany positive integer or 0.

Type: Boolean.

Conditions: Must be used with the expectedname parameter. When set to true, thismust be used with the expected valueparameter. When set to false, this cannotbe used with the expected value parameter.

Can only be used with single-valuedattributes.

Expected.X.Exists (REST)

<Expected><Exists>...</Exists></Expected> (SOAP)

Response ElementsSee Common Response Elements (p. 59).

Special Errors

DescriptionError

Attribute ("+ name + ") does not existAttributeDoesNotExist

Conditional check failed. Attribute (" + name + ") value exists.ConditionalCheckFailed

Conditional check failed. Attribute ("+ name +") value is ("+value +") but was expected ("+ expValue +")

ConditionalCheckFailed

Expected.Exists=false and Expected.Value cannot bespecified together

ExistsAndExpectedValue

If Expected.Exists=true or unspecified, then Expected.Valuehas to be specified

IncompleteExpectedExpression

Value (" + value + ") for parameter Expected.Exists is invalid.Expected.Exists should be either true or false.

InvalidParameterValue

Value (" + value + ") for parameter Name is invalid.The emptystring is an illegal attribute name

InvalidParameterValue

Value (" + value + ") for parameter Value is invalid. Valueexceeds maximum length of 1024

InvalidParameterValue

Value (" + value + ") for parameter Name is invalid. Valueexceeds maximum length of 1024.

InvalidParameterValue

Value (" + value + ") for parameter Value is invalid. Valueexceeds maximum length of 1024.

InvalidParameterValue

Value (" + value + ") for parameter Item is invalid. Valueexceeds max length of 1024.

InvalidParameterValue

Value (" + value + ") for parameter Replace is invalid. TheReplace flag should be either true or false.

InvalidParameterValue

API Version 2009-04-1582

Amazon SimpleDB Developer GuidePutAttributes

Page 87: sdb-dg

DescriptionError

Parameter (" + parameterName +") is only supported in WSDLversion 2009-04-15 or beyond. Please upgrade to new version

InvalidWSDLVersion

The request must contain the parameter NameMissingParameter

The request must contain the parameter DomainName.MissingParameter

The request must contain the parameter ItemName.MissingParameter

Attribute.Value missing forAttribute.Name='<attribute name>'.

MissingParameter

Attribute.Name missing forAttribute.Value='<attribute value>'.

MissingParameter

Only one Exists condition can be specifiedMultipleExistsConditions

Only one Expected.Name can be specifiedMultipleExpectedNames

Only one Expected.Value can be specifiedMultipleExpectedValues

Attribute (" + name + ") is multi-valued. Conditional check canonly be performed on a single-valued attribute

MultiValuedAttribute

The specified domain does not exist.NoSuchDomain

Too many attributes in this item.NumberItemAttributesExceeded

Too many attributes in this domain.NumberDomainAttributesExceeded

Too many bytes in this domain.NumberDomainBytesExceeded

Examples

Sample Request

The following example uses PutAttributes on Item123, which has attributes (Color=Blue),(Size=Med), and (Price=0014.99) in MyDomain. If Item123 already had the Price attribute, thisoperation would replace the values for that attribute.

https://sdb.amazonaws.com/?Action=PutAttributes&Attribute.1.Name=Color&Attribute.1.Value=Blue&Attribute.2.Name=Size&Attribute.2.Value=Med&Attribute.3.Name=Price&Attribute.3.Value=0014.99&Attribute.3.Replace=true&AWSAccessKeyId=[valid access key id]&DomainName=MyDomain&ItemName=Item123&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A03%3A05-07%3A00

API Version 2009-04-1583

Amazon SimpleDB Developer GuidePutAttributes

Page 88: sdb-dg

&Version=2009-04-15&Signature=[valid signature]

Sample Response

<PutAttributesResponse> <ResponseMetadata> <RequestId>490206ce-8292-456c-a00f-61b335eb202b</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></PutAttributesResponse>

Sample Request

The following example uses conditional updates to ensure that multiple processes do not overwrite eachother’s settings. For example, if two people are buying the JumboFez item at the same time, the followingensures that the inventory is decremented correctly.

Note

For more examples of conditional operations, see Conditionally Putting and Deleting Data (p. 34).

https://sdb.amazonaws.com/?Action=PutAttributes&DomainName=MyDomain&ItemName=JumboFez&Attribute.1.Name=quantity&Attribute.1.Value=14&Attribute.1.Replace=true&Expected.1.Name=quantity&Expected.1.Value=15&AWSAccessKeyId=[valid access key id]&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A03%3A05-07%3A00&Version=2009-04-15&Signature=[valid signature]

Sample Response

If the update condition is met, Amazon SimpleDB returns output similar to the following.

<PutAttributesResponse> <ResponseMetadata> <RequestId>490206ce-8292-456c-a00f-61b335eb202b</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></PutAttributesResponse>

API Version 2009-04-1584

Amazon SimpleDB Developer GuidePutAttributes

Page 89: sdb-dg

In this example, one of the servers updates the value and the other receives an error. The server thatreceives the error resubmits the request specifying a value of 13 and an expected value of 14, ensuringthat the inventory is correctly set.

Related Actions• DeleteAttributes (p. 66)

• GetAttributes (p. 75)

API Version 2009-04-1585

Amazon SimpleDB Developer GuidePutAttributes

Page 90: sdb-dg

Select

DescriptionThe Select operation returns a set of Attributes for ItemNames that match the select expression.Select is similar to the standard SQL SELECT statement.

Amazon SimpleDB keeps multiple copies of each domain. When data is written or updated, all copies ofthe data are updated. However, it takes time for the update to propagate to all storage locations. Thedata will eventually be consistent, but an immediate read might not show the change. If eventuallyconsistent reads are not acceptable for your application, use ConsistentRead. Although this operationmight take longer than a standard read, it always returns the last updated value.

The total size of the response cannot exceed 1 MB. Amazon SimpleDB automatically adjusts the numberof items returned per page to enforce this limit. For example, even if you ask to retrieve 2500 items, buteach individual item is 10 KB in size, the system returns 100 items and an appropriate next token so youcan get the next page of results.

For information on how to construct select expressions, see Using Select to Create Amazon SimpleDBQueries (p. 38).

Note

Operations that run longer than 5 seconds return a time-out error response or a partial or emptyresult set. Partial and empty result sets contains a next token which allow you to continue theoperation from where it left off.

Responses larger than one megabyte return a partial result set.

Your application should not excessively retry queries that return RequestTimeout errors. If youreceive too many RequestTimeout errors, reduce the complexity of your query expression.

When designing your application, keep in mind that Amazon SimpleDB does not guarantee howattributes are ordered in the returned response.

For information about limits that affect Select, see Limits (p. 9).

The select operation is case-sensitive.

Request Parameters

RequiredDescriptionName

YesThe expression used to query the domain.

Type: String

Default: None

SelectExpression

NoWhen set to true, ensures that the mostrecent data is returned. For more information,see Consistency (p. 7)

Type: Boolean

Default: false

ConsistentRead

NoString that tells Amazon SimpleDB where tostart the next list of ItemNames.

Type: String

Default: None

NextToken

API Version 2009-04-1586

Amazon SimpleDB Developer GuideSelect

Page 91: sdb-dg

Response Elements

DescriptionName

Item names that match the select expression.<Item><Name>... </Name></Item>

The name and value of the attribute.<Attribute> <Name>...</Name><Value>...</Value> </Attribute>

An opaque token indicating that more thanMaxNumberOfItems matched, the response sizeexceeded 1 megabyte, or the execution timeexceeded 5 seconds.

NextToken

Special Errors

DescriptionError

Value (" + value + ") for parameter MaxNumberOfItems isinvalid. MaxNumberOfItems must be between 1 and 2500.

InvalidParameterValue

Value (" + value + ") for parameter AttributeName is invalid.Value exceeds maximum length of 1024.

InvalidParameterValue

Value (" + value + ") for parameter ConsistentRead is invalid.The ConsistentRead flag should be either true or false.

InvalidParameterValue

The specified next token is not valid.InvalidNextToken

Too many predicates in the query expression.InvalidNumberPredicates

Too many value tests per predicate in the query expression.InvalidNumberValueTests

The specified query expression syntax is not valid.InvalidQueryExpression

The sort attribute must be present in at least one of thepredicates, and the predicate cannot contain the is nulloperator.

InvalidSortExpression

The request must contain the parameter DomainName.MissingParameter

The specified domain does not exist.NoSuchDomain

A timeout occurred when attempting to query domain <domainname> with query expression <query expression>. BoxUsage[<box usage value>]"

RequestTimeout

Too many attributes requested.TooManyRequestedAttributes

Examples

Sample Request

https://sdb.amazonaws.com/?Action=Select

API Version 2009-04-1587

Amazon SimpleDB Developer GuideSelect

Page 92: sdb-dg

&AWSAccessKeyId=[valid access key id]&NextToken=[valid next token]&SelectExpression=select%20Color%20from%20MyDomain%20where%20Col or%20like%20%27Blue%25%27&ConsistentRead=true&SignatureVersion=2&SignatureMethod=HmacSHA256&Timestamp=2010-01-25T15%3A03%3A09-07%3A00&Version=2009-04-15&Signature=[valid signature]

Sample Response

<SelectResponse> <SelectResult> <Item> <Name>Item_03</Name> <Attribute><Name>Category</Name><Value>Clothes</Value></Attribute> <Attribute><Name>Subcategory</Name><Value>Pants</Value></Attribute> <Attribute><Name>Name</Name><Value>Sweatpants</Value></Attribute> <Attribute><Name>Color</Name><Value>Blue</Value></Attribute> <Attribute><Name>Color</Name><Value>Yellow</Value></Attribute> <Attribute><Name>Color</Name><Value>Pink</Value></Attribute> <Attribute><Name>Size</Name><Value>Large</Value></Attribute> </Item> <Item> <Name>Item_06</Name> <Attribute><Name>Category</Name><Value>Motorcycle Parts</Value></Attribute>

<Attribute><Name>Subcategory</Name><Value>Bodywork</Value></Attribute> <Attribute><Name>Name</Name><Value>Fender Eliminator</Value></Attribute>

<Attribute><Name>Color</Name><Value>Blue</Value></Attribute> <Attribute><Name>Make</Name><Value>Yamaha</Value></Attribute> <Attribute><Name>Model</Name><Value>R1</Value></Attribute> </Item> </SelectResult> <ResponseMetadata> <RequestId>b1e8f1f7-42e9-494c-ad09-2674e557526d</RequestId> <BoxUsage>0.0000219907</BoxUsage> </ResponseMetadata></SelectResponse>

API Version 2009-04-1588

Amazon SimpleDB Developer GuideSelect

Page 93: sdb-dg

API Error Codes

There are two types of error codes, client and server.

Client error codes are generally caused by the client and might be an authentication failure or an invaliddomain. In the SOAP API, these error codes are prefixed with Client. For example: Client.AuthFailure.In the REST API, these errors are accompanied by a 4xx HTTP response code.

Server error codes are generally caused by a server-side issue and should be reported. In the SOAPAPI, these error codes are prefixed with Server. For example: Server.Unavailable. In the REST API, theseerrors are accompanied by a 5xx HTTP response code.

The following table lists all Amazon SimpleDB error codes.

SOAPFaultCodePrefix

HTTP StatusCode

DescriptionError

Client403 ForbiddenAccess to the resource " +resourceName + " is denied.

AccessFailure

Client404 Not FoundAttribute ("+ name + ") does notexist

AttributeDoesNotExist

Client403 ForbiddenAWS was not able to validate theprovided access credentials.

AuthFailure

Client403 ForbiddenAWS was not able to authenticatethe request: access credentials aremissing.

AuthMissingFailure

Client409 ConflictConditional check failed. Attribute ("+ name + ") value exists.

ConditionalCheckFailed

Client409 ConflictConditional check failed. Attribute("+ name +") value is ("+ value +")but was expected ("+ expValue +")

ConditionalCheckFailed

Client400 BadRequest

Expected.Exists=false andExpected.Value cannot be specifiedtogether

ExistsAndExpectedValue

API Version 2009-04-1589

Amazon SimpleDB Developer Guide

Page 94: sdb-dg

SOAPFaultCodePrefix

HTTP StatusCode

DescriptionError

Client400 BadRequest

The replace flag must be specifiedper attribute, not per item.

FeatureDeprecated

Client400 BadRequest

If Expected.Exists=true orunspecified, then Expected.Valuehas to be specified

IncompleteExpectedExpression

Server500 InternalServer Error

Request could not be executed dueto an internal service error.

InternalError

Client400 BadRequest

The action " + actionName + " is notvalid for this web service.

InvalidAction

Client400 BadRequest

The HTTP authorization header isbad, use " + correctFormat".

InvalidHTTPAuthHeader

Client400 BadRequest

The HTTP request is invalid.Reason: " + reason".

InvalidHttpRequest

Client400 BadRequest

Illegal literal in the filter expression.InvalidLiteral

Client400 BadRequest

The specified next token is not valid.InvalidNextToken

Client400 BadRequest

Too many predicates in the queryexpression.

InvalidNumberPredicates

Client400 BadRequest

Too many value tests per predicatein the query expression.

InvalidNumberValueTests

Client400 BadRequest

The parameter " + param1 + "cannot be used with the parameter" + param2".

InvalidParameterCombination

Client400 BadRequest

Value (" + value + ") for parameterMaxNumberOfDomains is invalid.MaxNumberOfDomains must bebetween 1 and 100.

InvalidParameterValue

Client400 BadRequest

Value (" + value + ") for parameterMaxNumberOfItems is invalid.MaxNumberOfItems must bebetween 1 and 2500.

InvalidParameterValue

Client400 BadRequest

Value (" + value + ") for parameterMaxNumberOfDomains is invalid.MaxNumberOfDomains must bebetween 1 and 100.

InvalidParameterValue

Client400 BadRequest

Value (" + value + ") for parameter" + paramName + " is invalid. " +reason".

InvalidParameterValue

API Version 2009-04-1590

Amazon SimpleDB Developer Guide

Page 95: sdb-dg

SOAPFaultCodePrefix

HTTP StatusCode

DescriptionError

Client400 BadRequest

Value (" + value + ") for parameterName is invalid. Value exceedsmaximum length of 1024.

InvalidParameterValue

Client400 BadRequest

Value (" + value + ") for parameterValue is invalid. Value exceedsmaximum length of 1024.

InvalidParameterValue

Client400 BadRequest

Value (" + value + ") for parameterDomainName is invalid.

InvalidParameterValue

Client400 BadRequest

Value (" + value + ") for parameterReplace is invalid.The Replace flagshould be either true or false.

InvalidParameterValue

Client400 BadRequest

Value (" + value + ") for parameterExpected.Exists is invalid.Expected.Exists should be eithertrue or false.

InvalidParameterValue

Client400 BadRequest

Value (" + value + ") for parameterName is invalid.The empty string isan illegal attribute name

InvalidParameterValue

Client400 BadRequest

Value (" + value + ") for parameterValue is invalid. Value exceedsmaximum length of 1024

InvalidParameterValue

Client400 BadRequest

Value (" + value + ") for parameterConsistentRead is invalid. TheConsistentRead flag should beeither true or false.

InvalidParameterValue

Client400 BadRequest

The specified query expressionsyntax is not valid.

InvalidQueryExpression

Client400 BadRequest

The following response groups areinvalid: " + invalidRGStr.

InvalidResponseGroups

Client400 BadRequest

The Web Service " + serviceName+ " does not exist.

InvalidService

Client400 BadRequest

Invalid SOAP request. " + reason".InvalidSOAPRequest

Client400 BadRequest

The sort attribute must be presentin at least one of the predicates, andthe predicate cannot contain the isnull operator.

InvalidSortExpression

Client400 BadRequest

The URI " + requestURI + " is notvalid.

InvalidURI

Client400 BadRequest

WS-Addressing parameter " +paramName + " has a wrong value:" + paramValue".

InvalidWSAddressingProperty

API Version 2009-04-1591

Amazon SimpleDB Developer Guide

Page 96: sdb-dg

SOAPFaultCodePrefix

HTTP StatusCode

DescriptionError

Client400 BadRequest

Parameter (" + parameterName +")is only supported in WSDL version2009-04-15 or beyond. Pleaseupgrade to new version

InvalidWSDLVersion

Client403 ForbiddenInvalid SOAP Signature. " + reason".MalformedSOAPSignature

Client400 BadRequest

No action was supplied with thisrequest.

MissingAction

Client400 BadRequest

The request must contain thespecified missing parameter.

MissingParameter

Client400 BadRequest

The request must contain theparameter " + paramName".

MissingParameter

Client400 BadRequest

The request must contain theparameter ItemName.

MissingParameter

Client400 BadRequest

The request must contain theparameter DomainName.

MissingParameter

Client400 BadRequest

Attribute.Value missing forAttribute.Name='name'.

MissingParameter

Client400 BadRequest

Attribute.Name missing forAttribute.Value='value'.

MissingParameter

Client400 BadRequest

No attributes for item ='" +itemName + "'.

MissingParameter

Client400 BadRequest

The request must contain theparameter Name

MissingParameter

Client400 BadRequest

WS-Addressing is missing arequired parameter (" + paramName+ ")".

MissingWSAddressingProperty

Client400 BadRequest

Only one Exists condition can bespecified

MultipleExistsConditions

Client400 BadRequest

Only one Expected.Name can bespecified

MultipleExpectedNames

Client400 BadRequest

Only one Expected.Value can bespecified

MultipleExpectedValues

Client409 ConflictAttribute (" + name + ") ismulti-valued. Conditional check canonly be performed on asingle-valued attribute

MultiValuedAttribute

Client400 BadRequest

The specified domain does not exist.NoSuchDomain

API Version 2009-04-1592

Amazon SimpleDB Developer Guide

Page 97: sdb-dg

SOAPFaultCodePrefix

HTTP StatusCode

DescriptionError

Client400 BadRequest

The requested version (" + version+ ") of service " + service + " doesnot exist.

NoSuchVersion

Client401Unauthorized

Feature " + feature + " is not yetavailable".

NotYetImplemented

Client409 ConflictThe domain limit was exceeded.NumberDomainsExceeded

Client409 ConflictToo many attributes in this domain.NumberDomainAttributes

Exceeded

Client409 ConflictToo many bytes in this domain.NumberDomainBytesExceeded

Client409 ConflictToo many attributes in this item.NumberItemAttributes

Exceeded

Client409 ConflictToo many attributes in a single call.NumberSubmitted

AttributesExceeded

Client409 ConflictToo many attributes for itemitemName in a single call. Up to 256attributes per call allowed.

NumberSubmittedAttributesExceeded

Client409 ConflictToo many items in a single call. Upto 25 items per call allowed.

NumberSubmittedItemsExceeded

Client400 BadRequest

Request has expired. " + paramType+ " date is " + date".

RequestExpired

Client408 RequestTimeout

A timeout occurred when attemptingto query domain <domain name>with query expression <queryexpression>. BoxUsage [<boxusage value>]".

RequestTimeout

Server503 ServiceUnavailable

Service Amazon SimpleDB iscurrently unavailable. Please tryagain later.

ServiceUnavailable

Client400 BadRequest

Too many attributes requested.TooManyRequestedAttributes

Client400 BadRequest

The requested HTTP verb is notsupported: " + verb".

UnsupportedHttpVerb

Client400 BadRequest

The specified next token is no longersupported. Please resubmit yourquery.

UnsupportedNextToken

Client400 BadRequest

The URI exceeded the maximumlimit of "+ maxLength".

URITooLong

API Version 2009-04-1593

Amazon SimpleDB Developer Guide

Page 98: sdb-dg

Amazon SimpleDB Glossary

account AWS account associated with a particular developer.

attribute Similar to columns on a spreadsheet, attributes represent categories of data thatcan be assigned to items.

consistent read A consistent read (using Select or GetAttributes with ConsistentRead=true) returnsa result that reflects all writes that received a successful response prior to theread.

domain All Amazon SimpleDB information is stored in domains. Domains are similar totables that contain similar data.You can execute queries against a domain, butcannot execute joins between domains.

The name of the domain must be unique within the customer account.

eventually consistent read An eventually consistent read (using Select or GetAttributes) might not reflect theresults of a recently completed write (using PutAttributes, BatchPutAttributes,DeleteAttributes). Consistency is usually reached within a second; repeating aread after a short time should return the updated data.

exponential backoff A strategy for reducing the load on the system and increasing the likelihood ofrepeated requests succeeding by incrementally decreasing the rate at whichretries are executed. For example, client applications might wait up to 400milliseconds before attempting the first retry, up to 1600 milliseconds before thesecond, up to 6400 milliseconds (6.4 seconds) before the third, and so on.

items Similar to rows on a spreadsheet, items represent individual objects that containone or more value-attribute pairs

item name An identifier for an item. The identifier must be unique within the domain.

machine utilization Charges based on the amount of machine capacity used to complete the particularrequest (SELECT, GET, PUT, etc.), normalized to the hourly capacity of a circa2007 1.7 GHz Xeon processor. Machine Utilization is measured in Machine Hourincrements.

multi-valued attribute An attribute with more than one value.

network partition A rare error condition where some Amazon SimpleDB computers cannot contacteach other, but all other components are operating correctly. Normally this isrepaired within seconds or minutes.

single-valued attribute An attribute with one value.

API Version 2009-04-1594

Amazon SimpleDB Developer Guide

Page 99: sdb-dg

value Similar to cells on a spreadsheet, values represent instances of attributes for anitem. An attribute might have multiple values.

API Version 2009-04-1595

Amazon SimpleDB Developer Guide

Page 100: sdb-dg

Document Conventions

This section lists the common typographical and symbol use conventions for AWS technical publications.

Typographical ConventionsThis section describes common typographical use conventions.

Description/ExampleConvention

A call-out is a number in the body text to give you a visual reference. Thereference point is for further discussion elsewhere.

You can use this resource regularly.

Call-outs

Inline code samples (including XML) and commands are identified with aspecial font.

You can use the command java -version.

Code in text

Blocks of sample code are set apart from the body and marked accordingly.

# ls -l /var/www/html/index.html-rw-rw-r-- 1 root root 1872 Jun 21 09:33 /var/www/html/index.html# dateWed Jun 21 09:33:42 EDT 2006

Code blocks

Unusual or important words and phrases are marked with a special font.

You must sign up for an account before you can use the service.

Emphasis

References to a section in the same document are marked.

See Document Conventions (p. 96).

Internal cross references

API Version 2009-04-1596

Amazon SimpleDB Developer GuideTypographical Conventions

Page 101: sdb-dg

Description/ExampleConvention

A special font is used for expressions that are important to identify, but arenot code.

If the value is null, the returned response will be false.

Logical values,constants, and regularexpressions, abstracta

Named AWS products and features are identified on first use.

Create an Amazon Machine Image (AMI).

Product and featurenames

In-text references to operations.

Use the GetHITResponse operation.

Operations

In-text references to parameters.

The operation accepts the parameter AccountID.

Parameters

In-text references to responses.

A container for one CollectionParent and one or moreCollectionItems.

Response elements

References to other AWS publications. If the reference is hyperlinked, it isalso underscored.

For detailed conceptual information, see the Amazon Mechanical TurkDeveloper Guide.

Technical publicationreferences

A special font marks text that the user types.

At the password prompt, type MyPassword.

User entered values

Denotes named items on the UI for easy identification.

On the File menu, click Properties.

User interface controlsand labels

When you see this style, you must change the value of the content when youcopy the text of a sample to a command line.

% ec2-register <your-s3-bucket>/image.manifest

See Symbol Conventions (p. 98).

Variables

API Version 2009-04-1597

Amazon SimpleDB Developer GuideTypographical Conventions

Page 102: sdb-dg

Symbol ConventionsThis section describes the common use of symbols.

Description/ExampleSymbolConvention

Within a code description, bar separators denote options fromwhich one must be chosen.

% data = hdfread (start | stride | edge)

(Parentheses | and| vertical | bars)

Mutuallyexclusiveparameters

Within a code description, square brackets denote completelyoptional commands or parameters.

% sed [-n, -quiet]

Use square brackets in XML examples to differentiate them fromtags.

<CustomerId>[ID]</CustomerId>

[square brackets]Optionalparameters

XML variabletext

Within a code sample, arrow brackets denote a variable thatmust be replaced with a valid value.

% ec2-register <your-s3-bucket>/image.manifest

<arrow brackets>Variables

API Version 2009-04-1598

Amazon SimpleDB Developer GuideSymbol Conventions

Page 103: sdb-dg

Document History

This What's New is associated with the 2009-04-15 release of Amazon SimpleDB. This guide was lastupdated on November 15, 2010.

The following table describes the important changes since the last release of the Amazon SimpleDBDeveloper Guide.

Release DateDescriptionChange

28 April 2010Amazon SimpleDB now supports the Asia Pacific (Singapore)Region. For more information, see Region Endpoints (p. 12).

Asia Pacific Region

24 February2010

GetAttributes and Select can now perform consistent reads,which always return the most recently written data. For moreinformation, see Consistency (p. 7).

Consistent read

24 February2010

Amazon SimpleDB now supports conditional put, which enablesyou to perform a put if a specific condition is met. For moreinformation, see Conditionally Putting and Deleting Data (p. 34)and PutAttributes (p. 80).

Conditional put

24 February2010

Amazon SimpleDB now supports conditional delete, whichenables you to delete data if a specific condition is met. Formore information, see Conditionally Putting and DeletingData (p. 34) and DeleteAttributes (p. 66).

Conditional delete

23 September2009

Amazon SimpleDB is now available in Europe. For moreinformation, see Region Endpoints (p. 12).

New Data Center inEurope

18 May 2009You can now search whether attribute values contain aspecified string using like. For more information, seeComparison Operators (p. 39).

contains

18 May 2009Select can now use where and order by with itemNames().For more information, see Comparison Operators (p. 39).

Sort and ExecuteQueries byitemName()

API Version 2009-04-1599

Amazon SimpleDB Developer Guide

Page 104: sdb-dg

Release DateDescriptionChange

18 May 2009Sort can now be applied to expressions that contain the isnull predicate operator, as long as is null is not appliedto the attribute that being sorted on. For more information aboutSelect, see Sort (p. 45).

IS NULL Sort

18 May 2009Select can now return up to 2500 items. For more informationabout Select, see Limits (p. 9).

Increased Item Limit

18 May 2009Amazon SimpleDB replaced Query andQueryWithAttributes with Select, a query function thatis similar to the standard SQL SELECT statement. For moreinformation, see Using Select to Create Amazon SimpleDBQueries (p. 38).

Query andQueryWithAttributesDeprecated

18 May 2009All requests to Amazon SimpleDB must be made over SSL(https://). For more information, see RequestAuthentication (p. 16).

SSL Required

API Version 2009-04-15100

Amazon SimpleDB Developer Guide

Page 105: sdb-dg

IndexAAccess Key ID, 7, 29, 64, 78access keys, 29, 64, 78

operations, 7access management, 10AccessFailure, 89Action, 57API

BatchPutAttributes, 60common errors, 59conventions, 53CreateDomain, 64data types, 54DeleteAttributes, 66DeleteDomain, 71DomainMetadata, 73error codes, 89errors, 55escaping, 59GetAttributes, 75ListDomains, 78parameter formats, 59parameters, 57PutAttributes, 80quotes, 59reference, 12, 53response elements, 59Select, 86summary, 7versioning, 54WSDL, 54

Attribute.X.Name, 57, 61, 66, 80Attribute.X.Value, 57, 61, 66, 80AttributeName, 75attributes

delete, 66get, 75put, 60, 80

AttributeValue, 75authentication

process, 19REST, 23signature version 2, 23SOAP, 24summary, 19WS-Security, 25

not using, 29AuthFailure, 89AuthMissingFailure , 89AWSAccessKeyId, 57

BBatchPutAttributes, 60

bill, 4BoxUsage, 59

Ccalls, 53charges, 3concepts, 5

consistent read, 7data model, 5eventually consistent, 7limits, 9operations, 7

conventions, 53cost, 3CreateDomain, 64

Ddata model

concepts, 5data set partitioning, 10data transfer

charges, 3report, 4

data types, 54DeleteAttributes, 66DeleteDomain, 71DomainMetadata, 73DomainName, 57, 64, 71, 86domains, 5

creating, 64deleting, 71listing, 78partitioning, 10

Eendpoints, 12error codes, 89errors

AccessFailure , 89AuthMissingFailure , 89client, 55, 89common responses, 59FeatureDeprecated, 89InternalError, 89InvalidAction, 89InvalidHTTPAuthHeader, 89InvalidHttpRequest, 89InvalidNextToken, 78, 87, 89InvalidNumberPredicates, 87, 89InvalidNumberValueTests, 87, 89InvalidParameterCombination, 89InvalidParameterValue, 62, 64, 67, 75, 78, 82, 87,89InvalidQueryExpression, 87InvalidResponseGroups, 89InvalidService, 89

API Version 2009-04-15101

Amazon SimpleDB Developer Guide

Page 106: sdb-dg

InvalidSOAPRequest, 89InvalidURI, 89InvalidWSAddressingProperty, 89MalformedSOAPSignature, 89MissingAction, 89MissingParameter, 62, 64, 67, 71, 73, 75, 78, 82, 87MissingWSAddressingProperty, 89NoSuchDomain, 62, 67, 73, 75, 82, 87, 89NoSuchVersion, 89NotYetImplemented, 89NumberDomainAttributesExceeded, 62, 82, 89NumberDomainBytesExceeded, 62, 82, 89NumberDomainsExceeded, 64, 89NumberItemAttributesExceeded, 62, 82, 89RequestExpired, 89RequestTimeout, 87, 89retries, 55server, 55, 55, 89ServiceOverload, 89ServiceUnavailable, 89UnsupportedHttpVerb, 89URITooLong, 89

escaping, 59Europe, 12eventually consistent, 66

concepts, 7exponential backoff, 55

FFeatureDeprecated, 89features, 2functions, 53

GGetAttributes, 75

Iidentity management, 10InternalError , 89InvalidAction, 89InvalidHTTPAuthHeader, 89InvalidHttpRequest, 89InvalidNextToken, 78, 87, 89InvalidNumberPredicates, 87, 89InvalidNumberValueTests, 87, 89InvalidParameterCombination, 89InvalidParameterValue, 62, 64, 67, 75, 78, 82, 87, 89InvalidQueryExpression, 87InvalidResponseGroups, 89InvalidService, 89InvalidSOAPRequest, 89InvalidSortExpression, 87, 89InvalidURI, 89InvalidWSAddressingProperty, 89invoice, 4Item.Y.Attribute.X.Name, 61

Item.Y.Attribute.X.Replace, 61Item.Y.Attribute.X.Value, 61Item.Y.ItemName, 61ItemName, 61, 66, 75, 80items, querying, 86

Llimits

concepts, 9ListDomains, 78locations

data, 12

Mmachine utilization, 59

charges, 3report, 4

MalformedSOAPSignature, 89MaxNumberOfDomains, 57, 78MaxNumberOfItems, 57, 86metadata

get, 73MissingAction, 89MissingParameter, 62, 64, 67, 71, 73, 75, 82, 87MissingWSAddressingProperty, 89model, data, 5multi-valued attribute, 66

Nnetwork partition, 7NextToken, 57, 78, 86NoSuchDomain, 62, 67, 73, 75, 82, 87, 89NoSuchVersion, 89NotYetImplemented, 89NumberDomainAttributesExceeded, 62, 82, 89NumberDomainBytesExceeded, 62, 82, 89NumberDomainsExceeded, 64, 89NumberItemAttributesExceeded, 62, 82, 89

Ooperations, 7, 53

Pparameters, 57

Attribute.X.Name, 61, 66, 80Attribute.X.Value, 61, 66, 80AttributeName, 75AttributeValue, 75DomainName, 64, 71, 86formats, 59ItemName, 61, 66, 75, 80MaxNumberOfDomains, 78MaxNumberOfItems, 86NextToken, 78, 86Replace, 61, 80

API Version 2009-04-15102

Amazon SimpleDB Developer Guide

Page 107: sdb-dg

partitioningdomains, 10

pricing, 3programmer reference, 12PutAttributes, 80

QQueryExpression, 57quotes, 59

Rreceipt, 4Replace, 57, 61, 80RequestExpired, 89RequestId, 59requests

authentication, 16BatchPutAttributes, 60CreateDomain, 64DeleteAttributes, 66DeleteDomain, 71DomainMetadata, 73GetAttributes, 75ListDomains, 78PutAttributes, 80REST, 13

about, 13parameters, 13sample, 14

Select, 86SOAP, 14

about, 14parameters, 15sample, 15

RequestTimeout, 87, 89responses, 59REST

authentication, 23requests, 13

about, 13parameters, 13sample, 14

restrictions, 9retries, 55

Sscale out model, 10Secret Access Key, 7, 29, 64, 78Select, 86server errors, 55ServiceOverload, 89ServiceUnavailable, 89Signature, 57signature version 2, 23SignatureMethod, 57SignatureVersion, 57

SOAPauthentication, 24requests, 14

about, 14parameters, 15sample, 15

spreadsheet, 5storage

charges, 3report, 4

structured data, 5

Ttime stamps, 27Timestamp, 57types, 54

UUnited States, 12UnsupportedHttpVerb, 89URITooLong, 89usage report, 4

VVersion, 57versioning, 54

WWS-Security

not using, 29overview, 24using, 25

WSDL, 54, 54WSDL versioning, 54

XX.509 certificate, 24

API Version 2009-04-15103

Amazon SimpleDB Developer Guide