Hızlı Başlangıç

İlk ürününüzü oluşturup stoğunu güncelleyene kadar izlenecek yol. Her adım, bir önceki adımın döndürdüğü ID'yi kullanır.

Neden bu sırayla? Milagron API'de her referans ID ile verilir. Marka adı, kategori adı veya özellik adı göndermezsiniz. Bu ID'ler mağazanıza özeldir ve katalog uçlarından öğrenilir. Aşağıdaki sıra, ürün oluşturmak için gereken dört ID'yi doğru sırayla toplar: sellerId, brandId, categoryId, attributeId.

Adım 0: Kimlik Bilgileriniz

Milagron ekibinden üç değer alırsınız: sellerId, apiKey ve apiSecret. Tüm istekler HTTP Basic Auth ile imzalanır. URL'deki sellerId, anahtarınızın sahibi olan mağazayla aynı olmalıdır.

Bağlantınızı en basit istekle doğrulayın:

curl -u "API_KEY:API_SECRET" \
  -X GET "https://api.milagron.com/integration/product/sellers/{sellerId}/brands"
<?php

$ch = curl_init('https://api.milagron.com/integration/product/sellers/{sellerId}/brands');

curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'API_KEY:API_SECRET',
    CURLOPT_CUSTOMREQUEST  => 'GET',
]);

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
const auth = Buffer.from('API_KEY:API_SECRET').toString('base64');

const res = await fetch('https://api.milagron.com/integration/product/sellers/{sellerId}/brands', {
    method: 'GET',
    headers: {
        'Authorization': `Basic ${auth}`
    }
});

const data = await res.json();
import requests

response = requests.get(
    'https://api.milagron.com/integration/product/sellers/{sellerId}/brands',
    auth=('API_KEY', 'API_SECRET')
)

response.raise_for_status()
data = response.json()
package main

import (
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://api.milagron.com/integration/product/sellers/{sellerId}/brands", nil)
    req.SetBasicAuth("API_KEY", "API_SECRET")

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
}
import java.net.URI;
import java.net.http.*;
import java.util.Base64;

HttpClient client = HttpClient.newHttpClient();

String auth = Base64.getEncoder()
    .encodeToString("API_KEY:API_SECRET".getBytes());

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.milagron.com/integration/product/sellers/{sellerId}/brands"))
    .header("Authorization", "Basic " + auth)
    .GET()
    .build();

HttpResponse<String> response = client.send(request,
    HttpResponse.BodyHandlers.ofString());
require 'net/http'
require 'uri'
require 'json'

uri = URI('https://api.milagron.com/integration/product/sellers/{sellerId}/brands')

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Get.new(uri.request_uri)
request.basic_auth('API_KEY', 'API_SECRET')

response = http.request(request)
data = JSON.parse(response.body)
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

var client = new HttpClient();

var auth = Convert.ToBase64String(
    Encoding.UTF8.GetBytes("API_KEY:API_SECRET"));
client.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Basic", auth);

var response = await client.GetAsync("https://api.milagron.com/integration/product/sellers/{sellerId}/brands");
var data = await response.Content.ReadAsStringAsync();

200 ve bir marka listesi aldıysanız kimlik bilgileriniz çalışıyor demektir. Alamadıysanız 401 ve 403 hatalarına bakın.

Adım 1: brandId, markanızı bulun

Yukarıdaki istek, mağazanıza tanımlı markaları döndürür:

{
  "brands": [
    { "id": 8810, "name": "Serelia" }
  ]
}

Ürün oluştururken brandId olarak buradaki id değerini gönderirsiniz.

Listede olmayan bir markayla ürün oluşturamazsınız. Ayrıca her markanın komisyon oranı tanımlı olmalıdır. Tanımlı değilse ürün oluşturma 422 ile reddedilir; bu durumda bizimle iletişime geçin.

Adım 2: categoryId, yaprak kategoriyi seçin

Kategori ağacı üç seviyelidir: ana kategori, alt kategori ve yaprak kategori. Ürün oluştururken yalnızca yaprak kategoriyi gönderirsiniz. Üst seviyeler ağaçtan türetilir.

curl -u "API_KEY:API_SECRET" \
  -X GET "https://api.milagron.com/integration/product/sellers/{sellerId}/categories"
<?php

$ch = curl_init('https://api.milagron.com/integration/product/sellers/{sellerId}/categories');

curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'API_KEY:API_SECRET',
    CURLOPT_CUSTOMREQUEST  => 'GET',
]);

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
const auth = Buffer.from('API_KEY:API_SECRET').toString('base64');

const res = await fetch('https://api.milagron.com/integration/product/sellers/{sellerId}/categories', {
    method: 'GET',
    headers: {
        'Authorization': `Basic ${auth}`
    }
});

const data = await res.json();
import requests

response = requests.get(
    'https://api.milagron.com/integration/product/sellers/{sellerId}/categories',
    auth=('API_KEY', 'API_SECRET')
)

response.raise_for_status()
data = response.json()
package main

import (
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://api.milagron.com/integration/product/sellers/{sellerId}/categories", nil)
    req.SetBasicAuth("API_KEY", "API_SECRET")

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
}
import java.net.URI;
import java.net.http.*;
import java.util.Base64;

HttpClient client = HttpClient.newHttpClient();

String auth = Base64.getEncoder()
    .encodeToString("API_KEY:API_SECRET".getBytes());

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.milagron.com/integration/product/sellers/{sellerId}/categories"))
    .header("Authorization", "Basic " + auth)
    .GET()
    .build();

HttpResponse<String> response = client.send(request,
    HttpResponse.BodyHandlers.ofString());
require 'net/http'
require 'uri'
require 'json'

uri = URI('https://api.milagron.com/integration/product/sellers/{sellerId}/categories')

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Get.new(uri.request_uri)
request.basic_auth('API_KEY', 'API_SECRET')

response = http.request(request)
data = JSON.parse(response.body)
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

var client = new HttpClient();

var auth = Convert.ToBase64String(
    Encoding.UTF8.GetBytes("API_KEY:API_SECRET"));
client.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Basic", auth);

var response = await client.GetAsync("https://api.milagron.com/integration/product/sellers/{sellerId}/categories");
var data = await response.Content.ReadAsStringAsync();
{
  "categories": [
    {
      "id": 8, "name": "Oyuncak", "leaf": false,
      "subCategories": [
        {
          "id": 43, "name": "Puzzle", "leaf": false,
          "subCategories": [
            { "id": 271, "name": "3D Puzzle", "leaf": true,
              "taxRates": [20], "variantless": true }
          ]
        }
      ]
    }
  ]
}

leaf: true olan düğümü arayın. categoryId olarak onun id değerini gönderirsiniz.

Yaprak kategori ID'leri ayrı bir ID uzayındadır. Yukarıdaki örnekte 8 ve 43 ara seviye kategorilerdir, 271 ise yapraktır. Ara seviye bir ID göndermek 422 döndürür. Seviyeyi tahmin etmeyin, leaf alanına bakın.

Yaprak düğümde iki alan daha vardır ve ikisi de sonraki adımları belirler:

AlanAnlamı
taxRatesBu kategoride izin verilen KDV oranları. taxRate olarak bu listeden bir değer göndermelisiniz.
variantlesstrue ise kategori varyant desteklemez: tek varyant gönderirsiniz, özellik göndermezsiniz. false ise Adım 3'e geçin.

Adım 3: attributeId, kategorinin özelliklerini alın

Bir üründe hangi özelliklerin (renk, beden gibi) kullanılabileceğini kategori belirler. Genel özellik listesi değil, o kategoriye atanmış liste geçerlidir:

curl -u "API_KEY:API_SECRET" \
  -X GET "https://api.milagron.com/integration/product/sellers/{sellerId}/categories/{categoryId}/attributes"
<?php

$ch = curl_init('https://api.milagron.com/integration/product/sellers/{sellerId}/categories/{categoryId}/attributes');

curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'API_KEY:API_SECRET',
    CURLOPT_CUSTOMREQUEST  => 'GET',
]);

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
const auth = Buffer.from('API_KEY:API_SECRET').toString('base64');

const res = await fetch('https://api.milagron.com/integration/product/sellers/{sellerId}/categories/{categoryId}/attributes', {
    method: 'GET',
    headers: {
        'Authorization': `Basic ${auth}`
    }
});

const data = await res.json();
import requests

response = requests.get(
    'https://api.milagron.com/integration/product/sellers/{sellerId}/categories/{categoryId}/attributes',
    auth=('API_KEY', 'API_SECRET')
)

response.raise_for_status()
data = response.json()
package main

import (
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://api.milagron.com/integration/product/sellers/{sellerId}/categories/{categoryId}/attributes", nil)
    req.SetBasicAuth("API_KEY", "API_SECRET")

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
}
import java.net.URI;
import java.net.http.*;
import java.util.Base64;

HttpClient client = HttpClient.newHttpClient();

String auth = Base64.getEncoder()
    .encodeToString("API_KEY:API_SECRET".getBytes());

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.milagron.com/integration/product/sellers/{sellerId}/categories/{categoryId}/attributes"))
    .header("Authorization", "Basic " + auth)
    .GET()
    .build();

HttpResponse<String> response = client.send(request,
    HttpResponse.BodyHandlers.ofString());
require 'net/http'
require 'uri'
require 'json'

uri = URI('https://api.milagron.com/integration/product/sellers/{sellerId}/categories/{categoryId}/attributes')

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Get.new(uri.request_uri)
request.basic_auth('API_KEY', 'API_SECRET')

response = http.request(request)
data = JSON.parse(response.body)
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

var client = new HttpClient();

var auth = Convert.ToBase64String(
    Encoding.UTF8.GetBytes("API_KEY:API_SECRET"));
client.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Basic", auth);

var response = await client.GetAsync("https://api.milagron.com/integration/product/sellers/{sellerId}/categories/{categoryId}/attributes");
var data = await response.Content.ReadAsStringAsync();
{
  "category": { "id": 12, "name": "Tişört", "leaf": true, "taxRates": [10], "variantless": false },
  "attributes": [
    {
      "id": 14, "name": "Renk", "required": true, "variant": true, "multiple": true,
      "values": [ { "id": 1, "value": "Siyah" }, { "id": 2, "value": "Beyaz" } ]
    },
    {
      "id": 21, "name": "Beden", "required": true, "variant": true, "multiple": true,
      "values": [ { "id": 55, "value": "S" }, { "id": 56, "value": "M" } ]
    }
  ]
}

Bu yanıtta üç alan belirleyicidir:

  • variant: true olanlar varyant üretir. false olanlar bilgi amaçlıdır ve ürün oluştururken gönderilirse istek reddedilir.
  • required: true olan varyant özelliklerinin hepsi gönderilmelidir, eksik gönderim 422 döndürür.
  • multiple: false ise tüm varyantlar bu özellik için aynı değeri kullanmak zorundadır.

Adım 4: Ürünü oluşturun

Topladığınız ID'lerle ürünü gönderin. Aşağıdaki örnek varyantsız, yani en basit durumdur:

curl -u "API_KEY:API_SECRET" \
  -X POST "https://api.milagron.com/integration/product/sellers/{sellerId}/products" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Örnek Ürün",
    "description": "<p>Ürün açıklaması</p>",
    "brandId": 8810,
    "categoryId": 271,
    "taxRate": 20,
    "deliveryOptions": {
        "minDeliveryDays": 1,
        "maxDeliveryDays": 3
    },
    "images": [
        "https://cdn.example.com/urun-1.jpg"
    ],
    "variants": [
        {
            "barcode": "8680000000001",
            "stockCode": "ORN-001",
            "stock": 25,
            "price": {
                "salePrice": 249.9,
                "listPrice": 349.9
            },
            "attributes": []
        }
    ]
}'
<?php

$ch = curl_init('https://api.milagron.com/integration/product/sellers/{sellerId}/products');

curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'API_KEY:API_SECRET',
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode([
    'title' => 'Örnek Ürün',
    'description' => '<p>Ürün açıklaması</p>',
    'brandId' => 8810,
    'categoryId' => 271,
    'taxRate' => 20,
    'deliveryOptions' => [
        'minDeliveryDays' => 1,
        'maxDeliveryDays' => 3
    ],
    'images' => [
        'https://cdn.example.com/urun-1.jpg'
    ],
    'variants' => [
        [
            'barcode' => '8680000000001',
            'stockCode' => 'ORN-001',
            'stock' => 25,
            'price' => [
                'salePrice' => 249.9,
                'listPrice' => 349.9
            ],
            'attributes' => [

            ]
        ]
    ]
]),
]);

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
const auth = Buffer.from('API_KEY:API_SECRET').toString('base64');

const res = await fetch('https://api.milagron.com/integration/product/sellers/{sellerId}/products', {
    method: 'POST',
    headers: {
        'Authorization': `Basic ${auth}`,
        'Content-Type':  'application/json'
    },
    body: JSON.stringify({
    title: 'Örnek Ürün',
    description: '<p>Ürün açıklaması</p>',
    brandId: 8810,
    categoryId: 271,
    taxRate: 20,
    deliveryOptions: {
        minDeliveryDays: 1,
        maxDeliveryDays: 3
    },
    images: [
        'https://cdn.example.com/urun-1.jpg'
    ],
    variants: [
        {
            barcode: '8680000000001',
            stockCode: 'ORN-001',
            stock: 25,
            price: {
                salePrice: 249.9,
                listPrice: 349.9
            },
            attributes: {

            }
        }
    ]
})
});

const data = await res.json();
import requests

response = requests.post(
    'https://api.milagron.com/integration/product/sellers/{sellerId}/products',
    auth=('API_KEY', 'API_SECRET'),
    json={
    'title': 'Örnek Ürün',
    'description': '<p>Ürün açıklaması</p>',
    'brandId': 8810,
    'categoryId': 271,
    'taxRate': 20,
    'deliveryOptions': {
        'minDeliveryDays': 1,
        'maxDeliveryDays': 3
    },
    'images': [
        'https://cdn.example.com/urun-1.jpg'
    ],
    'variants': [
        {
            'barcode': '8680000000001',
            'stockCode': 'ORN-001',
            'stock': 25,
            'price': {
                'salePrice': 249.9,
                'listPrice': 349.9
            },
            'attributes': {

            }
        }
    ]
}
)

response.raise_for_status()
data = response.json()
package main

import (
    "bytes"
    "encoding/json"
    "net/http"
)

func main() {
    payload, _ := json.Marshal(map[string]interface{}{
    "title": "Örnek Ürün",
    "description": "<p>Ürün açıklaması</p>",
    "brandId": 8810,
    "categoryId": 271,
    "taxRate": 20,
    "deliveryOptions": map[string]interface{}{
        "minDeliveryDays": 1,
        "maxDeliveryDays": 3,
    },
    "images": []interface{}{
        "https://cdn.example.com/urun-1.jpg",
    },
    "variants": []interface{}{
        map[string]interface{}{
            "barcode": "8680000000001",
            "stockCode": "ORN-001",
            "stock": 25,
            "price": map[string]interface{}{
                "salePrice": 249.9,
                "listPrice": 349.9,
            },
            "attributes": map[string]interface{}{
,
            },
        },
    },
})
    req, _ := http.NewRequest("POST", "https://api.milagron.com/integration/product/sellers/{sellerId}/products", bytes.NewBuffer(payload))
    req.SetBasicAuth("API_KEY", "API_SECRET")
    req.Header.Set("Content-Type", "application/json")

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
}
import java.net.URI;
import java.net.http.*;
import java.util.Base64;

HttpClient client = HttpClient.newHttpClient();

String auth = Base64.getEncoder()
    .encodeToString("API_KEY:API_SECRET".getBytes());

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.milagron.com/integration/product/sellers/{sellerId}/products"))
    .header("Authorization", "Basic " + auth)
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString("{\"title\":\"Örnek Ürün\",\"description\":\"<p>Ürün açıklaması</p>\",\"brandId\":8810,\"categoryId\":271,\"taxRate\":20,\"deliveryOptions\":{\"minDeliveryDays\":1,\"maxDeliveryDays\":3},\"images\":[\"https://cdn.example.com/urun-1.jpg\"],\"variants\":[{\"barcode\":\"8680000000001\",\"stockCode\":\"ORN-001\",\"stock\":25,\"price\":{\"salePrice\":249.9,\"listPrice\":349.9},\"attributes\":[]}]}"))
    .build();

HttpResponse<String> response = client.send(request,
    HttpResponse.BodyHandlers.ofString());
require 'net/http'
require 'uri'
require 'json'

uri = URI('https://api.milagron.com/integration/product/sellers/{sellerId}/products')

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri.request_uri)
request.basic_auth('API_KEY', 'API_SECRET')
request['Content-Type'] = 'application/json'
request.body = {
  title: 'Örnek Ürün',
  description: '<p>Ürün açıklaması</p>',
  brandId: 8810,
  categoryId: 271,
  taxRate: 20,
  deliveryOptions: {
    minDeliveryDays: 1,
    maxDeliveryDays: 3
  },
  images: [
    'https://cdn.example.com/urun-1.jpg'
  ],
  variants: [
    {
      barcode: '8680000000001',
      stockCode: 'ORN-001',
      stock: 25,
      price: {
        salePrice: 249.9,
        listPrice: 349.9
      },
      attributes: {

      }
    }
  ]
}.to_json

response = http.request(request)
data = JSON.parse(response.body)
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

var client = new HttpClient();

var auth = Convert.ToBase64String(
    Encoding.UTF8.GetBytes("API_KEY:API_SECRET"));
client.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Basic", auth);

var content = new StringContent(
    "{\"title\":\"Örnek Ürün\",\"description\":\"<p>Ürün açıklaması</p>\",\"brandId\":8810,\"categoryId\":271,\"taxRate\":20,\"deliveryOptions\":{\"minDeliveryDays\":1,\"maxDeliveryDays\":3},\"images\":[\"https://cdn.example.com/urun-1.jpg\"],\"variants\":[{\"barcode\":\"8680000000001\",\"stockCode\":\"ORN-001\",\"stock\":25,\"price\":{\"salePrice\":249.9,\"listPrice\":349.9},\"attributes\":[]}]}",
    Encoding.UTF8,
    "application/json");

var response = await client.PostAsync("https://api.milagron.com/integration/product/sellers/{sellerId}/products", content);
var data = await response.Content.ReadAsStringAsync();

Varyantlı bir kategoride her varyant, Adım 3'te aldığınız attributeId ve attributeValueId çiftlerini taşır:

"variants": [
  {
    "barcode": "8680000000002", "stockCode": "ORN-002", "stock": 10,
    "price": { "salePrice": 249.90, "listPrice": 349.90 },
    "attributes": [
      { "attributeId": 14, "attributeValueId": 1 },
      { "attributeId": 21, "attributeValueId": 55 }
    ]
  },
  {
    "barcode": "8680000000003", "stockCode": "ORN-003", "stock": 10,
    "price": { "salePrice": 249.90, "listPrice": 349.90 },
    "attributes": [
      { "attributeId": 14, "attributeValueId": 1 },
      { "attributeId": 21, "attributeValueId": 56 }
    ]
  }
]
Tüm varyantlar aynı özellik kümesini bildirmelidir. Bir varyantta renk ve beden, diğerinde yalnızca renk gönderemezsiniz. Böyle bir istek 422 ile reddedilir.

Başarılı yanıt 201 döner ve size iki kimlik verir:

{
  "contentId": 169671,
  "productMainId": "9456235905247",
  "status": "notOnSale",
  "title": "Örnek Ürün",
  "variants": [ { "barcode": "8680000000001", "stockCode": "ORN-001" } ]
}
Ürün taslak olarak oluşur ve kendiliğinden satışa çıkmaz. Milagron onay sürecinden geçtikten sonra yayınlanır.

Adım 5: Ürünü doğrulayın

Oluşturduğunuz ürünü productMainId ile sorgulayın:

curl -u "API_KEY:API_SECRET" \
  -X GET "https://api.milagron.com/integration/product/sellers/{sellerId}/products?productMainId=9456235905247"
<?php

$ch = curl_init('https://api.milagron.com/integration/product/sellers/{sellerId}/products?productMainId=9456235905247');

curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'API_KEY:API_SECRET',
    CURLOPT_CUSTOMREQUEST  => 'GET',
]);

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
const auth = Buffer.from('API_KEY:API_SECRET').toString('base64');

const res = await fetch('https://api.milagron.com/integration/product/sellers/{sellerId}/products?productMainId=9456235905247', {
    method: 'GET',
    headers: {
        'Authorization': `Basic ${auth}`
    }
});

const data = await res.json();
import requests

response = requests.get(
    'https://api.milagron.com/integration/product/sellers/{sellerId}/products?productMainId=9456235905247',
    auth=('API_KEY', 'API_SECRET')
)

response.raise_for_status()
data = response.json()
package main

import (
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://api.milagron.com/integration/product/sellers/{sellerId}/products?productMainId=9456235905247", nil)
    req.SetBasicAuth("API_KEY", "API_SECRET")

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
}
import java.net.URI;
import java.net.http.*;
import java.util.Base64;

HttpClient client = HttpClient.newHttpClient();

String auth = Base64.getEncoder()
    .encodeToString("API_KEY:API_SECRET".getBytes());

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.milagron.com/integration/product/sellers/{sellerId}/products?productMainId=9456235905247"))
    .header("Authorization", "Basic " + auth)
    .GET()
    .build();

HttpResponse<String> response = client.send(request,
    HttpResponse.BodyHandlers.ofString());
require 'net/http'
require 'uri'
require 'json'

uri = URI('https://api.milagron.com/integration/product/sellers/{sellerId}/products?productMainId=9456235905247')

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Get.new(uri.request_uri)
request.basic_auth('API_KEY', 'API_SECRET')

response = http.request(request)
data = JSON.parse(response.body)
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

var client = new HttpClient();

var auth = Convert.ToBase64String(
    Encoding.UTF8.GetBytes("API_KEY:API_SECRET"));
client.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Basic", auth);

var response = await client.GetAsync("https://api.milagron.com/integration/product/sellers/{sellerId}/products?productMainId=9456235905247");
var data = await response.Content.ReadAsStringAsync();

Adım 6: Stok ve fiyat güncelleyin

Ürün oluşturma tek seferliktir. Sonraki tüm stok ve fiyat değişiklikleri barkod üzerinden yapılır ve ürün ID'sine ihtiyaç duymaz:

curl -u "API_KEY:API_SECRET" \
  -X POST "https://api.milagron.com/integration/inventory/sellers/{sellerId}/products/price-and-inventory" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
        {
            "barcode": "8680000000001",
            "quantity": 42,
            "salePrice": 229.9,
            "listPrice": 349.9
        }
    ]
}'
<?php

$ch = curl_init('https://api.milagron.com/integration/inventory/sellers/{sellerId}/products/price-and-inventory');

curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'API_KEY:API_SECRET',
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode([
    'items' => [
        [
            'barcode' => '8680000000001',
            'quantity' => 42,
            'salePrice' => 229.9,
            'listPrice' => 349.9
        ]
    ]
]),
]);

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
const auth = Buffer.from('API_KEY:API_SECRET').toString('base64');

const res = await fetch('https://api.milagron.com/integration/inventory/sellers/{sellerId}/products/price-and-inventory', {
    method: 'POST',
    headers: {
        'Authorization': `Basic ${auth}`,
        'Content-Type':  'application/json'
    },
    body: JSON.stringify({
    items: [
        {
            barcode: '8680000000001',
            quantity: 42,
            salePrice: 229.9,
            listPrice: 349.9
        }
    ]
})
});

const data = await res.json();
import requests

response = requests.post(
    'https://api.milagron.com/integration/inventory/sellers/{sellerId}/products/price-and-inventory',
    auth=('API_KEY', 'API_SECRET'),
    json={
    'items': [
        {
            'barcode': '8680000000001',
            'quantity': 42,
            'salePrice': 229.9,
            'listPrice': 349.9
        }
    ]
}
)

response.raise_for_status()
data = response.json()
package main

import (
    "bytes"
    "encoding/json"
    "net/http"
)

func main() {
    payload, _ := json.Marshal(map[string]interface{}{
    "items": []interface{}{
        map[string]interface{}{
            "barcode": "8680000000001",
            "quantity": 42,
            "salePrice": 229.9,
            "listPrice": 349.9,
        },
    },
})
    req, _ := http.NewRequest("POST", "https://api.milagron.com/integration/inventory/sellers/{sellerId}/products/price-and-inventory", bytes.NewBuffer(payload))
    req.SetBasicAuth("API_KEY", "API_SECRET")
    req.Header.Set("Content-Type", "application/json")

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
}
import java.net.URI;
import java.net.http.*;
import java.util.Base64;

HttpClient client = HttpClient.newHttpClient();

String auth = Base64.getEncoder()
    .encodeToString("API_KEY:API_SECRET".getBytes());

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.milagron.com/integration/inventory/sellers/{sellerId}/products/price-and-inventory"))
    .header("Authorization", "Basic " + auth)
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString("{\"items\":[{\"barcode\":\"8680000000001\",\"quantity\":42,\"salePrice\":229.9,\"listPrice\":349.9}]}"))
    .build();

HttpResponse<String> response = client.send(request,
    HttpResponse.BodyHandlers.ofString());
require 'net/http'
require 'uri'
require 'json'

uri = URI('https://api.milagron.com/integration/inventory/sellers/{sellerId}/products/price-and-inventory')

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri.request_uri)
request.basic_auth('API_KEY', 'API_SECRET')
request['Content-Type'] = 'application/json'
request.body = {
  items: [
    {
      barcode: '8680000000001',
      quantity: 42,
      salePrice: 229.9,
      listPrice: 349.9
    }
  ]
}.to_json

response = http.request(request)
data = JSON.parse(response.body)
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

var client = new HttpClient();

var auth = Convert.ToBase64String(
    Encoding.UTF8.GetBytes("API_KEY:API_SECRET"));
client.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Basic", auth);

var content = new StringContent(
    "{\"items\":[{\"barcode\":\"8680000000001\",\"quantity\":42,\"salePrice\":229.9,\"listPrice\":349.9}]}",
    Encoding.UTF8,
    "application/json");

var response = await client.PostAsync("https://api.milagron.com/integration/inventory/sellers/{sellerId}/products/price-and-inventory", content);
var data = await response.Content.ReadAsStringAsync();

Bu uç asenkron çalışır ve hemen bir toplu işlem kimliği döndürür:

{ "batchRequestId": "3f2a91c4-8e1d-4b7a-9c22-1f0e6d8b4a15" }

Adım 7: Toplu işlem sonucunu sorgulayın

curl -u "API_KEY:API_SECRET" \
  -X GET "https://api.milagron.com/integration/inventory/sellers/{sellerId}/products/batch-requests/3f2a91c4-8e1d-4b7a-9c22-1f0e6d8b4a15"
<?php

$ch = curl_init('https://api.milagron.com/integration/inventory/sellers/{sellerId}/products/batch-requests/3f2a91c4-8e1d-4b7a-9c22-1f0e6d8b4a15');

curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'API_KEY:API_SECRET',
    CURLOPT_CUSTOMREQUEST  => 'GET',
]);

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
const auth = Buffer.from('API_KEY:API_SECRET').toString('base64');

const res = await fetch('https://api.milagron.com/integration/inventory/sellers/{sellerId}/products/batch-requests/3f2a91c4-8e1d-4b7a-9c22-1f0e6d8b4a15', {
    method: 'GET',
    headers: {
        'Authorization': `Basic ${auth}`
    }
});

const data = await res.json();
import requests

response = requests.get(
    'https://api.milagron.com/integration/inventory/sellers/{sellerId}/products/batch-requests/3f2a91c4-8e1d-4b7a-9c22-1f0e6d8b4a15',
    auth=('API_KEY', 'API_SECRET')
)

response.raise_for_status()
data = response.json()
package main

import (
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://api.milagron.com/integration/inventory/sellers/{sellerId}/products/batch-requests/3f2a91c4-8e1d-4b7a-9c22-1f0e6d8b4a15", nil)
    req.SetBasicAuth("API_KEY", "API_SECRET")

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
}
import java.net.URI;
import java.net.http.*;
import java.util.Base64;

HttpClient client = HttpClient.newHttpClient();

String auth = Base64.getEncoder()
    .encodeToString("API_KEY:API_SECRET".getBytes());

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.milagron.com/integration/inventory/sellers/{sellerId}/products/batch-requests/3f2a91c4-8e1d-4b7a-9c22-1f0e6d8b4a15"))
    .header("Authorization", "Basic " + auth)
    .GET()
    .build();

HttpResponse<String> response = client.send(request,
    HttpResponse.BodyHandlers.ofString());
require 'net/http'
require 'uri'
require 'json'

uri = URI('https://api.milagron.com/integration/inventory/sellers/{sellerId}/products/batch-requests/3f2a91c4-8e1d-4b7a-9c22-1f0e6d8b4a15')

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Get.new(uri.request_uri)
request.basic_auth('API_KEY', 'API_SECRET')

response = http.request(request)
data = JSON.parse(response.body)
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

var client = new HttpClient();

var auth = Convert.ToBase64String(
    Encoding.UTF8.GetBytes("API_KEY:API_SECRET"));
client.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Basic", auth);

var response = await client.GetAsync("https://api.milagron.com/integration/inventory/sellers/{sellerId}/products/batch-requests/3f2a91c4-8e1d-4b7a-9c22-1f0e6d8b4a15");
var data = await response.Content.ReadAsStringAsync();
200 almanız her kalemin başarılı olduğu anlamına gelmez. İşlemin geneli completed olsa bile tek tek kalemler failed olabilir. Her zaman failureCount alanını kontrol edin ve hatalı kalemler için failureReasons listesini okuyun.

Akış Özeti

#İstekDöndürdüğü değer
1GET /brandsbrandId
2GET /categoriescategoryId (yaprak), taxRates, variantless
3GET /categories/{id}/attributesattributeId, attributeValueId
4POST /productscontentId, productMainId
5GET /productsdoğrulama
6POST /price-and-inventorybatchRequestId
7GET /batch-requests/{id}kalem bazında sonuç

Üretime Geçmeden Önce

  • Katalog yanıtlarını önbelleğe alın. Marka, kategori ve özellik listeleri sık değişmez. Bir saatlik önbellek istek hakkınızı belirgin biçimde rahatlatır.
  • Limitleri kendi tarafınızda da uygulayın. Başlık 255 karakter, varyant 100, görsel 50. Tam liste Limitler sayfasındadır.
  • Barkodlarınızın benzersiz olduğundan emin olun. Mağaza genelinde çakışma 409 döndürür.
  • listPrice, salePrice değerinden küçük olamaz. İndirim yoksa 0 gönderin.
  • 4xx hatalarını yeniden denemeyin. Aynı istek her zaman aynı sonucu verir ve istek hakkınızı tüketir. Ayrıntı için Hata İşleme.
  • Test ortamı henüz açık değil. Geliştirme sırasında dikkat edilecekler Ortamlar sayfasındadır.