Key takeaways:

  • The SP-API is a door into your Seller Central data that computer programs can use instead of people clicking around.
  • To open it you need four things: a developer registration, an app with a client ID and client secret, a refresh token, and a short-lived access token.
  • Your first call is three steps: swap the refresh token for an access token, build the web address, and add four headers.
  • Every operation has a speed limit. If you go too fast you get error 429. The fix is to wait a little longer each time and try again.

The SP-API in one minute

Imagine Seller Central is a big shop. You walk in through the front door, look at the shelves and write things down. That works, but it is slow, and you have to do it every day.

The Selling Partner API (SP-API) is a back door into the same shop, built for computer programs. A program can knock on that door, show a pass, ask "what did I sell yesterday?" and get the answer in a second. It can also make changes, such as updating a price or a listing, if you allow it to.

If you want the bigger picture first (what data the SP-API gives you and how permissions work), read Amazon SP-API explained. This guide is the hands-on part: how to actually connect and make your first call.

The four things you need

Think of it like going to a members-only library:

Library SP-API What it is
Membership form Developer registration You tell Amazon who you are and what data you need. Amazon reviews it.
Your name and secret password at the desk Client ID and client secret The username and password of your app.
Your library card Refresh token Proves Seller Central allowed your app in. It lasts a long time.
Today's day pass Access token Lets you in for one hour. You get a new one with your card whenever it runs out.
Read this flowchart as text
  1. 1. Register as a developer
  2. 2. Create an app client ID and secret
  3. 3. Authorize the app get a refresh token
  4. 4. Swap refresh token for access token
  5. 5. Call the SP-API with 4 headers
  6. Data back as JSON

Steps 1 to 3 you do once, by hand. Steps 4 and 5 your program does by itself, every time it runs.

Step 1: Register as a private developer

A private developer is a seller who builds tools only for their own business. That is what you want if the program will only ever touch your own account. (A public developer builds apps for other sellers, which needs a longer review.)

  1. Sign in to Seller Central as the Primary User of the account.
  2. Open the menu, choose Apps and Services, then Develop Apps. (If your account has already moved to the Solution Provider Portal, sign in there and go to Settings, then Developer Profile.)
  3. Fill in the form: contact details, then under Data Access choose Private Developer: I build application(s) that integrate my own company with Amazon Services APIs.
  4. Tick only the Roles you need. A role is a group of data, such as Product Listing, Pricing, Inventory and Order Tracking, or Brand Analytics. Asking for less makes the review easier.
  5. Describe your use cases honestly ("daily sales report to email", "low-stock alert") and your security controls (where you keep keys, who can see them).
  6. Accept the agreements and choose Register.

Amazon reviews the profile and opens a case. Watch the admin email on the account: if Amazon asks a question, you must answer within five days or the case closes.

Step 2: Create your app and find its keys

Once you are approved, go back to Develop Apps and choose Add new app client. Give it a name, pick the API type (SP-API) and the roles it needs.

Your new app now has a client ID and a client secret (choose View next to "LWA credentials"). LWA means Login with Amazon, the system that hands out the passes.

Treat the client secret like a bank password:

  • Never paste it into a spreadsheet, a chat or an email.
  • Never put it in code that runs in a web browser.
  • Keep it in a password manager or your hosting's secret store, and read it from there.

Amazon makes you replace (rotate) client secrets from time to time and emails you before they expire, so put a reminder in your calendar too.

Step 3: Authorize the app and get a refresh token

Your app exists, but it has not been let into your shop yet. For a private app, you let it in yourself. This is called self-authorization, and the app can stay in draft: there is no reason to publish a private app.

  1. On the Develop Apps page, find your app.
  2. Choose Authorize app next to it, then Authorize app for the account you want it to read.
  3. A refresh token appears. It starts with Atzr|. Copy it straight into your secret store.

Each time you press Authorize app you get a new refresh token, and the old ones keep working. If you sell in several regions with merged accounts, you see a button for each one.

Step 4: Swap the refresh token for an access token

Now the program takes over. Every time it starts, it sends the refresh token, client ID and client secret to Amazon's token server and gets back an access token that works for one hour.

Read this flowchart as text
  1. Program starts
  2. Have an access token younger than 55 minutes?
  3. Use it
  4. POST to api.amazon.com/auth/o2/token refresh token + client ID + secret
  5. Save the new access token and the time you got it

Here it is in Python. You need Python 3 and the requests library (pip install requests). The three secrets come from environment variables, so they never sit in the code.

import os, time, requests

def get_access_token():
    reply = requests.post(
        "https://api.amazon.com/auth/o2/token",
        data={
            "grant_type": "refresh_token",
            "refresh_token": os.environ["SPAPI_REFRESH_TOKEN"],
            "client_id": os.environ["SPAPI_CLIENT_ID"],
            "client_secret": os.environ["SPAPI_CLIENT_SECRET"],
        },
        timeout=30,
    )
    reply.raise_for_status()          # stop here if Amazon said no
    return reply.json()["access_token"]   # starts with "Atza|", lasts 3600 seconds

Step 5: Make your first call

A good first call is getMarketplaceParticipations. It answers a simple question, "which Amazon stores am I selling in?", so if it works you know every piece is in place.

Every SP-API call is built from three parts:

  1. The endpoint, which depends on where your account lives:
    • North America (US, Canada, Mexico, Brazil): https://sellingpartnerapi-na.amazon.com
    • Europe, the Middle East, India and Africa: https://sellingpartnerapi-eu.amazon.com
    • Far East (Japan, Australia, Singapore): https://sellingpartnerapi-fe.amazon.com
  2. The path of the operation: /sellers/v1/marketplaceParticipations
  3. Four headers, the labels on the envelope:
    • host: the endpoint's name
    • x-amz-access-token: the access token from step 4
    • x-amz-date: the date and time now, in UTC
    • user-agent: your app's name, version and language, for example WeSparkReport/1.0 (Language=Python)
from datetime import datetime, timezone

def first_call():
    token = get_access_token()
    reply = requests.get(
        "https://sellingpartnerapi-na.amazon.com/sellers/v1/marketplaceParticipations",
        headers={
            "x-amz-access-token": token,
            "x-amz-date": datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ"),
            "user-agent": "MyFirstSPAPIApp/1.0 (Language=Python)",
        },
        timeout=30,
    )
    print(reply.status_code)
    print(reply.json())

first_call()

The requests library fills in host for you. If you see 200 and a list of stores with your store name, you are connected. You no longer need an AWS account or AWS request signing for this: the access token is the pass.

What the answers mean

You see It means What to do
200 It worked Read the payload part of the JSON.
400 Something in the request is missing or wrong Check the path and any IDs, such as the marketplace ID.
403 Amazon doesn't trust the pass The access token expired, the app lacks the role, or the wrong region's endpoint was used.
404 That thing doesn't exist Check the ASIN, SKU or order ID.
429 Too fast Slow down and retry (see the next section).
500 or 503 Amazon had a problem Wait a little and retry.

Every response also carries an x-amzn-RequestId header. Log it: if you ever need help from Amazon, that ID is the first thing they ask for.

Rate limits: the sweet jar

Every SP-API operation has a speed limit, and Amazon explains it with a token bucket. Think of a jar of sweets:

  • The jar starts full. Each call eats one sweet.
  • Amazon drops new sweets into the jar at a steady speed. That speed is the rate.
  • The jar can only hold so many sweets. That size is the burst.
  • If the jar is empty when you call, you don't get in. That is error 429.

For getMarketplaceParticipations the default rate is 0.016 per second with a burst of 15. In plain words: you can make 15 calls quickly, and after that you get about one new call per minute. Other operations have very different limits, and some change with the size of your business, so always look up the Usage Plan table on each operation's page in Amazon's reference.

The response header x-amzn-RateLimit-Limit often tells you your current rate, but Amazon says not to depend on it: it doesn't appear on every response.

Read this flowchart as text
  1. Send the call
  2. Answer is 429, 500 or 503?
  3. Use the data
  4. Tried 5 times already?
  5. Stop and alert a person
  6. Wait: 2, 4, 8, 16 seconds plus a little random time

This waiting pattern is called exponential back-off: each wait is twice as long as the last, plus a little random extra so many programs don't all retry at the same moment. In Python:

import random

def call_with_retry(do_call, tries=5):
    for attempt in range(tries):
        reply = do_call()
        if reply.status_code not in (429, 500, 503):
            return reply
        time.sleep(2 ** (attempt + 1) + random.random())
    raise RuntimeError("SP-API still busy after retries, request ID: "
                       + reply.headers.get("x-amzn-RequestId", "none"))

Three habits keep you away from 429s most of the time:

  • Ask less often. Stock levels don't need checking every ten seconds.
  • Ask for more at once. Reports and Feeds return or send thousands of rows in one call, instead of one call per item. Our report automation guide shows how.
  • Listen instead of asking. Amazon's Notifications can tell your program when something changes, such as a price or an order, so it doesn't have to keep checking.

Calls that need an extra pass

Some operations return personal information, such as a buyer's name or address on an order. Those are restricted operations. For them, your program first asks the Tokens API for a Restricted Data Token (RDT) and sends that in the x-amz-access-token header instead of the normal access token. Your app also needs the matching role, and Amazon reviews those roles more strictly. If you don't need personal data, don't ask for it: your registration is simpler and the risk is lower.

Keeping it safe

  • Keep the client secret and refresh tokens in a secret store, never in code, logs or URLs.
  • Give each app only the roles it needs.
  • Log every change your program makes (what, when, old value, new value), so you can undo it.
  • Test new code in Amazon's sandbox first, which returns made-up data. The sandbox can test your 429 handling, but not real rate limits, because every sandbox operation shares the same rate.
  • Use one of Amazon's official SDKs (Python, Java, C#, JavaScript, PHP) once you move past your first test. They handle tokens and retries for you.

How we handle this with you

B21How changes reach your accountchanges made in bulk, validated before upload, and logged so you can trace every edit.

E12The numbers we work with

For most brands we build on a private SP-API app that you own, registered in your own Seller Central, so the keys and the data stay with you. We start with read-only roles (reports, stock, listings), set up token storage, retries and logging as shown above, and only add write access, such as price or listing updates, once the reports are trusted.

Rather not write the code yourself? WeSpark connects your Seller Central to the SP-API and builds the automations on top: daily reports, stock and listing alerts, and account health warnings, delivered to email or Slack. Builds are one-time and priced on your scope, with a fixed quote before we start. Book a free automation demo.

QUESTIONS

Frequently asked questions

Do I need to be a programmer to connect to the SP-API?

To follow this guide you only need to copy and run a short Python script. To build a reliable tool that runs every day, with retries, logging and safe storage of keys, you either learn a little more or work with a developer or agency.

Is the Amazon SP-API free to use?

There is no separate charge to call the SP-API for your own account today, beyond your selling plan. Amazon has announced and then withdrawn developer fees before, so check the current developer terms in the Solution Provider Portal before you rely on this.

Why do I get error 403 on my first call?

Usually one of four things: the access token is more than an hour old, the app doesn't have the role for that operation, you used the wrong region's endpoint, or the x-amz-access-token header is missing or misspelled. Get a fresh token and check each one.

What are the Amazon SP-API rate limits?

Each operation has its own rate (new requests per second) and burst (how many you can make at once). For example, getMarketplaceParticipations allows a burst of 15 and then about one call per minute. Look up the Usage Plan table on each operation's reference page, and handle error 429 by waiting longer between retries.