API Entegrasyon

n11 Entegrasyonu: API ile Ürün ve Sipariş Senkronizasyonu

n11.com marketplace'ine API entegrasyonu. Ürün aktarımı (XML/JSON), real-time stok senkronizasyonu, otomatik sipariş alma ve kargo bildirimi için kapsamlı teknik rehber ve kod örnekleri.

📅 16 Şubat 2026⏱️ 11 dakika

🔌n11 API Başlangıç

n11 API v3.0, satıcıların kendi sistemlerinden n11'e ürün yüklemesi, stok güncelleme, sipariş ve kargo yönetimi yapmasını sağlar. SOAP tabanlıdır (XML).

API Anahtarı Alma

Adımlar:

  1. 1. n11 Satıcı Hesabı: n11.com/magaza-ac adresinden başvuru
  2. 2. Onay Süreci: Belge kontrolü (1-3 gün)
  3. 3. API Anahtarı: Satıcı paneli → Ayarlar → API Bilgileri
  4. 4. Credentials: API Key + Secret Key (güvenli sakla)

Temel API Bilgileri

# n11 API Endpoints (Production)
Base URL: https://api.n11.com/ws

# Ana Servisler:
1. ProductService          # Ürün işlemleri
2. OrderService            # Sipariş yönetimi
3. CategoryService         # Kategori listesi
4. ShipmentService         # Kargo işlemleri
5. SettlementService       # Ödeme/hesap özeti

# Authentication
API Key: xxxxx-xxxxx-xxxxx-xxxxx
Secret Key: yyyyyyyyyyyy

📦Ürün Aktarımı

Tek Ürün Ekleme (SOAP/XML)

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:sch="http://www.n11.com/ws/schemas">
  <soapenv:Header/>
  <soapenv:Body>
    <sch:SaveProductRequest>
      <auth>
        <appKey>your-api-key</appKey>
        <appSecret>your-secret-key</appSecret>
      </auth>
      <product>
        <productSellerCode>LAPTOP-001</productSellerCode>
        <title>Dell XPS 13 Laptop</title>
        <subtitle>Intel i7, 16GB RAM, 512GB SSD</subtitle>
        <description>
          <![CDATA[
            <p>Dell XPS 13 özellikleri:</p>
            <ul>
              <li>Intel Core i7 işlemci</li>
              <li>16GB RAM</li>
              <li>512GB NVMe SSD</li>
            </ul>
          ]]>
        </description>
        <category>
          <id>1000265</id> <!-- Laptop kategorisi -->
        </category>
        <price>45000</price>
        <currencyType>TL</currencyType>
        <images>
          <image>
            <url>https://example.com/dell-xps-1.jpg</url>
            <order>1</order>
          </image>
          <image>
            <url>https://example.com/dell-xps-2.jpg</url>
            <order>2</order>
          </image>
        </images>
        <stockItems>
          <stockItem>
            <quantity>50</quantity>
            <sellerStockCode>LAPTOP-001-GRAY</sellerStockCode>
            <attributes>
              <attribute>
                <name>Renk</name>
                <value>Gri</value>
              </attribute>
            </attributes>
          </stockItem>
        </stockItems>
        <shipmentTemplate>Ücretsiz Kargo</shipmentTemplate>
      </product>
    </sch:SaveProductRequest>
  </soapenv:Body>
</soapenv:Envelope>

PHP ile Ürün Ekleme

<?php
// n11 SOAP Client
$client = new SoapClient("https://api.n11.com/ws/ProductService.wsdl");

$auth = [
    'appKey' => 'your-api-key',
    'appSecret' => 'your-secret-key'
];

$product = [
    'productSellerCode' => 'LAPTOP-001',
    'title' => 'Dell XPS 13 Laptop',
    'subtitle' => 'Intel i7, 16GB RAM, 512GB SSD',
    'description' => '<p>Dell XPS 13 özellikleri...</p>',
    'category' => ['id' => 1000265],
    'price' => 45000,
    'currencyType' => 'TL',
    'images' => [
        'image' => [
            ['url' => 'https://example.com/dell-xps-1.jpg', 'order' => 1],
            ['url' => 'https://example.com/dell-xps-2.jpg', 'order' => 2]
        ]
    ],
    'stockItems' => [
        'stockItem' => [
            [
                'quantity' => 50,
                'sellerStockCode' => 'LAPTOP-001-GRAY',
                'attributes' => [
                    'attribute' => [
                        ['name' => 'Renk', 'value' => 'Gri']
                    ]
                ]
            ]
        ]
    ],
    'shipmentTemplate' => 'Ücretsiz Kargo'
];

$params = [
    'auth' => $auth,
    'product' => $product
];

try {
    $response = $client->SaveProduct($params);

    if($response->result->status == 'success') {
        echo "Ürün başarıyla eklendi! ID: " . $response->product->id;
    } else {
        echo "Hata: " . $response->result->errorMessage;
    }
} catch(Exception $e) {
    echo "SOAP Hatası: " . $e->getMessage();
}
?>

Toplu Ürün Yükleme (Batch)

n11 API, tek seferde 100 ürün yüklemeye izin verir. Daha fazlası için döngü kullanın.

  • Rate Limit: Dakikada 60 istek (1 istek/saniye)
  • Batch Size: Maksimum 100 ürün/istek
  • Önerilen: 50 ürün/istek (hata toleransı için)
  • Retry Logic: Başarısız ürünleri tekrar dene

🔄Stok Senkronizasyonu

Stok Güncelleme Stratejileri

1. Real-Time (Anında)

Her satışta anında n11'e bildir

%100 doğru stok
Yüksek API kullanımı

2. Batch (Toplu)

Her 15 dakikada bir toplu güncelleme

Az API kullanımı
15 dakika gecikme

3. Hybrid (Önerilen)

Kritik: Real-time, Diğer: Batch

Dengeli
Optimal

Stok Güncelleme Kodu

<?php
// Stok güncelleme fonksiyonu
function updateN11Stock($productCode, $newQuantity) {
    $client = new SoapClient("https://api.n11.com/ws/ProductService.wsdl");

    $params = [
        'auth' => [
            'appKey' => 'your-api-key',
            'appSecret' => 'your-secret-key'
        ],
        'stockItems' => [
            'stockItem' => [
                [
                    'sellerStockCode' => $productCode,
                    'quantity' => $newQuantity
                ]
            ]
        ]
    ];

    $response = $client->UpdateStockByStockSellerCode($params);
    return $response->result->status == 'success';
}

// Toplu stok güncelleme (her 15 dakika)
function batchUpdateStock($products) {
    $stockItems = [];

    foreach($products as $product) {
        $stockItems[] = [
            'sellerStockCode' => $product['code'],
            'quantity' => $product['stock']
        ];

        // n11 limit: 100 ürün/istek
        if(count($stockItems) >= 100) {
            sendBatchUpdate($stockItems);
            $stockItems = [];
            sleep(1); // Rate limit
        }
    }

    if(!empty($stockItems)) {
        sendBatchUpdate($stockItems);
    }
}

// Webhook: Kendi sitenizde sipariş olduğunda
function onOrderCreated($orderItems) {
    foreach($orderItems as $item) {
        // n11'de stok düş (real-time)
        $currentStock = getN11Stock($item['sku']);
        updateN11Stock($item['sku'], $currentStock - $item['quantity']);
    }
}
?>

📋Sipariş Yönetimi

Sipariş Alma (Polling)

<?php
// Her 5 dakikada bir yeni siparişleri çek
function getNewOrders() {
    $client = new SoapClient("https://api.n11.com/ws/OrderService.wsdl");

    $params = [
        'auth' => [
            'appKey' => 'your-api-key',
            'appSecret' => 'your-secret-key'
        ],
        'searchData' => [
            'status' => 'Approved', // Onaylı siparişler
            'period' => [
                'startDate' => date('d/m/Y', strtotime('-1 day')),
                'endDate' => date('d/m/Y')
            ]
        ],
        'pagingData' => [
            'currentPage' => 0,
            'pageSize' => 100
        ]
    ];

    $response = $client->OrderList($params);

    if($response->result->status == 'success') {
        foreach($response->orderList->order as $order) {
            processOrder($order);
        }
    }
}

function processOrder($n11Order) {
    // 1. Kendi veritabanına kaydet
    $orderId = saveToDatabase([
        'n11_order_id' => $n11Order->id,
        'customer_name' => $n11Order->recipient->fullName,
        'total' => $n11Order->totalAmount,
        'items' => $n11Order->itemList->item
    ]);

    // 2. Stok düş
    foreach($n11Order->itemList->item as $item) {
        decreaseStock($item->sellerStockCode, $item->quantity);
    }

    // 3. Kargo hazırla
    prepareShipment($orderId);
}

// Cron job: Her 5 dakika
// */5 * * * * php /path/to/get-n11-orders.php
?>

Kargo Bildirimi

<?php
// Kargo bilgilerini n11'e bildir
function notifyShipment($n11OrderId, $trackingNumber, $cargoCompany) {
    $client = new SoapClient("https://api.n11.com/ws/OrderService.wsdl");

    $params = [
        'auth' => [
            'appKey' => 'your-api-key',
            'appSecret' => 'your-secret-key'
        ],
        'orderItemList' => [
            'orderItem' => [
                [
                    'id' => $n11OrderId,
                    'shipmentInfo' => [
                        'shipmentCompany' => $cargoCompany, // "Yurtiçi Kargo"
                        'trackingNumber' => $trackingNumber,
                        'shipmentMethod' => 'Kargo'
                    ]
                ]
            ]
        ]
    ];

    $response = $client->OrderItemShipment($params);

    if($response->result->status == 'success') {
        echo "Kargo bildirimi başarılı!";
        // n11 müşteriye SMS gönderir
    } else {
        echo "Hata: " . $response->result->errorMessage;
    }
}

// Örnek kullanım
notifyShipment(
    123456789,              // n11 sipariş ID
    "7894561230",          // Takip numarası
    "Yurtiçi Kargo"        // Kargo firması
);
?>

⚠️Hata Yönetimi ve Best Practices

Yaygın Hatalar

Error 1001: Geçersiz API Key
Çözüm: Credentials kontrol et
Error 2003: Kategori bulunamadı
Çözüm: CategoryService ile doğru ID al
Error 3005: Stok kodu mevcut
Çözüm: Unique SKU kullan

Best Practices

  • Retry Logic: 3 deneme, exponential backoff
  • Logging: Tüm API çağrılarını logla
  • Cache: Kategori listesi gibi statik veriyi cache'le
  • Queue: Toplu işlemleri queue'ya at
  • Monitoring: API health check (her 5 dk)
  • Testing: Test environment kullan

n11 Entegrasyonunuzu Profesyonelce Kuralım

Otomatik ürün senkronizasyonu, real-time stok güncelleme ve sipariş yönetimi ile n11'de satışlarınızı artırın.

Ücretsiz Demo