Profiles
https://d3a0d0y2hgofx6.cloudfront.net/openapi/en-us/profiles/3-0/openapi.yaml
Profiles represent an advertiser and their account’s marketplace, and are used in all subsequent API calls via a management scope, Amazon-Advertising-API-Scope. Reports and all entity management operations are associated with a single profile. Advertisers cannot have more than one profile for each marketplace.
Advertisers who operate in more than one marketplace (for example, Amazon.com, Amazon.co.uk, Amazon.co.jp) will have only one profile associated with each marketplace. See this link for a list of marketplaces associated with each endpoint.
To retrieve your profile IDs, call the listProfiles operation, and include a valid authorization access token in the header. Use a profileId from the returned list as the value for the management scope (Amazon-Advertising-API-Scope) in the headers for subsequent API calls.
- class ad_api.api.Profiles(account='default', marketplace: Marketplaces = Marketplaces.EU, credentials=None, proxies=None, verify=True, timeout=None, debug=False, access_token=None)
- list_profiles(self, **kwargs) ApiResponse
Gets a list of profiles.
query apiProgram:string | Optional. Filters response to include profiles that have permissions for the specified Advertising API program only. Available values : billing, campaign, paymentMethod, store, report, account, posts
query accessLevel:string | Optional. Filters response to include profiles that have specified permissions for the specified Advertising API program only. Available values : edit, view
query profileTypeFilter:string | Optional. Filters response to include profiles that are of the specified types in the comma-delimited list. Available values : seller, vendor, agency
query validPaymentMethodFilter:string | Optional. Filter response to include profiles that have valid payment methods. Available values : true, false
Returns:
ApiResponse
### Example getting a list of profiles
import logging from ad_api.api import Profiles from ad_api.base import AdvertisingApiException def list_profiles(**kwargs): logging.info("-------------------------------------") logging.info("Profiles > list_profiles(%s)" % kwargs) logging.info("-------------------------------------") try: result = Profiles(account=store, debug=True).list_profiles( **kwargs ) logging.info(result) accounts_info = result.payload for account_info in accounts_info: logging.info(account_info) except AdvertisingApiException as error: logging.info(error) list_profiles() # list_profiles(profileTypeFilter="seller") # list_profiles(profileTypeFilter="vendor") # list_profiles(profileTypeFilter="agency") # list_profiles(accessLevel="edit") # list_profiles(apiProgram="store") # list_profiles(validPaymentMethodFilter="true")
- update_single_profile_assistant(profile_id: int, daily_budget: int, **kwargs) ApiResponse
Update the daily budget for one or more profiles. Note that this operation is only used for Sellers using Sponsored Products.
‘profile_id’: integer($int64) | required {‘description’: ‘The identifier of the profile.’}
‘daily_budget’: number, | required {‘description’: ‘Note that this field applies to Sponsored Product campaigns for seller type accounts only. Not supported for vendor type accounts.’}
‘**kwargs’: You can add other keyword args like the original method (countryCode, currencyCode, timezone, accountInfo{}) but as they are read-only if you try to modify will get INVALID_ARGUMENT: Cannot modify “value” for profile Returns:
ApiResponse
### Example updating the budget of a single profile
import logging from ad_api.api import Profiles from ad_api.base import AdvertisingApiException def update_single_profile_assistant(account_profile_id: int, account_daily_budget: float, **kwargs): logging.info("-------------------------------------") logging.info("Profiles > update_single_profile_assistant({}, {}, {})".format(str(account_profile_id), str(account_daily_budget), str(kwargs))) logging.info("-------------------------------------") try: result = Profiles(account=store, debug=True).update_single_profile_assistant( profile_id=account_profile_id, daily_budget=account_daily_budget, **kwargs ) logging.info(result) payload = result.payload logging.info(payload) except AdvertisingApiException as error: logging.info(error) amz_profile_id = 1495806522428699 amz_daily_budget = 21.50 update_single_profile_assistant(amz_profile_id, amz_daily_budget) # update_single_profile_assistant(amz_profile_id, amz_daily_budget, countryCode="ES", timezone="Europe/London")
- update_profile(body: dict, list, str) ApiResponse
Update the daily budget for one or more profiles. Note that this operation is only used for Sellers using Sponsored Products.
body: | REQUIRED {‘description’: ‘An array of ad groups.}’
‘profileId’: integer($int64) | required {‘description’: ‘The identifier of the profile.’}‘countryCode’: string | readOnly {‘description’: ‘The countryCode for a given country’}‘currencyCode’: string | readOnly {‘description’: ‘The currency used for all monetary values for entities under this profile.’}‘dailyBudget’: number | required {‘description’: ‘Note that this field applies to Sponsored Product campaigns for seller type accounts only. Not supported for vendor type accounts.’}‘timezone’: string | readOnly {‘description’: ‘The time zone used for all date-based campaign management and reporting.’}‘accountInfo’: AccountInfoAccountInfo | readOnly {}Returns:
ApiResponse
### Example updating the budget of one or more profiles
import logging from ad_api.api import Profiles from ad_api.base import AdvertisingApiException def update_profile(data: (dict, list, str)): logging.info("-------------------------------------") logging.info("Profiles > update_profile(%s)" % str(data)) logging.info("-------------------------------------") try: result = Profiles(account=store, debug=True).update_profile( body=data ) logging.info(result) except AdvertisingApiException as error: logging.info(error) amz_profile_id = 1495806522428699 amz_daily_budget = 21.50 # Using a dict wrapped in a list. Note: countryCode, currencyCode, timezone and accountInfo are read only # try to update this fields will lead to INVALID ARGUMENT so in my opinion better no need to send unless # you store the data and you retrieve all the fields update_data_list = \ [ { 'profileId': amz_profile_id, 'dailyBudget': amz_daily_budget, 'countryCode': 'ES', 'currencyCode': 'EUR', 'timezone': 'Europe/Paris', 'accountInfo': { 'id': 'A30E1B2F3U4K5Y', 'marketplaceStringId': 'A1RKKUPIHCS9HS', 'type': 'seller' } } ] update_profile(update_data_list) # The most simple and useful way to update the budget of a single profile update_data_dict = \ { 'profileId': amz_profile_id, 'dailyBudget': amz_daily_budget, } update_profile(update_data_dict) # The most simple and useful way to update the budget of a bunch of profiles update_profiles_list = \ [ { 'profileId': 1495806522428699, 'dailyBudget': 10.5, }, { 'profileId': 1495806522428698, 'dailyBudget': 20, } ] update_profile(update_profiles_list)
- get_profile(self, profileId, **kwargs) ApiResponse
Gets a profile specified by identifier.
path profileId:number | Required. The identifier of an existing profile Id.
Returns:
ApiResponse
### Example getting a profiles by profileId
import logging from ad_api.api import Profiles from ad_api.base import AdvertisingApiException def get_profile(profile_id: int): logging.info("-------------------------------------") logging.info("Profiles > get_profile(%s)" % profile_id) logging.info("-------------------------------------") try: result = Profiles(account=store, debug=True).get_profile( profileId=profile_id ) logging.info(result) profile_info = result.payload except AdvertisingApiException as error: logging.info(error) amz_profile_id = 1495806522428699 get_profile(amz_profile_id)
Warning
Note that this register_brand_assistant operation is only used for SANDBOX test environment.
- register_brand_assistant(country_code: str, brand: str) ApiResponse
SANDBOX ONLY - Create a vendor profile for sandbox.
‘country_code’: string, {‘description’: ‘The countryCode for a given country’}‘brand’: string, {‘description’: ‘The brand for the vendor account’}Returns:
ApiResponse
### Example creating a Vendor profile for sandbox
import logging from ad_api.api import Profiles from ad_api.base import AdvertisingApiException def register_brand_assistant(country_code: str, brand: str): logging.info("-------------------------------------") logging.info("Profiles > register_brand_assistant({},{})".format(country_code, brand)) logging.info("-------------------------------------") try: result = Profiles(account=store, debug=True).register_brand_assistant( country_code=country_code, brand=brand ) logging.info(result) except AdvertisingApiException as error: logging.info(error) amz_country_code = "UK" vendor_brand = "LEADTECH" register_brand_assistant(amz_country_code, vendor_brand)
Warning
Note that this register_brand operation is only used for SANDBOX test environment.
- register_brand(body: dict) ApiResponse
SANDBOX ONLY - Create a vendor profile for sandbox.
- body: | REQUIRED
- {‘countryCode’: string, {‘description’: ‘The countryCode for a given country’}‘brand’: string, {‘description’: ‘The brand for the vendor account’}}
Returns:
ApiResponse
### Example creating a Vendor profile for sandbox with a regular dict
import logging from ad_api.api import Profiles from ad_api.base import AdvertisingApiException def register_brand(dictionary: dict): logging.info("-------------------------------------") logging.info("Profiles > register_brand(%s)" % str(dictionary)) logging.info("-------------------------------------") try: result = Profiles(account=store, debug=True).register_brand( body=dictionary ) logging.info(result) except AdvertisingApiException as error: logging.info(error) amz_dict_brand = \ { 'countryCode': amz_country_code, 'brand': vendor_brand } register_brand(amz_dict_brand)
Warning
Note that this register_assistant is only used for SANDBOX test environment. Using in PRODUCTION will get a AdvertisingApiException: {‘status_code’: 404, ‘code’: ‘NOT_FOUND’, ‘details’: ‘HTTP 404 Not Found’, ‘requestId’: ‘HEMG4AR2NRF5HCW8BH8S’}
Note
You only can create one profile per country, If you try to create again the same country will get a Payload: {‘profileId’: 81562378459925, ‘status’: ‘SUCCESS’, ‘statusDetails’: ‘Merchant is already registered’}
- register_assistant(country_code: str) ApiResponse
SANDBOX ONLY - Create a seller profile for sandbox.
‘countryCode’: string, {‘description’: ‘The countryCode for a given country: [ US, CA, MX, UK, DE, FR, ES, IT, NL, JP, AU, AE, SE, PL, TR ]’}
Returns:
ApiResponse
### Example creating a profiles por a specific country
import logging from ad_api.api import Profiles from ad_api.base import AdvertisingApiException def register_assistant(value: str): logging.info("-------------------------------------") logging.info("Profiles > register_assistant(%s)" % value) logging.info("-------------------------------------") try: result = Profiles(account=store, debug=True).register_assistant( country_code=value ) logging.info(result) except AdvertisingApiException as error: logging.info(error) amz_country_code = "DE" register_assistant(amz_country_code)
### Payload
{ 'registerProfileId': '82465ad1-e8cd-4d24-beb0-5cb8423f4260DE', 'status': 'IN_PROGRESS', 'statusDetails': 'Registration workflow has been started' }
Warning
Note that this register operation is only used for SANDBOX test environment.
- register(body: dict, str) ApiResponse
SANDBOX ONLY - Create a seller profile for sandbox.
body: | REQUIRED
{‘countryCode’: string, {‘description’: ‘The countryCode for a given country [ US, CA, MX, UK, DE, FR, ES, IT, NL, JP, AU, AE, SE, PL, TR ]’}}
### Example creating a profiles por a specific country with a dict
import logging from ad_api.api import Profiles from ad_api.base import AdvertisingApiException def register(dictionary: dict): logging.info("-------------------------------------") logging.info("Profiles > register(%s)" % str(dictionary)) logging.info("-------------------------------------") try: result = Profiles(account=store, debug=True).register( body=dictionary ) logging.info(result) except AdvertisingApiException as error: logging.info(error) amz_country_code = "DE" amz_dict_country_code = \ { "countryCode": amz_country_code } register(amz_dict_country_code)