amzn / selling-partner-api-models

This repository contains OpenAPI models for developers to use when developing software to call Selling Partner APIs.
Apache License 2.0
547 stars 722 forks source link

Reports API: `lastUpdatedDate` field in vendor reports. What is the purpose of this field? #636

Closed wolendranh closed 2 months ago

wolendranh commented 2 months ago

Hi!

In release notes here it was stated that following reports:

GET_VENDOR_SALES_REPORT GET_VENDOR_NET_PURE_PRODUCT_MARGIN_REPORT GET_VENDOR_TRAFFIC_REPORT GET_VENDOR_FORECASTING_REPORT GET_VENDOR_INVENTORY_REPORT

are getting new field lastUpdatedDate. According to Schema documentation for vendorSalesReport it is contained in reportSpecification part of json.

What does it represents? Does it allow to filter only data updated on certain date?

I tried to provide it as part of request, and it did nothing. Doesn't matter what report and what report date I am requesting it is always same in response: 2024-05-07, which is around 2 days ago. Even if I request report for dates that are 1 year ago.

What is the purpose of this field and how it can be used? This is very poorly documented...

shreeharsh-a commented 2 months ago

Hi @wolendranh Per the schema, the lastUpdatedDate is defined as (please see description):

"lastUpdatedDate": {
          "type": "string",
          "format": "date",
          "description": "The date when the report was last updated. Follows the <a href='https://developer-docs.amazon.com/sp-api/docs/iso-8601'>ISO 8601</a> Date format of YYYY-MM-DD.",
          "examples": [
            "2021-06-20"
          ]
        }

So it simply represents when the report was last updated. Hoping this helps.

wolendranh commented 2 months ago

@shreeharsh-a thank you for answering my question.

I am not sure I completely understand.

Does this mean that lastUpdatedDate is latest date for which report can be requested?

So for example today is 2024-05-10. When I request report for ANY date, lastUpdatedDate at current point in time would be 2024-05-07 or 2024-05-08, as newer dates are not "uploaded"/"available" yet.

So based on this this is "newest"/"latest" date for which report can be requested?

shreeharsh-a commented 2 months ago

@wolendranh the lastUpdatedDate is an output / response field & conveys when the report was last updated at the backend - think of it like a timestamp. You cannot use this field to place any requests. When you request a report the following are the only possible request fields per the docs:

Name Description Required
reportOptions Additional information passed to reports. This varies by report type.Type: ReportOptions No
reportType The report type. For more information, refer to Report Type Values.Type: string Yes
dataStartTime 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.Type: string (date-time) No
dataEndTime 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.Type: string (date-time) No
marketplaceIds 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.Type: < string > array Yes

Please use the dataStartTime & dataEndTime fields to filter data. Hoping this helps.

wolendranh commented 2 months ago

@shreeharsh-a hmm. Ok. It is confusing though. Field is contained under reportSpecification key in report response JSON. For example:

{
  "reportSpecification" : {
    "reportType" : "GET_VENDOR_TRAFFIC_REPORT",
    "reportOptions" : {
      "reportPeriod" : "DAY"
    },
    "lastUpdatedDate" : "2024-05-07",
    "dataStartTime" : "2024-04-20",
    "dataEndTime" : "2024-04-20",
    "marketplaceIds" : [ "ATVPDKIKX0DER" ]
  },

In this example ALL keys/parameters under reportSpecification key, are provided by Requester, except new lastUpdatedDate. I think it can appear to Requester that this field can be provided as parameter for report generation.

I understand now that this field cannot be passed while creating report (which is confusing for me, because of reasons above). But I still don't understand what this field represents.

You mentioned that

lastUpdatedDate is an output / response field & conveys when the report was last updated at the backend - think of it like a timestamp.

In response example above, where reportSpecification contains:

   "lastUpdatedDate" : "2024-05-07",
    "dataStartTime" : "2024-04-20",
    "dataEndTime" : "2024-04-20",

Does lastUpdatedDate mean:

a) at what timestamp/date was data updated on backend for timeframe 2024-04-20-2024-04-20 b) the latest timeframe for which report is available to download

Which one of these 2 is correct? Sorry for such long discussion, but I don't fully understand purpose of this field and logic behind it yet.