Budget Rules
Warning
Sponsored Product v3 is not available for Sandbox endpoint
Note
This API is version 3.0
- class ad_api.api.sp.BudgetRules(account='default', marketplace: Marketplaces = Marketplaces.EU, credentials=None, proxies=None, verify=True, timeout=None, debug=False, access_token=None)
Endpoints available
Method
Endpoint
Description
GET
/sp/campaigns/{campaignId}/budgetRules/budgetHistory
Gets the budget history for a campaign specified by identifier.
POST
/sp/budgetRules
Creates one or more budget rules.
GET
/sp/budgetRules
Get all budget rules created by an advertiser
PUT
/sp/budgetRules
Updates one or more budget rules.
GET
/sp/budgetRules/{budgetRuleId}
Gets a budget rule specified by identifier.
GET
/sp/budgetRules/{budgetRuleId}/campaigns
Gets all the campaigns associated with a budget rule
POST
/sp/campaigns/{campaignId}/budgetRules
Associates one or more budget rules to a campaign specified by identifer.
GET
/sp/campaigns/{campaignId}/budgetRules
Gets a list of budget rules associated to a campaign specified by identifier.
DELETE
/sp/campaigns/{campaignId}/budgetRules/{budgetRuleId}
Disassociates a budget rule specified by identifier from a campaign specified by identifier.
- get_budget_history(self, campaignId, **kwargs) ApiResponse:
Gets the budget history for a campaign specified by identifier.
- Param:
- path campaignId* (number). The campaign identifier.query nextToken (string). To retrieve the next page of results, call the same operation and specify this token in the request. If the nextToken field is empty, there are no further results.query pageSize* (number). Sets a limit on the number of results returned. Maximum limit of pageSize is 30.query startDate* (string). The start date of the budget history in YYYYMMDD format.query endDate* (string). The end date of the budget history in YYYYMMDD format.
Returns:
ApiResponse
- create_budget_rules(self, **kwargs) ApiResponse:
Creates one or more budget rules.
- Request Body
- CreateSPBudgetRulesRequest {budgetRulesDetails (array) [maxItems: 25.A list of budget rule details.SPBudgetRuleDetails {Object representing details of a budget rule for SP campaignduration RuleDuration {eventTypeRuleDuration EventTypeRuleDuration {Object representing event type rule duration.eventId*(string): The event identifier. This value is available from the budget rules recommendation API.endDate(string): The event end date in YYYYMMDD format. Read-only.eventName(string): The event name. Read-only.startDate(string): The event start date in YYYYMMDD format. Read-only. Note that this field is present only for announced events.}dateRangeTypeRuleDuration DateRangeTypeRuleDuration {Object representing date range type rule duration.endDate(string): The end date of the budget rule in YYYYMMDD format. The end date is inclusive. Required to be equal or greater than startDate.startDate*(string): The start date of the budget rule in YYYYMMDD format. The start date is inclusive. Required to be greater than or equal to current date.eventName(string): The event name. Read-only.startDate(string): The event start date in YYYYMMDD format. Read-only. Note that this field is present only for announced events.}}recurrence Recurrence {type (string): The frequency of the rule application. Enum: [‘DAILY’]daysOfWeek (array). Object representing days of the week for weekly type rule. It is not required for daily recurrence typeDayOfWeek [DayOfWeek(string): The day of the week. Enum: [‘MONDAY’, ‘TUESDAY’, ‘WEDNESDAY’, ‘THURSDAY’, ‘FRIDAY’, ‘SATURDAY’, ‘SUNDAY’]]}ruleType* SPRuleType (string): The type of budget rule. SCHEDULE: A budget rule based on a start and end date. PERFORMANCE: A budget rule based on advertising performance criteria. Enum: [‘SCHEDULE’, ‘PERFORMANCE’]budgetIncreaseBy budgetIncreaseBy {type* BudgetChangeType (string): The value by which to update the budget of the budget rule. Enum: [‘PERCENT’]value* number($double): The budget value.}name (string): The budget rule name. Required to be unique within a campaign. maxLength: 355performanceMeasureCondition* PerformanceMeasureCondition {metricName* PerformanceMetrics (string): The advertising performance metric. Enum: [ ACOS, CTR, CVR, ROAS ]comparisonOperator* ComparisonOperator (string): The comparison operator. Enum: [ GREATER_THAN, LESS_THAN, EQUAL_TO, LESS_THAN_OR_EQUAL_TO, GREATER_THAN_OR_EQUAL_TO ]threshold* number($double): The performance threshold value.}]}
Returns:
ApiResponse
- list_budget_rules(self, **kwargs) ApiResponse:
Get all budget rules created by an advertiser
- Param:
- query nextToken (string). To retrieve the next page of results, call the same operation and specify this token in the request. If the nextToken field is empty, there are no further results.query pageSize* (number). Sets a limit on the number of results returned. Maximum limit of pageSize is 30.
Returns:
ApiResponse
- edit_budget_rules(self, **kwargs) ApiResponse:
Updates one or more budget rules.
- Request Body
- UpdateSPBudgetRulesRequest {budgetRulesDetails (array) [maxItems: 25.A list of budget rule details.SPBudgetRule {ruleState state (string): The budget rule state. Enum: [‘ACTIVE’, ‘PAUSED’]lastUpdatedDate number($int64): Epoch time of budget rule update. Read-only.createdDate number($int64): Epoch time of budget rule creation. Read-only.ruleDetails SPBudgetRuleDetails {Object representing details of a budget rule for SP campaignduration RuleDuration {eventTypeRuleDuration EventTypeRuleDuration {Object representing event type rule duration.eventId*(string): The event identifier. This value is available from the budget rules recommendation API.endDate(string): The event end date in YYYYMMDD format. Read-only.eventName(string): The event name. Read-only.startDate(string): The event start date in YYYYMMDD format. Read-only. Note that this field is present only for announced events.}dateRangeTypeRuleDuration DateRangeTypeRuleDuration {Object representing date range type rule duration.endDate(string): The end date of the budget rule in YYYYMMDD format. The end date is inclusive. Required to be equal or greater than startDate.startDate*(string): The start date of the budget rule in YYYYMMDD format. The start date is inclusive. Required to be greater than or equal to current date.eventName(string): The event name. Read-only.startDate(string): The event start date in YYYYMMDD format. Read-only. Note that this field is present only for announced events.}}recurrence Recurrence {type (string): The frequency of the rule application. Enum: [‘DAILY’]daysOfWeek (array). Object representing days of the week for weekly type rule. It is not required for daily recurrence typeDayOfWeek [DayOfWeek(string): The day of the week. Enum: [‘MONDAY’, ‘TUESDAY’, ‘WEDNESDAY’, ‘THURSDAY’, ‘FRIDAY’, ‘SATURDAY’, ‘SUNDAY’]]}ruleType* SPRuleType (string): The type of budget rule. SCHEDULE: A budget rule based on a start and end date. PERFORMANCE: A budget rule based on advertising performance criteria. Enum: [‘SCHEDULE’, ‘PERFORMANCE’]budgetIncreaseBy budgetIncreaseBy {type* BudgetChangeType (string): The value by which to update the budget of the budget rule. Enum: [‘PERCENT’]value* number($double): The budget value.}name (string): The budget rule name. Required to be unique within a campaign. maxLength: 355performanceMeasureCondition* PerformanceMeasureCondition {metricName* PerformanceMetrics (string): The advertising performance metric. Enum: [ ACOS, CTR, CVR, ROAS ]comparisonOperator* ComparisonOperator (string): The comparison operator. Enum: [ GREATER_THAN, LESS_THAN, EQUAL_TO, LESS_THAN_OR_EQUAL_TO, GREATER_THAN_OR_EQUAL_TO ]threshold* number($double): The performance threshold value.}ruleId* (string): The budget rule identifier.ruleStatus (string): he budget rule status. Read-only.}]}
Returns:
ApiResponse
- get_budget_rule(self, budgetRuleId, **kwargs) ApiResponse:
Gets a budget rule specified by identifier.
- Param:
- path budgetRuleId* (string). The budget rule identifier.
Returns:
ApiResponse
- get_campaigns_budget_rule(self, budgetRuleId, **kwargs) ApiResponse:
Gets all the campaigns associated with a budget rule
- Param:
- path budgetRuleId* (string). The budget rule identifier.query nextToken (string). To retrieve the next page of results, call the same operation and specify this token in the request. If the nextToken field is empty, there are no further results.query pageSize* (number). Sets a limit on the number of results returned. Maximum limit of pageSize is 30.
Returns:
ApiResponse
- create_campaign_budget_rules(self, campaignId, **kwargs) ApiResponse:
Associates one or more budget rules to a campaign specified by identifer.
- Param:
- path campaignId* (number). The campaign identifier.
Returns:
ApiResponse
- get_budget_rules_campaign(self, campaignId, **kwargs) ApiResponse:
Gets a list of budget rules associated to a campaign specified by identifier.
- Param:
- path campaignId* (number). The campaign identifier.
Returns:
ApiResponse
- delete_budget_rule_campaign(self, campaignId, budgetRuleId, **kwargs) ApiResponse:
Disassociates a budget rule specified by identifier from a campaign specified by identifier.
- Param:
- path campaignId* (number). The campaign identifier.path budgetRuleId* (string). The budget rule identifier.
Returns:
ApiResponse