import { axios } from "@pipedream/platform"
export default defineComponent({
props: {
amazon_selling_partner: {
type: "app",
app: "amazon_selling_partner",
}
},
async run({steps, $}) {
// Define the mapping between Seller Central URLs (from your App Config) and SP-API Endpoints
const getEndpoint = (sellerCentralUrl) => {
const na = "https://sellingpartnerapi-na.amazon.com";
const eu = "https://sellingpartnerapi-eu.amazon.com";
const fe = "https://sellingpartnerapi-fe.amazon.com";
const map = {
// North America
"https://sellercentral.amazon.com": na,
"https://sellercentral.amazon.ca": na,
"https://sellercentral.amazon.com.mx": na,
"https://sellercentral.amazon.com.br": na,
// Europe (The Big 5 often share one URL, but newer ones have specific URLs)
"https://sellercentral-europe.amazon.com": eu,
"https://sellercentral.amazon.com.be": eu,
"https://sellercentral.amazon.nl": eu,
"https://sellercentral.amazon.pl": eu,
"https://sellercentral.amazon.se": eu,
"https://sellercentral.amazon.com.tr": eu,
// India (Uses EU endpoint)
"https://sellercentral.amazon.in": eu,
// Far East
"https://sellercentral.amazon.sg": fe,
"https://sellercentral.amazon.com.au": fe,
"https://sellercentral.amazon.co.jp": fe,
};
return map[sellerCentralUrl];
};
// 1. Get the Marketplace URL selected by the user in the App Connection
const marketplaceUrl = this.amazon_selling_partner.$auth.marketplace;
// 2. Resolve the correct SP-API Endpoint
const apiEndpoint = getEndpoint(marketplaceUrl);
if (!apiEndpoint) {
throw new Error(`Could not map Seller Central URL (${marketplaceUrl}) to an SP-API Endpoint.`);
}
// 3. Make the request
return await axios($, {
url: `${apiEndpoint}/inbound/fba/2024-03-20/inboundPlans`,
headers: {
"x-amz-access-token": `${this.amazon_selling_partner.$auth.oauth_access_token}`,
},
});
},
})
Emit new event when a new inbound shipment to FBA is created. See the documentation
Emit new event when a new order is created in Amazon Seller Central. See the documentation
Retrieves inventory summaries from Amazon fulfillment centers to monitor stock availability. See the documentation
Retrieves a list of orders based on a specified date range, buyer email, or order ID. See the documentation
Requests reports on sales, inventory, and fulfillment performance. See the documentation
Fetches detailed information about a specific order using its order ID. See the documentation
Fetches inbound shipment details to track stock movement and replenishment. See the documentation
Selling Partner API (SP-API) uses OAuth authentication. When you connect your Selling Partner API (SP-API) account, Pipedream will open a popup window where you can sign into Selling Partner API (SP-API) and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any Selling Partner API (SP-API) API.
Pipedream requests the following authorization scopes when you connect your account:
GET{{custom_fields.marketplace}}/apps/authorize/consent?application_id=amzn1.sp.solution.b94814bf-a133-46bf-af1c-439f0ede5661&state={{oauth.state}}&redirect_uri={{oauth.redirect_uri}}&response_type=code&scope={{oauth.space_separated_scopes}}&version=beta&client_id={{oauth.client_id}}POSThttps://api.amazon.com/auth/o2/token?grant_type=authorization_code&code={{oauth.code}}&redirect_uri={{oauth.redirect_uri}}&client_id={{oauth.client_id}}&client_secret={{oauth.client_secret}}content-type: application/x-www-form-urlencodedaccept: application/jsonPOSThttps://api.amazon.com/auth/o2/token?grant_type=refresh_token&refresh_token={{oauth.refresh_token}}&client_id={{oauth.client_id}}&client_secret={{oauth.client_secret}}content-type: application/x-www-form-urlencodedaccept: application/json