Trendyol API

Trendyol Entegrasyonu: Satıcı API Rehberi

Trendyol Partner API ile ürün yükleme, stok güncelleme, sipariş yönetimi ve kargo entegrasyonu. Toplu ürün aktarımı, real-time senkronizasyon ve kod örnekleri.

🚀Trendyol Partner API Başlangıç

Trendyol Partner API, satıcıların ürün, stok, sipariş ve kargo işlemlerini otomatik yönetmesini sağlar. RESTful API (JSON) kullanır.

# Trendyol API Base URL
Production: https://api.trendyol.com/sapigw

# Authentication
Bearer Token: Satıcı panelinden alınır

# Temel Endpoint'ler:
POST   /suppliers/{supplierId}/products          # Ürün ekle
PUT    /suppliers/{supplierId}/products          # Ürün güncelle
GET    /suppliers/{supplierId}/orders            # Sipariş listesi
POST   /suppliers/{supplierId}/shipment-packages # Kargo bildir

# Rate Limit: 100 istek/dakika

Tedarikçi Numarası ve API Key

1. Trendyol Satıcı Paneli → Entegrasyon → API Entegrasyonu
2. "API Key" ve "Tedarikçi ID" (supplierId) kopyala
3. Test environment'ta dene, sonra production'a geç

Ürün Yükleme

# Python ile Trendyol'e ürün ekleme
import requests
import json

API_URL = "https://api.trendyol.com/sapigw"
SUPPLIER_ID = "12345"
API_KEY = "your-api-key"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

product = {
    "items": [{
        "barcode": "8690000000001",
        "title": "Dell XPS 13 Laptop",
        "productMainId": "1234-XPS13",
        "brandId": 1791,  # Dell brand ID
        "categoryId": 2052,  # Laptop category
        "quantity": 50,
        "stockCode": "LAPTOP-XPS-001",
        "dimensionalWeight": 2.5,
        "description": "Intel i7, 16GB RAM, 512GB SSD",
        "currencyType": "TRY",
        "listPrice": 50000,
        "salePrice": 45000,
        "vatRate": 18,
        "cargoCompanyId": 10,  # Yurtiçi Kargo
        "images": [
            {"url": "https://cdn.example.com/image1.jpg"},
            {"url": "https://cdn.example.com/image2.jpg"}
        ],
        "attributes": [
            {"attributeId": 338, "attributeValueId": 76662},  # Renk: Gri
            {"attributeId": 346, "customAttributeValue": "512GB"}  # Disk
        ]
    }]
}

response = requests.post(
    f"{API_URL}/suppliers/{SUPPLIER_ID}/v2/products",
    headers=headers,
    json=product
)

if response.status_code == 200:
    print("Ürün başarıyla eklendi!")
    print(response.json())
else:
    print(f"Hata: {response.status_code}")
    print(response.text)

Stok ve Fiyat Güncelleme

# Toplu stok güncelleme (batch)
def update_stock_batch(items):
    """
    items = [
        {"barcode": "8690000000001", "quantity": 45},
        {"barcode": "8690000000002", "quantity": 30},
    ]
    """
    url = f"{API_URL}/suppliers/{SUPPLIER_ID}/products/price-and-inventory"

    payload = {"items": items}

    response = requests.post(url, headers=headers, json=payload)
    return response.json()

# Fiyat güncelleme
def update_price(barcode, list_price, sale_price):
    items = [{
        "barcode": barcode,
        "listPrice": list_price,
        "salePrice": sale_price,
        "quantity": None  # Stok değiştirme
    }]
    return update_stock_batch(items)

Sipariş Yönetimi

# Sipariş listesi çekme
def get_orders(start_date, end_date, status="Created"):
    """
    status: Created, Picking, Invoiced, Shipped, Delivered, Cancelled
    """
    url = f"{API_URL}/suppliers/{SUPPLIER_ID}/orders"

    params = {
        "startDate": start_date,  # timestamp (milisaniye)
        "endDate": end_date,
        "status": status,
        "page": 0,
        "size": 200
    }

    response = requests.get(url, headers=headers, params=params)
    return response.json()

# Kargo bildirimi
def notify_shipment(order_id, tracking_number):
    url = f"{API_URL}/suppliers/{SUPPLIER_ID}/shipment-packages"

    payload = {
        "shipmentPackages": [{
            "orderNumber": order_id,
            "trackingNumber": tracking_number,
            "invoiceDate": int(time.time() * 1000),
            "invoiceNumber": f"INV-{order_id}"
        }]
    }

    response = requests.post(url, headers=headers, json=payload)
    return response.json()

Trendyol Entegrasyonunuzu Kuralım

Otomatik ürün yükleme, stok senkronizasyonu ve sipariş yönetimi ile Trendyol satışlarınızı artırın.

Demo İste