Authorization
The base URI for the Seller Center REST API is https://sellercenter-api.[your-instance]/.
Seller Center REST API is not publicly accessible. All requests have to use authentication parameters. Seller Center provides a standard OAuth2 authentication/authorization server. API user needs to be authorized first and send access key as Authorization Bearer header in each request.
Step 1 - Create a new application
Create a new application in Seller Center at > Settings > OAuth Applications - https://sellercenter.[your-instance]/new/settings/integration-management/oauths.
Step 2 - Generate a new access token
To generate an access token, your application needs to send a POST request to the Seller Center OAuth server:
- Endpoint: https://sellercenter.[your-instance]/oauth/client-credentials
- Method:
POST - Payload:
grant_type=client_credentials - Authorization:
Basic base64(application_id:application_secret)
import base64
import requests
app_id = 'your_app_id'
app_secret = 'your_app_secret'
token = base64.b64encode(f'{app_id}:{app_secret}'.encode()).decode()
response = requests.post(
'https://sellercenter.[your-instance]/oauth/client-credentials',
headers={
'Authorization': f'Basic {token}'
},
data={
'grant_type': 'client_credentials'
}
)
data = response.json()
print(data)The response of this POST request contains an access_token needed for next step.
The response includes an expires_in field with a value of 3600, indicating the token will expire after 3600 seconds (1 hour).
Step 3 - Request the Seller Center REST API
Make sure that the user is provided with proper permissions to perform the API operation (read, write, delete, etc). From permission perspective, a seller integration application should be created by a user with Seller Full Access Role. Build your request to any resource of the Seller Center REST API and add the following Header for Authorization:
import requests
# Get the access token from the previous step
access_token = data["access_token"]
url = "https://sellercenter-api.[your-instance]/v2/<target-api>"
response = requests.post(
url,
headers={
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
},
json={} # Add your request body here
)
print(response.json())