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

[FEATURE] [ORDERS] [UNSOLVED] Add sorting options to getOrders or at least set the default sorting to latest to oldest #568

Closed hexrw closed 1 month ago

hexrw commented 2 months ago

I'm submitting a...

[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[x] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

SP-API Name and Version or Report/Feed Type

Orders v0 getOrders GET /orders/v0/orders

Expected Behavior

I request orders and I get the newest/latest order first. Then as I download more and more pages I get older and older orders. It's the natural intuitive reasonable way to do sort orders.

Either make the default behavior retrieve orders from latest to oldest or add an option for changing the order used.

Current Behavior

Orders get returned ordered from oldest to latest. So for example if I request yesterday's orders and there's a lot of them, I have to download multiple pages just to get to the latest ones...

Context/Screenshots

Example:

{
    "payload": {
        "Orders": [
            {
                "BuyerInfo": {
                    "BuyerEmail": ...
                },
                "AmazonOrderId": "306-0568272-0000000",
                "EarliestDeliveryDate": "2024-01-08T23:00:00Z",
                "EarliestShipDate": "2024-01-07T23:00:00Z",
                "SalesChannel": "Amazon.de",
                "AutomatedShippingSettings": {
                    "HasAutomatedShippingSettings": false
                },
                "OrderStatus": "Shipped",
                "NumberOfItemsShipped": 1,
                "OrderType": "StandardOrder",
                "IsPremiumOrder": false,
                "IsPrime": false,
                "FulfillmentChannel": "MFN",
                "NumberOfItemsUnshipped": 0,
                "HasRegulatedItems": false,
                "IsReplacementOrder": "false",
                "IsSoldByAB": false,
                "LatestShipDate": "2024-01-09T22:59:59Z",
                "ShipServiceLevel": "Exp DE Dom_1",
                "DefaultShipFromLocationAddress": ...
                "IsISPU": false,
                "MarketplaceId": "A1PA6795UKMFR9",
                "LatestDeliveryDate": "2024-01-11T22:59:59Z",
                "PurchaseDate": "2024-01-05T06:40:24Z",
                "ShippingAddress": ...
                "IsAccessPointOrder": false,
                "PaymentMethod": "Other",
                "IsBusinessOrder": false,
                "OrderTotal": {
                    "CurrencyCode": "EUR",
                    "Amount": "60.51"
                },
                "PaymentMethodDetails": [
                    "Standard"
                ],
                "IsGlobalExpressEnabled": false,
                "LastUpdateDate": "2024-01-05T14:14:27Z",
                "ShipmentServiceLevelCategory": "Expedited"
            },
            {
                "BuyerInfo": {
                    "BuyerEmail": ...
                },
                "AmazonOrderId": "305-8797721-0000001",
                "EarliestDeliveryDate": "2024-01-08T23:00:00Z",
                "EarliestShipDate": "2024-01-07T23:00:00Z",
                "SalesChannel": "Amazon.de",
                "AutomatedShippingSettings": {
                    "HasAutomatedShippingSettings": false
                },
                "OrderStatus": "Shipped",
                "NumberOfItemsShipped": 1,
                "OrderType": "StandardOrder",
                "IsPremiumOrder": false,
                "IsPrime": false,
                "FulfillmentChannel": "MFN",
                "NumberOfItemsUnshipped": 0,
                "HasRegulatedItems": false,
                "IsReplacementOrder": "false",
                "IsSoldByAB": false,
                "LatestShipDate": "2024-01-09T22:59:59Z",
                "ShipServiceLevel": "Exp DE Dom_1",
                "DefaultShipFromLocationAddress": ...
                "IsISPU": false,
                "MarketplaceId": "A1PA6795UKMFR9",
                "LatestDeliveryDate": "2024-01-11T22:59:59Z",
                "PurchaseDate": "2024-01-05T08:57:02Z",
                "ShippingAddress": ...
                "IsAccessPointOrder": false,
                "PaymentMethod": "Other",
                "IsBusinessOrder": false,
                "OrderTotal": {
                    "CurrencyCode": "EUR",
                    "Amount": "37.99"
                },
                "PaymentMethodDetails": [
                    "Standard"
                ],
                "IsGlobalExpressEnabled": false,
                "LastUpdateDate": "2024-01-08T13:46:44Z",
                "ShipmentServiceLevelCategory": "Expedited"
            },
            ...
        }
    }
}

This order is wrong. Why from oldest to latest?

{
    "payload": {
        "Orders": [
            {
                "BuyerInfo": {
                    "BuyerEmail": ...
                },
                "AmazonOrderId": "305-8797721-0000001",
                "EarliestDeliveryDate": "2024-01-08T23:00:00Z",
                "EarliestShipDate": "2024-01-07T23:00:00Z",
                "SalesChannel": "Amazon.de",
                "AutomatedShippingSettings": {
                    "HasAutomatedShippingSettings": false
                },
                "OrderStatus": "Shipped",
                "NumberOfItemsShipped": 1,
                "OrderType": "StandardOrder",
                "IsPremiumOrder": false,
                "IsPrime": false,
                "FulfillmentChannel": "MFN",
                "NumberOfItemsUnshipped": 0,
                "HasRegulatedItems": false,
                "IsReplacementOrder": "false",
                "IsSoldByAB": false,
                "LatestShipDate": "2024-01-09T22:59:59Z",
                "ShipServiceLevel": "Exp DE Dom_1",
                "DefaultShipFromLocationAddress": ...
                "IsISPU": false,
                "MarketplaceId": "A1PA6795UKMFR9",
                "LatestDeliveryDate": "2024-01-11T22:59:59Z",
                "PurchaseDate": "2024-01-05T08:57:02Z",
                "ShippingAddress": ...
                "IsAccessPointOrder": false,
                "PaymentMethod": "Other",
                "IsBusinessOrder": false,
                "OrderTotal": {
                    "CurrencyCode": "EUR",
                    "Amount": "37.99"
                },
                "PaymentMethodDetails": [
                    "Standard"
                ],
                "IsGlobalExpressEnabled": false,
                "LastUpdateDate": "2024-01-08T13:46:44Z",
                "ShipmentServiceLevelCategory": "Expedited"
            },
            {
                "BuyerInfo": {
                    "BuyerEmail": ...
                },
                "AmazonOrderId": "306-0568272-0000000",
                "EarliestDeliveryDate": "2024-01-08T23:00:00Z",
                "EarliestShipDate": "2024-01-07T23:00:00Z",
                "SalesChannel": "Amazon.de",
                "AutomatedShippingSettings": {
                    "HasAutomatedShippingSettings": false
                },
                "OrderStatus": "Shipped",
                "NumberOfItemsShipped": 1,
                "OrderType": "StandardOrder",
                "IsPremiumOrder": false,
                "IsPrime": false,
                "FulfillmentChannel": "MFN",
                "NumberOfItemsUnshipped": 0,
                "HasRegulatedItems": false,
                "IsReplacementOrder": "false",
                "IsSoldByAB": false,
                "LatestShipDate": "2024-01-09T22:59:59Z",
                "ShipServiceLevel": "Exp DE Dom_1",
                "DefaultShipFromLocationAddress": ...
                "IsISPU": false,
                "MarketplaceId": "A1PA6795UKMFR9",
                "LatestDeliveryDate": "2024-01-11T22:59:59Z",
                "PurchaseDate": "2024-01-05T06:40:24Z",
                "ShippingAddress": ...
                "IsAccessPointOrder": false,
                "PaymentMethod": "Other",
                "IsBusinessOrder": false,
                "OrderTotal": {
                    "CurrencyCode": "EUR",
                    "Amount": "60.51"
                },
                "PaymentMethodDetails": [
                    "Standard"
                ],
                "IsGlobalExpressEnabled": false,
                "LastUpdateDate": "2024-01-05T14:14:27Z",
                "ShipmentServiceLevelCategory": "Expedited"
            },
            ...
        }
    }
}

This is what I want to see. Latest order first.

Your Environment

Node 20 LTS

harguph commented 1 month ago

Hello @hexrw ,

The getOrders api allows multiple query parameters to apply the filtering criteria.

Currently it does not allow sorting feature, as an immediate fix one can use a programming language to iterate through the data in-memory ( such as lists in python ) and traverse it in reverse order after getting all the details.

We have noted your feedback and shared with the concerned team.

Regards