

# Making API requests
<a name="making-api-requests"></a>

Query requests for the Amazon Resource Groups Tagging API are HTTP or HTTPS requests that use an HTTP verb such as `GET` or `POST`.

## Amazon Resource Groups Tagging API endpoints
<a name="cw-endpoints"></a>

An *endpoint* is a URL that serves as an entry point for a web service. You can select an Amazon Web Services Region endpoint when you make your requests to reduce latency. For information about the endpoints used with Resource Groups Tagging API, see the [Tagging section of Amazon Resource Groups and Tagging endpoints and quotas](https://docs.amazonaws.cn/general/latest/gr/arg.html#argtapi) in the *Amazon Web Services General Reference*.

## Query parameters
<a name="query-parameters"></a>

Each query request must include some common parameters to handle authentication and selection of an action. For more information, see [Common Parameters](CommonParameters.md).

Some API operations take lists of parameters. These lists are specified using the following notation: 

```
param.member.n
```

 Values of `n` are integers starting from 1. All lists of parameters must follow this notation, including lists that contain only one parameter. A query parameter list looks like the following example.

```
1. &attribute.member.1=this
2. &attribute.member.2=that
```

## Request identifiers
<a name="RequestId-common-data-type"></a>

In every response from an Amazon Query API, there is a `ResponseMetadata` element, which contains a `RequestId` element. This string is a unique identifier that Amazon assigns to provide tracking information. Although `RequestId` is included as part of every response, it isn't listed on the individual API documentation pages to improve readability and to reduce redundancy.

## Query API authentication
<a name="query-authentication"></a>

You can send query requests over either HTTP or HTTPS. Regardless of which protocol you use, you must include a signature in every query request. For more information about creating and including a signature, see [Signing Amazon API Requests](https://docs.amazonaws.cn/general/latest/gr/signing_aws_api_requests.html) in the *Amazon Web Services General Reference*.

## Available libraries
<a name="using-libraries"></a>

Amazon provides libraries, sample code, tutorials, and other resources for software developers who prefer to build applications using language-specific APIs instead of the command-line tools and Query API. These libraries provide basic functions (not included in the APIs), such as request authentication, request retries, and error handling so that it's easier to get started. Libraries and resources are available for the following languages and platforms:
+  [Amazon SDK for Go](https://docs.amazonaws.cn/sdk-for-go/v1/developer-guide) 
+  [Amazon Amplify for mobile apps for Android and iOS](https://docs.amazonaws.cn/amplify) 
+  [Amazon SDK for Java 2.x](https://docs.amazonaws.cn/sdk-for-java/latest/developer-guide) 
+  [Amazon SDK for Java 1.x](https://docs.amazonaws.cn/sdk-for-java/v1/developer-guide) 
+  [Amazon SDK for JavaScript](https://docs.amazonaws.cn/sdk-for-javascript/v3/developer-guide) 
+  [Amazon SDK for JavaScript in Node.js](https://docs.amazonaws.cn/sdk-for-javascript/v2/developer-guide) 
+ [Amazon SDK for Kotlin](https://docs.amazonaws.cn/sdk-for-kotlin/latest/developer-guide)
+  [Amazon SDK for .NET](https://docs.amazonaws.cn/sdk-for-net/v3/developer-guide) 
+  [Amazon SDK for PHP](https://docs.amazonaws.cn/aws-sdk-php/v2/guide) 
+  [Amazon SDK for Python (Boto)](https://boto3.amazonaws.com/v1/documentation/api/latest/index.html) 
+  [Amazon SDK for Ruby](https://docs.amazonaws.cn/sdk-for-ruby/v3/developer-guide) 
+ [Amazon SDK for Rust](https://awslabs.github.io/aws-sdk-rust/)
+ [Amazon SDK for Swift](https://aws.amazon.com/sdk-for-swift/)

For more information about libraries and sample code in all languages, see [Sample Code & Libraries](https://docs.amazonaws.cn/code-library).

## Making API requests using the `POST` method
<a name="CloudWatch-API-requests-using-post-method"></a>

If you don't use one of the Amazon SDKs, you can make Resource Groups Tagging API requests over HTTP using the `POST` request method. The `POST` method requires that you specify the operation in the header of the request and provide the data for the operation in JSON format in the body of the request.


| Header name | Header value | 
| --- | --- | 
| host | The Amazon Resource Groups Tagging API endpoint. For example: `tagging.us-east-1.amazonaws.com.cn`  | 
| x-amz-date | You must provide the timestamp in either the HTTP Date header or the Amazon *x-amz-date* header. Some HTTP client libraries don't let you set the Date header. When an *x-amz-date* header is present, the system ignores any Date header during the request authentication.<br />The *x-amz-date* header must be specified in ISO 8601 basic format. For example: `20130315T092054Z`  | 
| Authorization | The set of authorization parameters that Amazon uses to ensure the validity and authenticity of the request. For more information about constructing this header, see [Signature Version 4 Signing Process](https://docs.amazonaws.cn/general/latest/gr/signature-version-4.html) in the *Amazon Web Services General Reference*. | 
| x-amz-target | Specifies the Resource Groups Tagging API namespace and version, and the operation that you want to perform. <br />`ResourceGroupsTaggingAPI_20170126.{{API_Name}}` For the Resource Groups Tagging API, always use the version **`20170126`**. <br />For example, to call the `GetTagValues` operation, use the following target value.<br />`ResourceGroupsTaggingAPI_20170126.GetTagValues` | 
| Content-Type | Specifies the input format. Use the following value.<br />`application/json` | 
| Accept | Specifies the response format. Use the following value.<br />`application/json` | 
| Content-Length | Size of the payload in bytes. | 
| Content-Encoding | Specifies the encoding format of the input and output. Use the following value.<br />`amz-1.0` | 

The following is an example header for an HTTP request to return metric data in JSON format. In this example, the `Authorization` line is word-wrapped here for easier reading. Don't word wrap it in your actual request.

```
POST / HTTP/1.1
host: tagging.us-east-1.amazonaws.com.cn
x-amz-target: ResourceGroupsTaggingAPI_20170126.GetTagValues
x-amz-date: 20180112T092034Z
Authorization: AWS4-HMAC-SHA256 Credential=REDACTED/20180411/us-east-1/monitoring/aws4_request, 
        SignedHeaders=content-encoding;content-length;content-type;host;x-amz-date;x-amz-target, 
        Signature=EXAMPLE5cb91f88f1EXAMPLEa02d3af93dEXAMPLE91e5d03588EXAMPLE88ff1d
Content-Type: application/json
Accept: application/json
Content-Encoding: amz-1.0
Content-Length: 18
Connection: keep-alive

{
    "Key": "Example_key"
}
```