Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Search for agreements by account ID using an AWS SDK - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Search for agreements by account ID using an AWS SDK

The following code example shows how to search for agreements by account ID.

Python
SDK for Python (Boto3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Marketplace API Reference Code Library repository.

# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 """ Purpose Shows how to use the AWS SDK for Python (Boto3) to get agreement by customer AWS account ID AG-02 """ import argparse import logging import boto3 import utils.helpers as helper from botocore.exceptions import ClientError mp_client = boto3.client("marketplace-agreement") logger = logging.getLogger(__name__) MAX_PAGE_RESULTS = 10 def get_agreements(account_id): AgreementSummaryList = [] try: agreement = mp_client.search_agreements( catalog="AWSMarketplace", maxResults=MAX_PAGE_RESULTS, filters=[ {"name": "PartyType", "values": ["Proposer"]}, {"name": "AcceptorId", "values": [account_id]}, {"name": "AgreementType", "values": ["PurchaseAgreement"]}, ], ) except ClientError as e: logger.error("Could not complete search_agreements request.") raise e AgreementSummaryList.extend(agreement["agreementViewSummaries"]) while "nextToken" in agreement and agreement["nextToken"] is not None: try: agreement = mp_client.search_agreements( catalog="AWSMarketplace", maxResults=MAX_PAGE_RESULTS, nextToken=agreement["nextToken"], filters=[ {"name": "PartyType", "values": ["Proposer"]}, {"name": "AcceptorId", "values": [account_id]}, {"name": "AgreementType", "values": ["PurchaseAgreement"]}, ], ) except ClientError as e: logger.error("Could not complete search_agreements request.") raise e AgreementSummaryList.extend(agreement["agreementViewSummaries"]) return AgreementSummaryList if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--account_id", "-aid", help="Provide accepting account ID to search for agreements", required=True, ) args = parser.parse_args() response = get_agreements(account_id=args.account_id) helper.pretty_print_datetime(response)
  • For API details, see SearchAgreements in AWS SDK for Python (Boto3) API Reference.

SDK for Python (Boto3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Marketplace API Reference Code Library repository.

# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 """ Purpose Shows how to use the AWS SDK for Python (Boto3) to get agreement by customer AWS account ID AG-02 """ import argparse import logging import boto3 import utils.helpers as helper from botocore.exceptions import ClientError mp_client = boto3.client("marketplace-agreement") logger = logging.getLogger(__name__) MAX_PAGE_RESULTS = 10 def get_agreements(account_id): AgreementSummaryList = [] try: agreement = mp_client.search_agreements( catalog="AWSMarketplace", maxResults=MAX_PAGE_RESULTS, filters=[ {"name": "PartyType", "values": ["Proposer"]}, {"name": "AcceptorId", "values": [account_id]}, {"name": "AgreementType", "values": ["PurchaseAgreement"]}, ], ) except ClientError as e: logger.error("Could not complete search_agreements request.") raise e AgreementSummaryList.extend(agreement["agreementViewSummaries"]) while "nextToken" in agreement and agreement["nextToken"] is not None: try: agreement = mp_client.search_agreements( catalog="AWSMarketplace", maxResults=MAX_PAGE_RESULTS, nextToken=agreement["nextToken"], filters=[ {"name": "PartyType", "values": ["Proposer"]}, {"name": "AcceptorId", "values": [account_id]}, {"name": "AgreementType", "values": ["PurchaseAgreement"]}, ], ) except ClientError as e: logger.error("Could not complete search_agreements request.") raise e AgreementSummaryList.extend(agreement["agreementViewSummaries"]) return AgreementSummaryList if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--account_id", "-aid", help="Provide accepting account ID to search for agreements", required=True, ) args = parser.parse_args() response = get_agreements(account_id=args.account_id) helper.pretty_print_datetime(response)
  • For API details, see SearchAgreements in AWS SDK for Python (Boto3) API Reference.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.