Pricing / Client / get_products

get_products#

Pricing.Client.get_products(**kwargs)#

Returns a list of all products that match the filter criteria.

See also: AWS API Documentation

Request Syntax

response = client.get_products(
    ServiceCode='string',
    Filters=[
        {
            'Type': 'TERM_MATCH',
            'Field': 'string',
            'Value': 'string'
        },
    ],
    FormatVersion='string',
    NextToken='string',
    MaxResults=123
)
Parameters:
  • ServiceCode (string) –

    [REQUIRED]

    The code for the service whose products you want to retrieve.

  • Filters (list) –

    The list of filters that limit the returned products. only products that match all filters are returned.

    • (dict) –

      The constraints that you want all returned products to match.

      • Type (string) – [REQUIRED]

        The type of filter that you want to use.

        Valid values are: TERM_MATCH. TERM_MATCH returns only products that match both the given filter field and the given value.

      • Field (string) – [REQUIRED]

        The product metadata field that you want to filter on. You can filter by just the service code to see all products for a specific service, filter by just the attribute name to see a specific attribute for multiple services, or use both a service code and an attribute name to retrieve only products that match both fields.

        Valid values include: ServiceCode, and all attribute names

        For example, you can filter by the AmazonEC2 service code and the volumeType attribute name to get the prices for only Amazon EC2 volumes.

      • Value (string) – [REQUIRED]

        The service code or attribute value that you want to filter by. If you’re filtering by service code this is the actual service code, such as AmazonEC2. If you’re filtering by attribute name, this is the attribute value that you want the returned products to match, such as a Provisioned IOPS volume.

  • FormatVersion (string) –

    The format version that you want the response to be in.

    Valid values are: aws_v1

  • NextToken (string) – The pagination token that indicates the next set of results that you want to retrieve.

  • MaxResults (integer) – The maximum number of results to return in the response.

Return type:

dict

Returns:

Response Syntax

{
    'FormatVersion': 'string',
    'PriceList': [
        'string',
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) –

    • FormatVersion (string) –

      The format version of the response. For example, aws_v1.

    • PriceList (list) –

      The list of products that match your filters. The list contains both the product metadata and the price information.

      • (string) –

    • NextToken (string) –

      The pagination token that indicates the next set of results to retrieve.

Exceptions

  • Pricing.Client.exceptions.InvalidParameterException

  • Pricing.Client.exceptions.InvalidNextTokenException

  • Pricing.Client.exceptions.NotFoundException

  • Pricing.Client.exceptions.InternalErrorException

  • Pricing.Client.exceptions.ExpiredNextTokenException

Examples

This operation returns a list of products that match the given criteria.

response = client.get_products(
    Filters=[
        {
            'Field': 'ServiceCode',
            'Type': 'TERM_MATCH',
            'Value': 'AmazonEC2',
        },
        {
            'Field': 'volumeType',
            'Type': 'TERM_MATCH',
            'Value': 'Provisioned IOPS',
        },
    ],
    FormatVersion='aws_v1',
    MaxResults=1,
)

print(response)

Expected Output:

{
    'FormatVersion': 'aws_v1',
    'NextToken': '57r3EXAMPLEujbzWfHF7Ciw==:ywSmZsD3mtpQmQLQ5XfOsIMkYybSj+vAT+kGmwMFq+K9DGmIoJkz7lunVeamiOPgthdWSO2a7YKojCO+zY4dJmuNl2QvbNhXs+AJ2Ufn7xGmJncNI2TsEuAsVCUfTAvAQNcwwamtk6XuZ4YdNnooV62FjkV3ZAn40d9+wAxV7+FImvhUHi/+f8afgZdGh2zPUlH8jlV9uUtj0oHp8+DhPUuHXh+WBII1E/aoKpPSm3c=',
    'PriceList': [
        '{"product":{"productFamily":"Storage","attributes":{"storageMedia":"SSD-backed","maxThroughputvolume":"320 MB/sec","volumeType":"Provisioned IOPS","maxIopsvolume":"20000","servicecode":"AmazonEC2","usagetype":"CAN1-EBS:VolumeUsage.piops","locationType":"AWS Region","location":"Canada (Central)","servicename":"Amazon Elastic Compute Cloud","maxVolumeSize":"16 TiB","operation":""},"sku":"WQGC34PB2AWS8R4U"},"serviceCode":"AmazonEC2","terms":{"OnDemand":{"WQGC34PB2AWS8R4U.JRTCKXETXF":{"priceDimensions":{"WQGC34PB2AWS8R4U.JRTCKXETXF.6YS6EN2CT7":{"unit":"GB-Mo","endRange":"Inf","description":"$0.138 per GB-month of Provisioned IOPS SSD (io1)  provisioned storage - Canada (Central)","appliesTo":[],"rateCode":"WQGC34PB2AWS8R4U.JRTCKXETXF.6YS6EN2CT7","beginRange":"0","pricePerUnit":{"USD":"0.1380000000"}}},"sku":"WQGC34PB2AWS8R4U","effectiveDate":"2017-08-01T00:00:00Z","offerTermCode":"JRTCKXETXF","termAttributes":{}}}},"version":"20170901182201","publicationDate":"2017-09-01T18:22:01Z"}',
    ],
    'ResponseMetadata': {
        '...': '...',
    },
}