

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用價目表大量 API 取得 AWS 價目表檔案
<a name="using-the-aws-price-list-bulk-api"></a>


|  | 
| --- |
| 若要提供有關 的意見回饋 AWS 價格表，請完成此[簡短問卷](https://amazonmr.au1.qualtrics.com/jfe/form/SV_cO0deTMyKyFeezA)。您的回覆將採匿名處理。**注意：**這份問卷僅提供英文版本。 | 

如果要執行下列任務，建議您使用 Price List Bulk API：
+ 使用 AWS 服務的大量產品和定價資訊。
+ 以高輸送量使用 AWS 服務的產品和定價資訊，例如大量處理。

此外，如果 Price List Query API 無法為您的使用案例提供足夠的輸送量和配額，也請使用 Price List Bulk API。<a name="using-the-aws-price-list-bulk-api-fetching-price-list-files"></a>

我們建議您使用 AWS Price List Bulk API 以程式設計方式尋找和下載價目表檔案。若要取得價目表檔案的 URL，請參閱下列步驟。

如果您不想使用 AWS 價目表大量 API，您可以手動下載價目表檔案。如需詳細資訊，請參閱[手動取得價目表檔案](using-the-aws-price-list-bulk-api-fetching-price-list-files-manually.md)。

### 步驟 1：可用的調查結果 AWS 服務
<a name="price-bulk-api-step-1-find-available-services"></a>

使用 `DescribeServices` API 操作尋找 Price List Bulk API 支援的所有可用 AWS 服務 。此 API 操作會傳回服務清單中的 `ServiceCode` 值。您稍後可以使用此值來尋找相關的價目表檔案。

**Example 範例：尋找可用服務**  
以下命令示範如何尋找可用 AWS 服務。  

```
aws pricing describe-services --region us-east-1
```
 AWS 區域 是 Price List Bulk API 的 API 端點。端點與產品或服務屬性無關。  
**回應**  

```
{
    "FormatVersion": "aws_v1", 
    "NextToken": "abcdefg123", 
    "Services": [ 
        {
            "AttributeNames": [ 
                "volumeType", 
                "maxIopsvolume", 
                "instanceCapacity10xlarge", 
                "locationType", 
                "operation" 
            ], 
            "ServiceCode": "AmazonEC2" 
        },
        {
            "AttributeNames": [ 
                "productFamily", 
                "volumeType", 
                "engineCode", 
                "memory" 
            ], 
            "ServiceCode": "AmazonRDS" 
        },
        {...} 
    ] 
}
```

如需此 API 操作的詳細資訊，請參閱*AWS 帳單與成本管理 《 API 參考*》中的 [https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_pricing_DescribeServices.html](https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_pricing_DescribeServices.html)和語言特定 SDK [AWS SDKs](https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_pricing_DescribeServices.html#API_pricing_DescribeServices_SeeAlso) 

**注意**  
雖然 `DescribeServices` API 目前不會傳回 `serviceCodes` Savings Plans，但您需要下列項目`serviceCodes`，才能在後續 API 呼叫中使用 Savings Plans：  


| ServiceCode | SavingsPlanCode | 
| --- | --- | 
| ComputeSavingsPlans | AWSComputeSavingsPlan | 
| MachineLearningSavingsPlans | AWSMachineLearningSavingsPlans | 
| DatabaseSavingsPlans | AWSDatabaseSavingsPlans | 
使用 `ListPriceLists`和 `GetPriceListFileUrl` API 操作時，請使用 `ServiceCode`值。`SavingsPlanCode` 只有在您手動下載價目表檔案而非使用 APIs時才需要 。

### 步驟 2：尋找可用 的價目表檔案 AWS 服務
<a name="price-list-bulk-api-step-2-find-available-price-list-files"></a>

使用 `ListPriceLists` API 操作取得您有權檢視的價目表參考。若要篩選結果，您可以指定 `ServiceCode`、`CurrencyCode` 和 `EffectiveDate` 參數。

 AWS 區域 是 Price List Bulk API 的 API 端點。端點與產品或服務屬性無關。

#### 價目表檔案尋找範例
<a name="price-list-bulk-api-examples-find-price-list-files"></a>

**Example 範例：尋找所有 的價目表檔案 AWS 區域**  
如果您未指定 `--region-code` 參數，API 操作會傳回所有可用 AWS 區域的價目表檔案參考資料。  

```
aws pricing list-price-lists --service-code AmazonRDS --currency-code USD --effective-date "2023-04-03 00:00"
```
**回應**  

```
{
   "NextToken": "abcd1234",
   "PriceLists": [ 
      { 
         "CurrencyCode": "USD",
         "FileFormats": [ "json", "csv" ],
         "PriceListArn": "arn:aws:pricing:::price-list/aws/AmazonRDS/USD/20230328234721/us-east-1",
         "RegionCode": "us-east-1"
      },
      { 
         "CurrencyCode": "USD",
         "FileFormats": [ "json", "csv" ],
         "PriceListArn": "arn:aws:pricing:::price-list/aws/AmazonRDS/USD/20230328234721/us-west-2",
         "RegionCode": "us-west-2"
      },
      ...
   ]
}
```

**Example 範例：搜尋特定區域的價目表檔案**  
如果您指定 `RegionCode` 參數，API 操作會傳回該區域特定的價目表檔案參考資料。若要尋找歷史價目表檔案，請使用 `EffectiveDate` 參數。舉例來說，您可以指定過去的日期，尋找特定的價目表檔案。  
得到回應後，您接著可以在 [https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_pricing_GetPriceListFileUrl.html](https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_pricing_GetPriceListFileUrl.html) API 操作中使用 `PriceListArn` 值，以取得偏好的價目表檔案。  

```
aws pricing list-price-lists --service-code AmazonRDS --currency-code USD --region-code us-west-2 --effective-date "2023-04-03 00:00"
```
**回應**  

```
{
   "PriceLists": [ 
      { 
         "CurrencyCode": "USD",
         "FileFormats": [ "json", "csv" ],
         "PriceListArn": "arn:aws:pricing:::price-list/aws/AmazonRDS/USD/20230328234721/us-west-2",
         "RegionCode": "us-west-2"
      }
   ]
}
```

如需此 API 操作的詳細資訊，請參閱*AWS 帳單與成本管理 《 API 參考*》中的 [https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_pricing_ListPriceLists.html](https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_pricing_ListPriceLists.html)和語言特定 SDK。 [AWS SDKs](https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_pricing_ListPriceLists.html#API_pricing_ListPriceLists_SeeAlso) 

### 步驟 3：取得特定價目表檔案
<a name="price-list-bulk-api-step-3-getting-specific-price-list"></a>

使用 `GetPriceListFileUrl` API 操作取得價目表檔案的 URL。此 URL 是以您在[步驟 1](#price-bulk-api-step-1-find-available-services) 和[步驟 2](#price-list-bulk-api-step-2-find-available-price-list-files) 中從 `ListPriceLists` 的回應擷取的 `PriceListArn` 和 `FileFormats` 值為依據 

**Example 範例：取得特定價目表檔案。**  
下列命令會取得 Amazon RDS 特定價目表檔案的 URL。  

```
aws pricing get-price-list-file-url --price-list-arn arn:aws:pricing:::price-list/aws/AmazonRDS/USD/20230328234721/us-east-1 --file-format json --region us-east-1
```
**回應**  

```
{
    "Url": "https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonRDS/20230328234721/us-east-1/index.json"
}
```
取得回應後，您可以使用 URL 下載價目表檔案。

如需此 API 操作的詳細資訊，請參閱下列主題：
+  [https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_pricing_GetPriceListFileUrl.html](https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_pricing_GetPriceListFileUrl.html) *AWS 帳單與成本管理 API 參考*中的 [和語言特定 AWS SDKs](https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_pricing_GetPriceListFileUrl.html#API_pricing_GetPriceListFileUrl_SeeAlso) 
+ [讀取價目表檔案](bulk-api-reading-price-list-files.md)