import requests
# Trendyol API URL'si
trendyol_api_url = "https://api.trendyol.com/grocerygw/suppliers/{sellerId}/products"
# Trendyol API Kimlik Bilgileri
api_key = "YOUR_API_KEY"
seller_id = "YOUR_SELLER_ID"
def upload_product_to_trendyol(product_data):
url = trendyol_api_url.format(sellerId=seller_id)
headers = {
"Authorization": "Basic " + api_key,
"Content-Type": "application/json",
}
response = requests.post(url, headers=headers, json=product_data)
return response
def main():
# Örnek ürün verisi
product_data = {
"items": [
{
"barcode": "1234567890123",
"images": [{"url": "https://example.com/image1.jpg"}],
"vatRate": 18,
"title": "Ürün Başlığı",
"description": "Ürün açıklaması",
"productMainId": "main_product_001",
"stockCode": "stock_code_001",
"brandId": 1,
"categoryId": 10,
}
]
}
# Ürünü Trendyol'a yükleme
response = upload_product_to_trendyol(product_data)
if response.status_code == 200:
print("Ürün başarıyla yüklendi.")
# Tarafınıza dönen batchRequestId ile Toplu İşlem Kontrolü Servisine giderek işlem sonucunu görebilirsiniz.
else:
print("Ürün yüklenirken hata oluştu.")
print(f"Detaylar: {response.json()}")
if __name__ == "__main__":
main()