Reports๏
- class sp_api.api.Reports(marketplace: ~sp_api.base.marketplaces.Marketplaces = Marketplaces.US, *, refresh_token=None, account='default', credentials=None, restricted_data_token=None, proxies=None, verify=True, timeout=None, version=None, credential_providers=None, auth_token_client_class=<class 'sp_api.auth.access_token_client.AccessTokenClient'>)๏
Reports SP-API Client :link:
The Selling Partner API for Reports lets you retrieve and manage a variety of reports that can help selling partners manage their businesses.
- get_reports(self, **kwargs) ApiResponse ๏
Returns report details for the reports that match the filters that you specify.
Usage Plan:
Rate (requests per second)
Burst
0.0222
10
For more information, see โUsage Plans and Rate Limitsโ in the Selling Partner API documentation.
Examples
literal blocks:
report_types = ["FEE_DISCOUNTS_REPORT", "GET_AFN_INVENTORY_DATA"] processing_status = ["IN_QUEUE", "IN_PROGRESS"] res = Reports().get_reports(reportTypes=report_types, processingStatuses=processing_status)
- Parameters:
reportTypes (key) โ str[] or ReportType[] | optional A list of report types used to filter reports. When reportTypes is provided, the other filter parameters (processingStatuses, marketplaceIds, createdSince, createdUntil) and pageSize may also be provided. Either reportTypes or nextToken is required.
processingStatuses (key) โ str[] or ProcessingStatus[] optional A list of processing statuses used to filter reports.
marketplaceIds (key) โ str[] or Marketplaces[] optional A list of marketplace identifiers used to filter reports. The reports returned will match at least one of the marketplaces that you specify.
pageSize (key) โ int optional The maximum number of reports to return in a single call.
createdSince (key) โ str or datetime optional The earliest report creation date and time for reports to include in the response, in ISO 8601 date time format. The default is 90 days ago. Reports are retained for a maximum of 90 days. string (date-time) -
createdUntil (key) โ str or datetime optional The latest report creation date and time for reports to include in the response, in ISO 8601 date time format. The default is now. string (date-time) -
nextToken (key) โ str optional A stringget_report_document token returned in the response to your previous request. nextToken is returned when the number of results exceeds the specified pageSize value. To get the next page of results, call the getReports operation and include this token as the only parameter. Specifying nextToken with any other parameters will cause the request to fail. string -
- Returns:
ApiResponse
- create_report(self, **kwargs) ApiResponse ๏
See report types at :link: https://github.com/amzn/selling-partner-api-docs/blob/main/references/reports-api/reporttype-values.md
Usage Plan:
Rate (requests per second)
Burst
0.0167
15
Examples
literal blocks:
res = Reports().create_report( reportType=ReportType.GET_MERCHANT_LISTINGS_ALL_DATA, dataStartTime='2019-12-10T20:11:24.000Z', marketplaceIds=[ "A1PA6795UKMFR9", "ATVPDKIKX0DER" ])
- Parameters:
reportOptions (key) โ optional Additional information passed to reports. This varies by report type. ReportOptions
reportType (key) โ required The report type. :link: https://github.com/amzn/selling-partner-api-docs/blob/main/references/reports-api/reporttype-values.md
dataStartTime (key) โ optional The start of a date and time range, in ISO 8601 date time format, used for selecting the data to report. The default is now. The value must be prior to or equal to the current date and time. Not all report types make use of this. string (date-time)
dataEndTime (key) โ optional The end of a date and time range, in ISO 8601 date time format, used for selecting the data to report. The default is now. The value must be prior to or equal to the current date and time. Not all report types make use of this. string (date-time)
marketplaceIds (key) โ optional, defaults to the clientโs marketplace A list of marketplace identifiers. The report documentโs contents will contain data for all of the specified marketplaces, unless the report type indicates otherwise. < string > array
- Returns:
ApiResponse
- cancel_report(self, reportId, **kwargs) ApiResponse ๏
Cancels the report that you specify. Only reports with processingStatus=IN_QUEUE can be cancelled. Cancelled reports are returned in subsequent calls to the getReport and getReports operations.
Usage Plan:
Rate (requests per second)
Burst
0.0022
10
For more information, see โUsage Plans and Rate Limitsโ in the Selling Partner API documentation.
- Parameters:
reportId โ string | * REQUIRED The identifier for the report. This identifier is unique only in combination with a seller ID.
- Return type:
- get_report(self, report_id, **kwargs)๏
Returns report details (including the reportDocumentId, if available) for the report that you specify.
Usage Plan:
Rate (requests per second)
Burst
2
15
For more information, see โUsage Plans and Rate Limitsโ in the Selling Partner API documentation.
Examples
literal blocks:
Reports().get_report('ID323')
- Parameters:
reportId โ str
- Returns:
ApiResponse
- get_report_schedules(**kwargs) ApiResponse ๏
Returns report schedule details that match the filters that you specify.
Usage Plan:
Rate (requests per second)
Burst
0.0222
10
For more information, see โUsage Plans and Rate Limitsโ in the Selling Partner API documentation.
- Parameters:
reportTypes (key) โ str[] or ReportType[] | required A list of report types used to filter report schedules. Min count : 1. Max count : 10.
- Returns:
ApiResponse
- create_report_schedule(self, **kwargs) ApiResponse ๏
Creates a report schedule. If a report schedule with the same report type and marketplace IDs already exists, it will be cancelled and replaced with this one.
Usage Plan:
Rate (requests per second)
Burst
0.0222
10
Examples
literal blocks:
Reports().create_report_schedule(reportType='FEE_DISCOUNTS_REPORT', period=Schedules.MINUTES_5.value, nextReportCreationTime="2019-12-10T20:11:24.000Z", marketplaceIds=["A1PA6795UKMFR9", "ATVPDKIKX0DER"])
- Parameters:
reportType (key) โ str
marketplaceIds (key) โ str
reportOptions (key) โ dict
period (key) โ Schedules
nextReportCreationTime (key) โ str datetime isoformat
- Return type:
- cancel_report_schedule(self, reportScheduleId, **kwargs) ApiResponse ๏
Cancels the report schedule that you specify.
Usage Plan:
Rate (requests per second)
Burst
0.0222
10
For more information, see โUsage Plans and Rate Limitsโ in the Selling Partner API documentation.
Examples
literal blocks:
Reports().cancel_report_schedule('ID')
- Parameters:
reportScheduleId โ str
kwargs
- Returns:
ApiResponse
- delete_report_schedule(reportScheduleId, **kwargs) ApiResponse ๏
cancel_report_schedule(self, reportScheduleId, **kwargs) -> ApiResponse
Cancels the report schedule that you specify.
Usage Plan:
Rate (requests per second)
Burst
0.0222
10
For more information, see โUsage Plans and Rate Limitsโ in the Selling Partner API documentation.
Examples
literal blocks:
Reports().cancel_report_schedule('ID')
- Parameters:
reportScheduleId โ str
kwargs
- Returns:
ApiResponse
- get_report_schedule(self, reportScheduleId, **kwargs) ApiResponse ๏
Returns report schedule details for the report schedule that you specify.
Usage Plan:
Rate (requests per second)
Burst
0.0222
10
For more information, see โUsage Plans and Rate Limitsโ in the Selling Partner API documentation.
Examples
literal blocks:
Reports().get_report_schedule('ID323')
- Parameters:
reportScheduleId โ str | required The identifier for the report schedule. This identifier is unique only in combination with a seller ID.
kwargs
- Returns:
ApiResponse
- get_report_document(self, document_id, decrypt: bool = False, file=None, character_code: str | None = None, **kwargs) ApiResponse ๏
Returns the information required for retrieving a report documentโs contents. This includes a presigned URL for the report document as well as the information required to decrypt the documentโs contents.
If decrypt = True the report will automatically be loaded and decrypted/unpacked If file is set to a file (or file like object), the reportโs contents are written to the file
Usage Plan:
Rate (requests per second)
Burst
0.0167
15
For more information, see โUsage Plans and Rate Limitsโ in the Selling Partner API documentation.
Examples
literal blocks:
Reports().get_report_document('0356cf79-b8b0-4226-b4b9-0ee058ea5760', download=True, file=file)
- Parameters:
reportDocumentId โ str | the document to load
download โ bool | flag to automatically download a report
file โ If passed, will save the document to the file specified. Only valid if decrypt=True
character_code โ If passed, will be a file with the specified character code. The default is the Content-Encoding in the response while obtaining the document from the document URL. It fallbacks to โiso-8859-1โ if no encoding was found. Only valid if decrypt=True.
- Returns:
ApiResponse