Bu sayfada, ürünlerinizi programatik olarak nasıl yükleyip yönetebileceğiniz açıklanmaktadır. Merchant Products API'yi kullanarak bir veri kaynağına ürün ekleyebilir veya mevcut bir ürünü güncelleyebilir, hesabınızdan ürün alabilir ve bir veri kaynağındaki ürünü silebilirsiniz.
Merchant Products API iki kaynak içerir.
productInputs
, ürünlerinizin giriş bölümlerini temsil eder.products
, giriş parçalarınızdan oluşturulan işlenmiş ürünleri temsil eder.
productInputs
, birincil veri kaynağına veya ek veri kaynağına yüklenip yüklenmediğine bağlı olarak birincil ve ek olabilir.
Her product
, tek bir birincil productInput
ve herhangi bir sayıda ek productInputs
'den oluşur.
Merchant Products API'yi kullanarak online veya yerel mağaza katalogları oluşturabilirsiniz. Bu kataloglar, birden fazla alışveriş hedefinde görünebilecek ürünlerdir.
Merchant Center hesabınızı oluşturduktan, ilk veri kaynağınızı oluşturduktan ve API aracılığıyla ilk ürün grubunu yüklemeye hazır olduktan sonra productInputs
kaynağını kullanabilirsiniz.
Satıcılar PrimaryProductDataSource adlı bir dosya kullanarak ürün yükleyebilir. Ancak Merchant API'yi kullanarak ürün oluşturmanın ve silmenin çeşitli avantajları vardır. Bu avantajlar arasında daha hızlı yanıt süresi ve büyük dosyaları yönetmeye gerek kalmadan ürünleri gerçek zamanlı olarak güncelleme olanağı yer alır. API çağrılarıyla yapılan ürün değişikliklerinin Alışveriş veritabanında görünmesi birkaç saat sürebilir.
Ön koşullar
Veri kaynağınız yoksa Merchant Data Sources API'yi veya Merchant Center'ı kullanarak veri kaynağı oluşturun.
Merchant Center kullanıcı arayüzünü veya API'yi kullanarak oluşturduğunuz bir veri kaynağınız varsa ürünlerinizi eklemek için Merchant Products API'yi kullanabilirsiniz. Ürün eklemek için Content API for Shopping'i kullanıyorsanız Merchant Products API'yi kullanmaya nasıl başlayacağınızı öğrenmek için taşıma kılavuzuna bakın.
Alışveriş reklamları ve ücretsiz listelemeler politikalarına uyma konusunda sorumluluk size aittir. Alışveriş reklamları, bu politikaları uygulama ve bu politikaları ihlal eden içerik veya davranış tespit edersek uygun şekilde yanıt verme hakkını saklı tutar.
Kaynaklar
products
kaynağı, Alışveriş veritabanından ürün bilgilerini almanıza olanak tanır.
productInput
kaynağı, bir ürün için gönderdiğiniz giriş verilerini temsil eder. Ayrıca, ürün bilgilerini tek tek veya toplu modda birden fazla ürün için güncellemenize ya da silmenize olanak tanıyan yöntemler de sunar. productInput
kaynağında aşağıdaki alanlar bulunmalıdır:
channel
: Ürünün kanalı.offerId
: Ürünün benzersiz tanımlayıcısı.contentLanguage
: Ürünün iki harfli ISO 639-1 dil kodu.feedLabel
: Ürünlerinizi kategorize etmenize ve tanımlamanıza olanak tanıyan etiket. İzin verilen maksimum karakter sayısı 20'dir ve desteklenen karakterlerA-Z
,0-9
, kısa çizgi ve alt çizgidir. Feed etiketi boşluk içermemelidir. Daha fazla bilgi için Feed etiketlerini kullanma başlıklı makaleyi inceleyin.
Hesabınıza ürün girişi yükleme
Hesabınıza ürün girişi yüklemek için accounts.productInputs.insert
yöntemini kullanın. Birincil veya ek veri kaynağının benzersiz tanımlayıcısını iletmeniz gerekir.
Aşağıdaki örnek istek, satıcı hesabınıza ürün girişi yüklemek için accounts.productInputs.insert
yöntemini nasıl kullanabileceğinizi gösterir. İstek, kargo fiyatını ve bölgesini, ayrıca üretim tarihi ve beden gibi özel özellikleri belirler.
POST https://merchantapi.googleapis.com/products/v1beta/accounts/{ACCOUNT_ID}/productInputs:insert?dataSource={DATASOURCE}
{
"name": "{PRODUCT_TITLE}",
"versionNumber": {VERSION_NUMBER},
"contentLanguage": "{CONTENT_LANGUAGE}",
"feedLabel": "{FEED_LABEL}",
"offerId": "{OFFER_ID}",
"channel": "ONLINE",
"attributes": {
"availability": "in stock",
"imageLink": "{IMAGE_LINK}",
"link": "{PRODUCT_LINK}",
"brand": "{BRAND_NAME}",
"price": {
"currencyCode": "{CURRENCY_CODE}",
"amountMicros": {PRICE}
},
"color": "red",
"productWeight": {
"value": 320,
"unit": "g"
},
"adult": false,
"shipping": [
{
"country": "GB",
"price": {
"amountMicros": {SHIPPING_COST},
"currencyCode": "{CURRENCY_CODE_SHIPPING}"
},
"postalCode": "{SHIPPING_POSTALCODE}",
"service": "",
"region": "{SHIPPING_REGION}",
"maxHandlingTime": "{MAX_HANDLING_TIME}",
"minHandlingTime": "{MIN_HANDLING_TIME}",
"maxTransitTime": "{MAX_TRANSIT_TIME}",
"minTransitTime": "{MIN_TRANSIT_TIME}"
}
],
"gender": "Female"
},
"customAttributes": [
{
"name": "size",
"value": "Large"
},
{
"name": "Date of Manufacturing",
"value": "2024-05-05"
}
]
}
Aşağıdakini değiştirin:
- {ACCOUNT_ID}: Merchant Center hesabınızın benzersiz tanımlayıcısıdır.
- {DATASOURCE}: Veri kaynağının benzersiz tanımlayıcısı.
accounts/
{ACCOUNT_ID}/dataSources/
{DATASOURCE_ID} biçiminde olmalıdır. - {PRODUCT_TITLE}: Ürünün adı.
- {VERSION_NUMBER}: Ürünün sürüm numarası. İsteğe bağlıdır.
- {CONTENT_LANGUAGE}: Ürünün iki harfli ISO 639-1 dil kodu. Zorunlu.
- {FEED_LABEL}: Ürünlerinizi kategorilere ayırmanıza ve tanımlamanıza olanak tanıyan etiket. İzin verilen maksimum karakter sayısı 20'dir ve desteklenen karakterler
A-Z
,0-9
, kısa çizgi ve alt çizgidir. Feed etiketi boşluk içermemelidir. - {OFFER_ID}: Ürünün benzersiz tanımlayıcısıdır. Zorunlu.
- {IMAGE_LINK}: Ürünün web sitenizdeki resminin bağlantısı. İsteğe bağlıdır.
- {PRODUCT_LINK}: Web sitenizdeki ürünün bağlantısı. İsteğe bağlıdır.
- {CURRENCY_CODE}: ISO 4217'ye göre üç harfli kısaltmalar kullanılarak fiyatın para birimi. İsteğe bağlıdır.
- {PRICE}: Ürünün fiyatı, mikro cinsinden bir sayı olarak temsil edilir. İsteğe bağlıdır.
- {SHIPPING_COST}: Sabit kargo fiyatı, sayı olarak temsil edilir. İsteğe bağlıdır.
- {SHIPPING_POSTALCODE}: Gönderim ücretinin geçerli olduğu posta kodu aralığı. İsteğe bağlıdır.
- {MAX_HANDLING_TIME}: Sipariş alındığı tarih ile gönderildiği tarih arasında iş günü cinsinden maksimum sevkiyata hazırlık süresi. İsteğe bağlıdır.
- {MIN_HANDLING_TIME}: Sipariş alındığı tarih ile gönderildiği tarih arasındaki minimum sevkiyata hazırlık süresi (iş günü cinsinden). 0 değeri, siparişin alındığı gün teslim edildiği anlamına gelir. İsteğe bağlıdır.
- {MAX_TRANSIT_TIME}: Siparişin gönderildiği tarih ile teslim edildiği tarih arasında iş günü cinsinden maksimum nakliye süresi. İsteğe bağlıdır.
- {MIN_TRANSIT_TIME}: Siparişin gönderildiği tarih ile teslim edildiği tarih arasında iş günü cinsinden minimum nakliye süresi. 0 değeri, siparişin gönderildiği gün teslim edildiği anlamına gelir. İsteğe bağlıdır.
İstek başarıyla çalıştığında aşağıdaki yanıtı görürsünüz:
{
"name": "{PRODUCT_NAME}",
"product": "{PRODUCT_ID}",
"channel": "ONLINE",
"offerId": "{OFFER_ID}",
"contentLanguage": "{CONTENT_LANGUAGE}",
"feedLabel": "{FEED_LABEL}",
"versionNumber": "{VERSION_NUMBER}",
"attributes": {
"link": "{PRODUCT_LINK}",
"imageLink": "{IMAGE_LINK}",
"adult": false,
"availability": "in stock",
"brand": "{BRAND_NAME}",
"color": "red",
"gender": "Female",
"price": {
"amountMicros": "{PRICE}",
"currencyCode": "{CURRENCY_CODE}"
},
"shipping": [
{
"price": {
"amountMicros": "{SHIPPING_COST}",
"currencyCode": "{CURRENCY_CODE}"
},
"country": "{SHIPPING_COUNTRY}",
"region": "{SHIPPING_REGION}",
"postalCode": "{SHIPPING_POSTALCODE}",
"minHandlingTime": "{MIN_HANDLING_TIME}",
"maxHandlingTime": "{MAX_HANDLING_TIME}",
"minTransitTime": "{MIN_TRANSIT_TIME}",
"maxTransitTime": "{MAX_TRANSIT_TIME}"
}
],
"productWeight": {
"value": 320,
"unit": "g"
}
},
"customAttributes": [
{
"name": "Size",
"value": "Large"
},
{
"name": "Date of Manufacturing",
"value": "2024-05-05"
}
]
}
Merchant Center hesabınıza ürün eklemek için aşağıdaki örnekte gösterildiği gibi google.shopping.merchant.accounts.v1beta.InsertProductInputSample
yöntemini kullanabilirsiniz.
Java
public static void insertProductInput(Config config, String dataSource) throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the credentials retrieved above.
ProductInputsServiceSettings productInputsServiceSettings =
ProductInputsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Creates parent to identify where to insert the product.
String parent = getParent(config.getAccountId().toString());
// Calls the API and catches and prints any network failures/errors.
try (ProductInputsServiceClient productInputsServiceClient =
ProductInputsServiceClient.create(productInputsServiceSettings)) {
// Price to be used for shipping ($33.45).
Price price = Price.newBuilder().setAmountMicros(33_450_000).setCurrencyCode("USD").build();
Shipping shipping =
Shipping.newBuilder()
.setPrice(price)
.setCountry("GB")
.setService("1st class post")
.build();
Shipping shipping2 =
Shipping.newBuilder()
.setPrice(price)
.setCountry("FR")
.setService("1st class post")
.build();
Attributes attributes =
Attributes.newBuilder()
.setTitle("A Tale of Two Cities")
.setDescription("A classic novel about the French Revolution")
.setLink("https://exampleWebsite.com/tale-of-two-cities.html")
.setImageLink("https://exampleWebsite.com/tale-of-two-cities.jpg")
.setAvailability("in stock")
.setCondition("new")
.setGoogleProductCategory("Media > Books")
.setGtin(0, "9780007350896")
.addShipping(shipping)
.addShipping(shipping2)
.build();
// The datasource can be either a primary or supplemental datasource.
InsertProductInputRequest request =
InsertProductInputRequest.newBuilder()
.setParent(parent)
// You can only insert products into datasource types of Input "API" and "FILE", and
// of Type "Primary" or "Supplemental."
// This field takes the `name` field of the datasource.
.setDataSource(dataSource)
// If this product is already owned by another datasource, when re-inserting, the
// new datasource will take ownership of the product.
.setProductInput(
ProductInput.newBuilder()
.setChannel(ChannelEnum.ONLINE)
.setContentLanguage("en")
.setFeedLabel("label")
.setOfferId("sku123")
.setAttributes(attributes)
.build())
.build();
System.out.println("Sending insert ProductInput request");
ProductInput response = productInputsServiceClient.insertProductInput(request);
System.out.println("Inserted ProductInput Name below");
// The last part of the product name will be the product ID assigned to a product by Google.
// Product ID has the format `channel~contentLanguage~feedLabel~offerId`
System.out.println(response.getName());
System.out.println("Inserted Product Name below");
System.out.println(response.getProduct());
} catch (Exception e) {
System.out.println(e);
}
}
İşlenen bir ürünü hesabınızdan alma
İşlenen bir ürünü hesabınızdan almak için accounts.products.get
yöntemini kullanın. İşlenen ürünün eklendikten sonra görünmesi birkaç dakika sürebilir.
GET https://merchantapi.googleapis.com/products/v1beta/accounts/{ACCOUNT_ID}/products/{PRODUCT_NAME}
{PRODUCT_NAME} yerine, silmek istediğiniz ürün giriş kaynağının adını yazın. Örneğin, online~en~US~sku123
.
İşlenen ürünün kaynak adını, accounts.productInputs.insert
yanıtındaki product
alanından alabilirsiniz.
Belirli bir Merchant Center hesabı için tek bir ürünü almak üzere aşağıdaki örnekte gösterildiği gibi google.shopping.merchant.accounts.v1beta.GetProductRequest
yöntemini kullanabilirsiniz.
Java
public static void getProduct(Config config, String product) throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the credentials retrieved above.
ProductsServiceSettings productsServiceSettings =
ProductsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Calls the API and catches and prints any network failures/errors.
try (ProductsServiceClient productsServiceClient =
ProductsServiceClient.create(productsServiceSettings)) {
// The name has the format: accounts/{account}/products/{productId}
GetProductRequest request = GetProductRequest.newBuilder().setName(product).build();
System.out.println("Sending get product request:");
Product response = productsServiceClient.getProduct(request);
System.out.println("Retrieved Product below");
System.out.println(response);
} catch (Exception e) {
System.out.println(e);
}
}
Hesabınızdaki bir ürün girişini silme
Hesabınızdaki bir ürün girişini silmek için accounts.productInputs.delete
yöntemini kullanın. Merchant Products API'yi kullanarak bir ürünü silmek için ürünün ait olduğu birincil veya ek veri kaynağının benzersiz tanımlayıcısını iletmeniz gerekir.
Aşağıdaki istek, bir ürün girişini silmek için accounts.productInputs.delete
yöntemini nasıl kullanabileceğinizi gösterir:
DELETE https://merchantapi.googleapis.com/products/v1beta/accounts/{ACCOUNT_ID}/productInputs/{PRODUCT_NAME}?dataSource=accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID}
{PRODUCT_NAME} yerine, silmek istediğiniz ürün giriş kaynağının adını yazın. Örneğin, online~en~US~sku123
.
Belirli bir Merchant Center hesabındaki bir ürünü silmek için aşağıdaki örnekte gösterildiği gibi google.shopping.merchant.accounts.v1beta.DeleteProductInputRequest
yöntemini kullanabilirsiniz.
Java
public static void deleteProductInput(Config config, String productId, String dataSource)
throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the credentials retrieved above.
ProductInputsServiceSettings productInputsServiceSettings =
ProductInputsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Creates product name to identify product.
String name =
ProductInputName.newBuilder()
.setAccount(config.getAccountId().toString())
.setProductinput(productId)
.build()
.toString();
// Calls the API and catches and prints any network failures/errors.
try (ProductInputsServiceClient productInputsServiceClient =
ProductInputsServiceClient.create(productInputsServiceSettings)) {
DeleteProductInputRequest request =
DeleteProductInputRequest.newBuilder().setName(name).setDataSource(dataSource).build();
System.out.println("Sending deleteProductInput request");
productInputsServiceClient.deleteProductInput(request); // no response returned on success
System.out.println(
"Delete successful, note that it may take a few minutes for the delete to update in"
+ " the system. If you make a products.get or products.list request before a few"
+ " minutes have passed, the old product data may be returned.");
} catch (Exception e) {
System.out.println(e);
}
}
Hesabınızdaki ürünleri listeleme
Hesabınızda işlenen ürünleri listelemek için aşağıdaki istekte gösterildiği gibi accounts.products.list
yöntemini kullanın.
GET https://merchantapi.googleapis.com/products/v1beta/accounts/{ACCOUNT_ID}/products
Belirli bir Merchant Center hesabı için ürün listelemek istiyorsanız aşağıdaki örnekte gösterildiği gibi google.shopping.merchant.accounts.v1beta.ListProductsRequest
yöntemini kullanabilirsiniz.
Java
public static void listProducts(Config config) throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the credentials retrieved above.
ProductsServiceSettings productsServiceSettings =
ProductsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Creates parent to identify the account from which to list all products.
String parent = getParent(config.getAccountId().toString());
// Calls the API and catches and prints any network failures/errors.
try (ProductsServiceClient productsServiceClient =
ProductsServiceClient.create(productsServiceSettings)) {
// The parent has the format: accounts/{account}
ListProductsRequest request = ListProductsRequest.newBuilder().setParent(parent).build();
System.out.println("Sending list products request:");
ListProductsPagedResponse response = productsServiceClient.listProducts(request);
int count = 0;
// Iterates over all rows in all pages and prints the datasource in each row.
// Automatically uses the `nextPageToken` if returned to fetch all pages of data.
for (Product product : response.iterateAll()) {
System.out.println(product); // The product includes the `productStatus` field
// That shows approval and disapproval information.
count++;
}
System.out.print("The following count of products were returned: ");
System.out.println(count);
} catch (Exception e) {
System.out.println("An error has occured: ");
System.out.println(e);
}
}