Amazon Selling Partner API (SP-API) Samples

repository·main·Indexed 41 days ago

https://github.com/amzn/selling-partner-api-samples

A collection of sample code, recipes, and complex solutions for implementing Amazon Selling Partner API (SP-API) use cases. Includes Java, Python, and PHP implementations for workflows such as Vendor Retail Procurement and Easy Ship, along with a local Model Context Protocol (MCP) server and mock backend for testing.

Tokens
158.9K
Snippets
360
Records
589
Agent score
53%

What's inside Selling Partner API Samples

  1. Overview of Sample Solutions

    main
    Sample solutions in this repository are end-to-end implementations of specific business use cases. They demonstrate well-architected patterns that span across one or more Amazon Selling Partner API (SP-API) sections. These solutions are designed to be easily deployed to AWS to facilitate exploration and learning of how to integrate SP-API into production-grade architectures.
  2. Overview of the Shipping Guru Workshop

    main

    The Shipping Guru Workshop is an intermediate-level hands-on challenge (estimated 1-2 hours) designed to teach developers how to debug and optimize fulfillment flows using the Amazon Selling Partner API (SP-API).

    Key Learning Goals:

    • Master SP-API Orders and Shipping operations.
    • Debug shipping label purchase workflows.
    • Validate order and shipment data integrity.
    • Troubleshoot address and rate ID issues.
    • Implement end-to-end shipping solutions.

    The Challenge: Using the notebook 00-buy-shipping-challenge.ipynb, you must debug a scenario where a seller is having issues purchasing and validating shipping labels. You will use the Orders API (v2026-01-01) (specifically getOrder with the includedData parameter) and the Shipping API to identify errors in order IDs, item identifiers, addresses, rate IDs, and label formats.

  3. Overview of Amazon Data Kiosk Common Library

    main
    The common package provides shared utilities and core functionality designed for use by Amazon Data Kiosk MCP servers, specifically the Amazon Vendor Analytics MCP Server and the Amazon Seller Analytics MCP Server. It centralizes logic for interacting with Amazon's Selling Partner API (SP-API) and provides standardized helpers to ensure consistency across different analytics servers.
  4. Overview of FBA Inbound Sample Solution (Small Parcel Delivery)

    main

    The FBA Inbound Sample Solution App is a fully functional SP-API application designed to automate the creation and management of inbound shipments using the Fulfillment By Amazon (FBA) Inbound API v2024-03-20.

    This specific implementation targets Small Parcel Delivery (SPD - individual boxes) using the Amazon Partnered Carrier (PCP) transportation option. It is intended for sellers who want to automate inventory shipping workflows.

    Key Capabilities

    • Inbound Plan Creation: Specify SKUs and quantities for shipping inventory.
    • Packing Selection: Choose from available packing options.
    • Placement Selection: Select cost-effective placement for inventory.
    • Carrier Selection: Automatically select Amazon's partnered carrier for SPD.
    • Labels & Tracking: Generate FBA box and carrier shipping labels and monitor progress.

    Project Structure

    • App Folder: Contains AWS Step Function definitions, deployment templates, and infrastructure deployment scripts.
    • Code Folder: Contains the Java code used to interact with the FBA Inbound API, including sample inputs for shipments, labels, and carrier management.
  5. Overview of the LWA Credential Rotation Sample Solution

    main

    This sample solution provides a complete AWS deployment to implement the Login with Amazon (LWA) Credential Rotation workflow using the Amazon Selling Partner API (SP-API) Application Management API.

    It automates the process of reacting to APPLICATION_OAUTH_CLIENT_SECRET_EXPIRY notifications and rotating credentials via the APPLICATION_OAUTH_CLIENT_NEW_SECRET notification.

    Core Components:

    • SQS Queues: Two queues used to receive notifications for expiring secrets (LWASecretExpiry) and new secrets (LWANewSecret).
    • Lambda Functions:
      • RotateSecretsHandler: Triggered by expiring secret notifications. It verifies the client ID and, if the secret is within a 7-day threshold, calls the Application Management API to rotate the secret.
      • UpdateSecretsHandler: Triggered by new secret notifications. It verifies the client ID and updates the credentials in AWS Secrets Manager.
    • AWS Secrets Manager: Used to securely store the SP-API credentials.
  6. Overview of the Fulfillment Outbound Sample Solution

    main

    This sample solution provides a complete AWS deployment for a fully functional Selling Partner API (SP-API) application implementing the Fulfillment Outbound use case. It is designed for testing proposed solutions, making modifications, or integrating the logic into your own products.

    The solution implements three specific workflows:

    1. Create order: Reacts to SQS notifications to create an order in HOLD status, retrieves preview details, and eventually updates it to SHIP status.
    2. Get package tracking details: Reacts to FULFILLMENT_ORDER_STATUS notifications to retrieve order information and package tracking details.
    3. Cancel order: Reacts to SQS notifications to execute an order cancellation via a Step Functions state machine.
  7. Overview of FBA Inbound API v2024-03-20 Sample Solution

    main

    The FBA Inbound Sample Solution App is a fully functional application designed to implement the Fulfillment By Amazon (FBA) Inbound API v2024-03-20 end-to-end. It is specifically built for sellers automating inbound shipments using a Pack Later workflow.

    Target Use Case

    • Flow: Pallet (LTL/FTL) Delivery.
    • Transportation: Non-Partnered Carrier (nPCP).
    • Constraint: The seller does not know carton information upfront at the start of the process, allowing for flexible packing decisions later in the workflow.

    Key Capabilities

    • Inbound Plan Creation: Define SKU items and quantities.
    • Placement Selection: Generate, list, and select the most cost-effective placement options.
    • Packing Selection: Specify which items are packed into which boxes per shipment.
    • Delivery & Carrier Selection: Choose delivery windows and select non-partnered carriers for pallet delivery.
    • Shipping Details & Labels: Provide shipping details and generate FBA box/pallet labels.
    • Update Tracking: Provide carrier-provided tracking information to Amazon.
  8. Overview of Vendor Direct Fulfillment Sample Solution

    main

    This sample solution provides a complete AWS deployment for an Amazon Selling Partner API (SP-API) application implementing the Vendor Direct Fulfillment (DF) use case.

    It automates a DF order workflow: pulling new orders, acknowledging them, checking transaction status, and generating shipping labels.

    Core Components:

    • AWS Step Functions: Orchestrates the DF workflow state machine.
    • AWS Lambda: Executes individual steps of the workflow.
    • Amazon DynamoDB: Stores Order and Order Item data.
    • Amazon S3: Stores generated shipping labels.
    • Amazon SNS: Sends email notifications for new labels or failed shipment confirmations.
    • AWS Secrets Manager: Securely stores SP-API application credentials.
  9. Overview of the Sample SP-API Notification Solution

    main

    The Sample SP-API Notification Solution is an end-to-end event-driven application designed to deploy a pipeline for handling Amazon Selling Partner API (SP-API) notifications. It automates the registration of credentials, EventBridge configuration, infrastructure provisioning via AWS CDK, and deployment of application logic to AWS Lambda.

    Core Components

    • Infrastructure Stack (CDK): Deploys Lambda, SQS, EventBridge, IAM roles, DynamoDB, and S3 buckets.
    • Lambda Functions: Handles notification registration/deregistration, event processing, and forwarding to external platforms.
    • AWS Step Functions: Manages workflows for document retrieval and processing.
    • AWS Secrets Manager: Stores SP-API credentials for each seller.

    Workflow Summary

    1. Securely register a CSV containing seller credentials in Secrets Manager.
    2. Create and register EventBridge Destinations using grantless tokens if necessary.
    3. Upload Step Functions definition files to S3.
    4. Deploy the entire CDK application based on configuration files and secret definitions.
    5. Call Lambda to register subscriptions for specific notification types after deployment.