Testing of Product Details, Delivery Options, and Pricing Information in Product API Response

Testing of Product Details, Delivery Options, and Pricing Information in Product API Response

GET Request

https://data.amazon.de/api/marketplaces/A1PA6795UKMFR9/products/B00NH13DV2

Response

Click here to see the complete response
{
    "resource": {
        "url": "/api/marketplaces/A1PA6795UKMFR9/products/B00NH13DV2",
        "types": [
            "product.offer-comparison-experience/v1",
            "product/v2",
            "product/v3",
            "product.mini/v1",
            "product/v1"
        ]
    },
    "type": "product/v2",
    "entity": {
        "asin": "B00NH13DV2",
        "buyingOptions": [
            {
                "delivery": {
                    "resource": {
                        "url": "/api/marketplaces/A1PA6795UKMFR9/products/B00NH13DV2/buying-options/zGqwWIPeEc5P-u6kK-AxzYOIudgUNTsGrpCLmqmiLuk%3D/delivery",
                        "types": [
                            "product.shipping-cost/v1",
                            "product.global-store-delivery/v1",
                            "product.delivery-block-badge/v1",
                            "product.delivery.cache-experiment/v1",
                            "product.delivery-block-medium/v1",
                            "product.delivery.cache-experiment/v3",
                            "product.delivery-block-extra-small/v1",
                            "product.delivery/v1",
                            "product.delivery.lite/v1",
                            "product.delivery-block-small/v1",
                            "product.delivery.cache-experiment/v2"
                        ]
                    },
                    "type": "product.delivery/v1",
                    "metadata": {
                        "x-amzn-metrics-id": "INTER_RANKED:3bedab84-c97c-3617-9d8e-a96df62e3896",
                        "x-amzn-metrics-id": "MBOS:808f9d48-dc7e-3faa-9ad9-665f7d8bddb1",
                        "x-amzn-metrics-id": "delivery:5283d1bc-e075-3d75-8fff-4034760da59e",
                        "x-api-exp-data": "OFFERSX_DP_SINGLE_BO_995763:T1,AB_LACERTA_RPU_REMOVE_BUYABILITY_FMA_CALL_1022252:T1,WWGS_GSX_SKIP_FMA_FOR_ISM_OFFERLESS_ALM_BO_867153:T1,WWGS_GSX_PICKUP_REFINEMENT_FILTER_1058624:C,LUXURY_WALLED_GARDEN_990455:T1,F3_UFGPP_BUYING_OPTION_SUPPRESSION_577305:T1,MBOS_OPTIONAL_INPUT_ADD_B2B_CUSTOMER_1027242:T1,CETECH_RENEWED_BUYING_OPTIONS_SACX_819280:T1,OFFERSX_FMA_SBR_MIGRATION_WRAPPER_803165:T1,BUYX_NORI_CORRELATIONID_1036150:C,PSX_SUPPRESS_LD_TEMPORARILY_WHEN_PED_EXISTS_890635:T1,AB_LACERTA_RPU_BLOCK_OFFER_TYPE_911858:T1,SEARCH_OFFERSX_CAPTIONS_V2_LAUNCH_653316:T2,CONSUMABLES_DP_SNS_AB_ENABLE_WW_792035:T1,PSX_CBP_METADATA_REFACTOR_950955:T1,B2B_RD_BOF_752567:T1,EUSTORES_DRAGONFLY_DISABLE_PICKUP_TAB_G_1063973:C",
                        "x-api-exp-data": "DEX_CLARITY_UDM_GATE_ALTERNATIVE_PAID_MI_542301:T1,MDX_PRIME_TRIAL_IN_SHIPPING_INSTRUCTION_828561:C,CONSOLIDATION_EVERYWHERE_MIP_TENANT_674097:T1,SIP_SHORT_CIRCUIT_ORCHESTRATOR_958730:T1,DEX_CLARITY_UDM_DATAPATH_LOGGING_870375:C,DEX_PRIME_GATING_BUSINESS_CONSOLIDATION_980927:C,LINEITEM_PRIME_PARTICIPATION_1006196:T1,DEX_SD_MIP_API_UPSELL_282685:C,VAS_FADD_SHIPPING_COST_OVERRIDE_FIX_996335:T1,SCHEDULED_DELIVERY_MIP_CROSSCUT_MI_453600:C,DEX_SSD_PRECOMPUTE_SKYDEN_EDBPE_385279:C,FAST_AND_GREEN_MIP_TENANT_491227:C,SD_FST_PIP_SKYDEN_EXPERIMENT_493336:C,SKYDEN_DESTINATION_FILTER_233126:T1,UPOM_CONSIDERS_CUSTOMER_ELIGIBILITY_668035:T1,DEX_NPA_PRIME_UPSELL_LAUNCH_793531:C,BUYX_NORI_CORRELATIONID_1036150:C,DEX_SSD_EDBPE_CART_1032835:T1,GRF_DBP_ENABLE_TR_MP_668632:T1,DEX_CPD_PRIME_ENFORCEMENT_676144:T1,CE_FNG_CONVERGENCE_803574:C,FTC_PFSD_SKYDEN_MIGRATION_263236:T1"
                    },
                    "entity": {
                        "messageInstructions": [
                            {
                                "variant": "EXPORTS",
                                "subType": "PAID",
                                "type": "PAID_SHIPPING",
                                "messageData": [
                                    {
                                        "shippingCost": {
                                            "value": {
                                                "amount": "15.44",
                                                "convertedFrom": {
                                                    "amount": "15.44",
                                                    "currencyCode": "EUR"
                                                },
                                                "currencyCode": "EUR"
                                            }
                                        },
                                        "promise": {
                                            "deliveryDateValueOrRange": {
                                                "deliveryDate": {
                                                    "dateTime": "2024-11-14T19:00:00.000Z",
                                                    "zoneId": "MET"
                                                }
                                            },
                                            "deliveryOptionId": "1"
                                        },
                                        "key": "PAID_SHIPPING"
                                    }
                                ],
                                "group": "deliveryBenefitPrograms"
                            },
                            {
                                "variant": "BLANK",
                                "subType": "",
                                "type": "PRIME_BADGE",
                                "messageData": [
                                    {
                                        "key": "BADGECX",
                                        "badgeCxAccessor": {
                                            "renderingLargeCx": "NOT_SHOW",
                                            "badgeType": "UNKNOWN",
                                            "renderingSmallCx": "NOT_SHOW"
                                        }
                                    }
                                ],
                                "group": "badging"
                            },
                            {
                                "variant": "DEFAULT",
                                "subType": "",
                                "type": "DELIVERY",
                                "messageData": [
                                    {
                                        "unifiedFragmentLinks": {
                                            "links": []
                                        },
                                        "shippingCost": {
                                            "value": {
                                                "amount": "15.44",
                                                "convertedFrom": {
                                                    "amount": "15.44",
                                                    "currencyCode": "EUR"
                                                },
                                                "currencyCode": "EUR"
                                            }
                                        },
                                        "deliveryType": "DELIVERY",
                                        "promise": {
                                            "promiseId": "e1474bdf-d7f8-4364-b7f8-3fbdb8550aec",
                                            "deliveryDateValueOrRange": {
                                                "deliveryDateRange": {
                                                    "min": {
                                                        "dateTime": "2024-11-14T19:00:00.000Z",
                                                        "zoneId": "MET"
                                                    },
                                                    "max": {
                                                        "dateTime": "2024-11-14T19:00:00.000Z",
                                                        "zoneId": "MET"
                                                    }
                                                }
                                            },
                                            "cutoff": {
                                                "dateTime": "2024-11-03T15:44:59.000Z",
                                                "zoneId": "MET"
                                            },
                                            "deliveryOptionId": "1",
                                            "deliveryDateGranularity": "DAY"
                                        },
                                        "deliveryBenefitProgramId": "paid_shipping",
                                        "key": "DELIVERY"
                                    }
                                ],
                                "group": "primaryDeliveryMessage"
                            },
                            {
                                "variant": "DEFAULT",
                                "subType": "",
                                "type": "DELIVERY",
                                "messageData": [
                                    {
                                        "unifiedFragmentLinks": {
                                            "links": []
                                        },
                                        "shippingCost": {
                                            "value": {
                                                "amount": "17.41",
                                                "convertedFrom": {
                                                    "amount": "17.41",
                                                    "currencyCode": "EUR"
                                                },
                                                "currencyCode": "EUR"
                                            }
                                        },
                                        "deliveryType": "DELIVERY",
                                        "promise": {
                                            "promiseId": "ba6876c2-85ca-4c07-9793-dfac4e293403",
                                            "deliveryDateValueOrRange": {
                                                "deliveryDateRange": {
                                                    "min": {
                                                        "dateTime": "2024-11-07T19:00:00.000Z",
                                                        "zoneId": "MET"
                                                    },
                                                    "max": {
                                                        "dateTime": "2024-11-07T19:00:00.000Z",
                                                        "zoneId": "MET"
                                                    }
                                                }
                                            },
                                            "deliveryOptionId": "2",
                                            "deliveryDateGranularity": "DAY"
                                        },
                                        "key": "DELIVERY"
                                    }
                                ],
                                "group": "secondaryDeliveryMessage"
                            }
                        ]
                    }
                },
                "type": "NEW"
            }
        ]
    }
}

Test Script

// Parse response JSON
let jsonData = pm.response.json();

// Test 1: Check main resource URL and type
pm.test("Resource URL and Type", function () {
    pm.expect(jsonData.resource).to.have.property("url", "/api/marketplaces/A1PA6795UKMFR9/products/B00NH13DV2");
    pm.expect(jsonData.resource).to.have.property("types").that.is.an("array");
    pm.expect(jsonData.resource.types).to.include("product/v2");
});

// Test 2: Check main type and entity ASIN
pm.test("Main Type and Entity ASIN", function () {
    pm.expect(jsonData).to.have.property("type", "product/v2");
    pm.expect(jsonData.entity).to.have.property("asin", "B00NH13DV2");
});

// Test 3: Check that buyingOptions is an array and has a delivery object
pm.test("Buying Options Structure", function () {
    pm.expect(jsonData.entity).to.have.property("buyingOptions").that.is.an("array").with.length.greaterThan(0);
    pm.expect(jsonData.entity.buyingOptions[0]).to.have.property("delivery").that.is.an("object");
});

// Test 4: Validate delivery metadata fields
pm.test("Delivery Metadata Fields", function () {
    let metadata = jsonData.entity.buyingOptions[0].delivery.metadata;
    pm.expect(metadata).to.have.property("x-amzn-metrics-id").that.is.a("string");
    pm.expect(metadata).to.have.property("x-api-exp-data").that.is.a("string");
});

// Test 5: Validate shipping cost in delivery message instructions
pm.test("Shipping Cost in Delivery Messages", function () {
    let messageInstructions = jsonData.entity.buyingOptions[0].delivery.entity.messageInstructions;
    pm.expect(messageInstructions).to.be.an("array").that.is.not.empty;

    // Find specific message types
    let paidShippingMessage = messageInstructions.find(msg => msg.type === "PAID_SHIPPING");
    let primaryDeliveryMessage = messageInstructions.find(msg => msg.group === "primaryDeliveryMessage");

    // Validate PAID_SHIPPING message shipping cost
    if (paidShippingMessage) {
        let shippingCost = paidShippingMessage.messageData[0].shippingCost.value;
        pm.expect(shippingCost).to.have.property("amount", "15.44");
        pm.expect(shippingCost).to.have.property("currencyCode", "EUR");
    }

    // Validate primaryDeliveryMessage
    if (primaryDeliveryMessage) {
        let deliveryDateRange = primaryDeliveryMessage.messageData[0].promise.deliveryDateValueOrRange.deliveryDateRange;
        pm.expect(deliveryDateRange.min.dateTime).to.equal("2024-11-14T19:00:00.000Z");
        pm.expect(deliveryDateRange.max.dateTime).to.equal("2024-11-14T19:00:00.000Z");
    }
});

// Test 6: Check for expected delivery dates in secondaryDeliveryMessage
pm.test("Secondary Delivery Message Dates", function () {
    let secondaryDeliveryMessage = jsonData.entity.buyingOptions[0].delivery.entity.messageInstructions
        .find(msg => msg.group === "secondaryDeliveryMessage");
    if (secondaryDeliveryMessage) {
        let deliveryDateRange = secondaryDeliveryMessage.messageData[0].promise.deliveryDateValueOrRange.deliveryDateRange;
        pm.expect(deliveryDateRange.min.dateTime).to.equal("2024-11-07T19:00:00.000Z");
        pm.expect(deliveryDateRange.max.dateTime).to.equal("2024-11-07T19:00:00.000Z");
    }
});

Let’s explain the test script

Here’s an explanation of each part of the Postman test script and what it accomplishes when validating this API response.

1. Checking the Status Code

pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
  • This checks if the response status code is 200, indicating a successful request. This is a standard test to verify that the API responded correctly.

2. Parsing and Validating the Response Structure

const response = pm.response.json();
pm.test("Response has expected structure", function () {
pm.expect(response).to.have.property("resource");
pm.expect(response).to.have.property("type", "product/v2");
pm.expect(response).to.have.property("entity");
});
  • This test parses the JSON response and validates that the response contains specific fields: resource, type, and entity.
  • It ensures that type is specifically product/v2, which is an expected value based on the response schema.

3. Validating the Resource Fields

pm.test("Resource object validation", function () {
pm.expect(response.resource).to.have.property("url").that.is.a("string");
pm.expect(response.resource).to.have.property("types").that.is.an("array");
pm.expect(response.resource.types).to.include("product/v2");
});
  • This test validates that resource has a url property (a string) and a types array.
  • It confirms that "product/v2" is included in the types array to ensure that product/v2 is indeed supported for this product.

4. Checking the ASIN and Buying Options

pm.test("Entity contains expected ASIN and buyingOptions", function () {
pm.expect(response.entity).to.have.property("asin", "B00NH13DV2");
pm.expect(response.entity).to.have.property("buyingOptions").that.is.an("array").with.lengthOf(1);
pm.expect(response.entity.buyingOptions[0]).to.have.property("type", "NEW");
});
  • This verifies that the product’s ASIN matches B00NH13DV2.
  • It ensures that buyingOptions is an array containing only one item, and that the type of this item is "NEW".

5. Checking Delivery Details within Buying Options

pm.test("Delivery details validation", function () {
const delivery = response.entity.buyingOptions[0].delivery;
pm.expect(delivery).to.have.property("type", "product.delivery/v1");
pm.expect(delivery).to.have.property("metadata").that.is.an("object");
pm.expect(delivery).to.have.property("entity").that.is.an("object");
});
  • This part checks that the delivery section within buyingOptions has the correct type (product.delivery/v1) and that both metadata and entity objects exist.
  • The metadata and entity objects are necessary for additional details about delivery and promotional messages.

6. Verifying Metadata Fields

pm.test("Metadata has required experiment data", function () {
pm.expect(delivery.metadata).to.have.property("x-amzn-metrics-id");
pm.expect(delivery.metadata).to.have.property("x-api-exp-data");
pm.expect(delivery.metadata["x-api-exp-data"]).to.include("OFFERSX_DP_SINGLE_BO_995763:T1");
});
  • This validates that specific metadata fields (x-amzn-metrics-id and x-api-exp-data) exist.
  • It also checks if the x-api-exp-data field contains OFFERSX_DP_SINGLE_BO_995763:T1, which is one of the important experiment flags expected in this response.

7. Validating Shipping Costs and Promise Details in Message Instructions

pm.test("Shipping cost and delivery date validation", function () {
const messageData = delivery.entity.messageInstructions[0].messageData[0];
pm.expect(messageData).to.have.property("shippingCost").that.is.an("object");
pm.expect(messageData.shippingCost.value.amount).to.equal("15.44");
pm.expect(messageData.shippingCost.value.currencyCode).to.equal("EUR");

pm.expect(messageData).to.have.property("promise").that.is.an("object");
pm.expect(messageData.promise.deliveryDateValueOrRange.deliveryDate.dateTime).to.equal("2024-11-14T19:00:00.000Z");
pm.expect(messageData.promise.deliveryOptionId).to.equal("1");
});
  • This test digs deeper into messageInstructions to confirm the shipping cost amount (15.44 EUR).
  • It validates the delivery date (2024-11-14T19:00:00.000Z) and the deliveryOptionId (1), both of which are crucial for fulfilling the expected delivery promises.

8. Verifying Secondary Delivery Messages

pm.test("Secondary delivery message validation", function () {
const secondaryMessage = delivery.entity.messageInstructions.find(mi => mi.group === "secondaryDeliveryMessage").messageData[0];
pm.expect(secondaryMessage.promise.deliveryDateValueOrRange.deliveryDateRange.min.dateTime).to.equal("2024-11-07T19:00:00.000Z");
pm.expect(secondaryMessage.shippingCost.value.amount).to.equal("17.41");
pm.expect(secondaryMessage.shippingCost.value.currencyCode).to.equal("EUR");
});
  • This validates fields in the secondary delivery message, such as the minimum delivery date (2024-11-07T19:00:00.000Z) and shipping cost (17.41 EUR).
  • This ensures that alternative delivery options are available and correctly priced for the user.

Scroll to Top