Amazon Selling Partner API (SP-API) Samples
repository·main·Indexed 41 days ago
https://github.com/amzn/selling-partner-api-samplesA 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.
What's inside Selling Partner API Samples
- 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.
Overview of the Shipping Guru Workshop
mainThe 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) (specificallygetOrderwith theincludedDataparameter) and the Shipping API to identify errors in order IDs, item identifiers, addresses, rate IDs, and label formats.Overview of the Merchant Fulfillment API
mainThe Merchant Fulfillment API enables applications to allow sellers to use Amazon's Buy Shipping Services for both Prime and non-Prime orders.
Key capabilities include:
- Previewing shipping service offers based on specific shipping requirements.
- Creating shipments.
- Automatically paying for shipping.
- Receiving and printing shipping labels.
Overview of Amazon Data Kiosk Common Library
mainThecommonpackage 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.Overview of FBA Inbound Sample Solution (Small Parcel Delivery)
mainThe 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.
Overview of the Merchant Fulfillment Sample Solution
mainThe Merchant Fulfillment Sample Solution is a fully functional SP-API application designed to implement the Merchant Fulfillment use case end-to-end on AWS. It serves as a testing ground for developers to validate proposed solutions, make modifications, or integrate the workflow into their own products.Overview of the LWA Credential Rotation Sample Solution
mainThis 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_EXPIRYnotifications and rotating credentials via theAPPLICATION_OAUTH_CLIENT_NEW_SECRETnotification.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.
- SQS Queues: Two queues used to receive notifications for expiring secrets (
Overview of Fulfillment Inbound API v2024-03-20
mainThe Fulfillment Inbound API (v2024-03-20) allows sellers to automate and manage inbound shipping processes to Amazon's fulfillment network. It is designed to integrate with the Send-to-Amazon (STA) feature in the Seller Central User Interface. This API is used for streamlining inventory management and shipping operations.Overview of the Fulfillment Outbound Sample Solution
mainThis 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:
- Create order: Reacts to SQS notifications to create an order in
HOLDstatus, retrieves preview details, and eventually updates it toSHIPstatus. - Get package tracking details: Reacts to
FULFILLMENT_ORDER_STATUSnotifications to retrieve order information and package tracking details. - Cancel order: Reacts to SQS notifications to execute an order cancellation via a Step Functions state machine.
- Create order: Reacts to SQS notifications to create an order in
Overview of FBA Inbound API v2024-03-20 Sample Solution
mainThe 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.
Overview of Vendor Direct Fulfillment Sample Solution
mainThis 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.
Overview of the Sample SP-API Notification Solution
mainThe 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
- Securely register a CSV containing seller credentials in Secrets Manager.
- Create and register EventBridge Destinations using grantless tokens if necessary.
- Upload Step Functions definition files to S3.
- Deploy the entire CDK application based on configuration files and secret definitions.
- Call Lambda to register subscriptions for specific notification types after deployment.