Integration of Online Store with eBay (API)
eBay provides several APIs: Trading API (legacy), Sell API (modern REST). For new integrations, we use Sell API. Relevant for sellers working on international markets: US, UK, DE, AU.
Authentication (OAuth2)
import requests
import base64
def get_access_token(client_id: str, client_secret: str) -> str:
credentials = base64.b64encode(f"{client_id}:{client_secret}".encode()).decode()
resp = requests.post(
'https://api.ebay.com/identity/v1/oauth2/token',
headers={'Authorization': f'Basic {credentials}'},
data={
'grant_type': 'client_credentials',
'scope': 'https://api.ebay.com/oauth/api_scope',
}
)
return resp.json()['access_token']
Creating Listing via Inventory API
def create_inventory_item(sku: str, product: dict, token: str) -> None:
headers = {'Authorization': f'Bearer {token}', 'Content-Language': 'de-DE'}
# Creating inventory item
requests.put(
f'https://api.ebay.com/sell/inventory/v1/inventory_item/{sku}',
headers=headers,
json={
'availability': {'shipToLocationAvailability': {'quantity': product['stock']}},
'condition': 'NEW',
'product': {
'title': product['name'],
'description': product['description'],
'imageUrls': product['images'],
'aspects': {'Brand': [product['brand']]},
'ean': [product['ean']],
},
}
)
# Creating offer (listing)
requests.post(
'https://api.ebay.com/sell/inventory/v1/offer',
headers=headers,
json={
'sku': sku,
'marketplaceId': 'EBAY_DE',
'format': 'FIXED_PRICE',
'pricingSummary': {
'price': {'value': str(product['price']), 'currency': 'EUR'}
},
'fulfillmentPolicyId': FULFILLMENT_POLICY_ID,
'paymentPolicyId': PAYMENT_POLICY_ID,
'returnPolicyId': RETURN_POLICY_ID,
'merchantLocationKey': WAREHOUSE_KEY,
'categoryId': product['ebay_category_id'],
}
)
Getting Orders
def get_orders(token: str, since: str) -> list:
resp = requests.get(
'https://api.ebay.com/sell/fulfillment/v1/order',
headers={'Authorization': f'Bearer {token}'},
params={'filter': f'creationdate:[{since}..{datetime.utcnow().isoformat()}Z]', 'limit': 50}
)
return resp.json().get('orders', [])
eBay Notifications
// eBay Platform Notifications handler
Route::post('/webhooks/ebay', function (Request $request) {
// eBay sends XML notifications
$xml = simplexml_load_string($request->getContent());
$eventType = (string) $xml->BuyerUserID; // depends on notification type
// ... processing
return response('');
});
Timeline
Registration in eBay Developer Program: 1–3 days. Integration (listings + orders): 14–20 business days.







