Ana SayfaBelgelerKod ÖrnekleriAPI BaşvurusuDuyurularModellerSürüm NotlarıSSSGitHubVideolar
Geliştirici MerkeziAPI DurumuDestek
Belgeler
Geliştirici MerkeziAPI DurumuDestek

Data Kiosk Kullanım Örneği Kılavuzu

How to use the Data Kiosk API.

API Sürümü: 2023-11-15

Data Kiosk API'si nedir?

Data Kiosk için Satış Ortağı API'si, satış ortaklarının işlerini yönetmelerine yardımcı olmak için çeşitli şemalardan GraphQL sorguları göndermenize olanak tanır.

Anahtar noktalar

  • Data Kiosk, getQuery işleminin yanıtında bir veri belgesi veya bir hata belgesi döndürebilir. Ayrıca, sorgunun başarılı olduğu ancak veri döndürülmediği durumda hiçbir belge dönmeyebilir.
    • The data document contains the output in JSONL format when a successful request is processed with DONE processing status.
    • Hata belgesi JSON biçimindedir ve FATAL işlem durumu ile başarısız bir istek için hata mesajını içerir.
  • getQuery işleminin yanıtında errorDocumentId veya dataDocumentId olmadan DONEprocessingStatus olması durumunda, isteğin veri olmadan tamamlandığı veya verilen tarih aralığı için veri olmadığı anlamına gelir. İsteği farklı parametrelerle yeniden deneyin.
  • Data Kiosk API'si sorgu zamanlamasını desteklemez.
  • Data Kiosk API'si sorgu yedeklemeyi desteklemez. Data Kiosk, satış ortağı başına ve GraphQL sorgusu başına eşzamanlı terminal dışı sorgu sayısını sınırlar.

Eğitim: GraphQL sorgusuyla veri isteme ve filtreleme

Bu eğitim, bir GraphQL sorgusuyla verilerin nasıl talep edileceğini ve filtreleneceğini açıklar.

Ön koşullar:

Bu eğitici içeriği tamamlamak için şunlara ihtiyacınız olacak:

  • The appropriate role for the data you're requesting. This tutorial uses Sales and Traffic data in its examples, which requires the Brand Analytics role.

1. Adım: Sorgu isteği oluşturun

Create an async query request by specifying the query. The query must be a valid GraphQL query which adheres to the schema. The query input parameters can be modified as desired and response fields can be included or excluded in any order.

Call the createQuery operation, providing the query in the body:

Gövde parametresi

Ad Type Açıklama Zorunlu mu?
query string The GraphQL query that is compliant with the schema. A query can be at most 8,000 characters after unnecessary whitespace is removed. Refer to the schema to build your query. Evet

İstek örnekleri

Örnek 1: Yanıttaki alanların bir alt kümesini almak amacıyla salesAndTrafficByDate için bir sorgu isteği oluşturun.

POST https://sellingpartnerapi-na.amazon.com/dataKiosk/2023-11-15/queries { "query": "{analytics_salesAndTraffic_2023_11_15{salesAndTrafficByDate(startDate:\"2023-01-01\" endDate:\"2023-10-31\" aggregateBy:DAY marketplaceIds:[\"ATVPDKIKX0DER\"]){endDate marketplaceId startDate traffic{averageOfferCount browserPageViews averageParentItems browserPageViewsB2B browserSessions}sales{averageSalesPerOrderItem{amount currencyCode}averageSalesPerOrderItemB2B{amount currencyCode}averageSellingPrice{amount currencyCode}claimsGranted refundRate unitsOrderedB2B unitsRefunded unitsShipped}}}}" }

Örnek 2: Yanıttaki alanların bir alt kümesini almak amacıyla salesAndTrafficByAsin için bir sorgu isteği oluşturun.

POST https://sellingpartnerapi-na.amazon.com/dataKiosk/2023-11-15/queries { "query": "{analytics_salesAndTraffic_2023_11_15{salesAndTrafficByAsin(startDate:\"2023-01-01\" endDate:\"2023-10-31\" aggregateBy:PARENT marketplaceIds:[\"ATVPDKIKX0DER\"]){childAsin endDate marketplaceId parentAsin sales{orderedProductSales{amount currencyCode}totalOrderItems totalOrderItemsB2B}sku startDate traffic{browserPageViews browserPageViewsB2B browserPageViewsPercentage browserPageViewsPercentageB2B browserSessionPercentage unitSessionPercentageB2B unitSessionPercentage}}}}" }

Yanıt

Başarılı bir yanıt aşağıdaki özelliği içerir:

Ad Type Açıklama
queryId string Sorgunun tanımlayıcısı. Bu tanımlayıcı yalnızca satış ortağı kimliği ile birlikte benzersizdir.

Yanıt örneği

{ "queryId": "012345678901" }

2. Adım: Sorgu işlemenin tamamlandığını onaylayın

After you call the createQuery operation, Amazon receives the request and begins processing the query. Confirm that processing has completed before you continue. To confirm that the query processing is complete, refer to Verify that the query processing is complete.

3. Adım: Sorgu sonucunu almak için gerekli bilgileri alın

Sorgu sonucu belgesinin içeriğini almak için gereken bilgileri almak üzere getDocument işlemini çağırın. Bu, belge için önceden imzalanmış bir URL içerir. Belge sıkıştırılmışsa, Content-Encoding başlığı sıkıştırma algoritmasını gösterecektir. Bunun, Raporlar API'sinin sıkıştırma hakkında bilgi sağlama şeklinden farklı olduğunu unutmayın.

Yol parametresi

Ad Type Açıklama Zorunlu mu?
documentId string Sorgu sonuç belgesi için tanımlayıcı. Tanımlayıcı yalnızca bir satış ortağı kimliği ile birlikte benzersizdir. Evet

İstek örneği

GET https://sellingpartnerapi-na.amazon.com/dataKiosk/2023-11-15/documents/DOC-b8b0-4226-b4b9-0ee058ea5760

Yanıt

Başarılı bir yanıtta aşağıdakiler yer alır:

Ad Type Açıklama
documentId string Sorgu belgesi için tanımlayıcı. Tanımlayıcı yalnızca bir satış ortağı kimliği ile birlikte benzersizdir.
documentUrl string Data Kiosk belgesini almak için kullanılabilecek önceden imzalanmış bir URL. Bu URL'nin süresi beş dakika sonra dolar. Data Kiosk belgesi sıkıştırılmışsa Content-Encoding başlığı sıkıştırma algoritmasını belirtir.

Yanıt örneği

{ "documentId": "DOC-b8b0-4226-b4b9-0ee058ea5760", "documentUrl": "https://d34o8swod1owfl.cloudfront.net/SampleResult%2BKey%3DSample%2BINITVEC%3D58+fa+bf+a7+08+11+95+0f+c1+a8+c6+e0+d5+6f+ae+c8" }

documentUrl öğesini bir sonraki adımda kullanmak üzere kaydedin.

4. Adım: Belgeyi indirin

3. Adım'da döndürülen bilgileri kullanarak sorgu belgesini indirmelisiniz.

Aşağıdaki örnek kod, bir Data Kiosk belgesinin nasıl indirileceğini göstermektedir. Önceki adımdaki documentUrl değerini DownloadExample sınıfının download yönteminin url parametresinin bağımsız değişkeni olarak kullanın.

Not: Şifrelemeyi her zaman beklemede tutmalısınız. Sorgu sonuç belgesi hassas bilgiler içerebileceğinden, şifrelenmemiş sorgu sonuç belgesi içeriği geçici olarak bile olsa asla diskte depolanmamalıdır. Aşağıdaki örnek kod bu prensibi göstermektedir:

// DownloadExample.java // This example is for use with the Selling Partner API for Data Kiosk, Version: 2023-11-15 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; import com.squareup.okhttp.ResponseBody; /** * Example that downloads a Data Kiosk document. */ public class DownloadExample { public static void main(String[] args) { String url = "<URL from the getDocument response>"; DownloadExample obj = new DownloadExample(); try { obj.download(url); } catch (IOException e) { // Handle exceptions here. e.printStackTrace(); } } /** * Download the document from the given Amazon Simple Storage Service (Amazon S3) URL. * * @param url the signed Amazon S3 URL to retrieve the document from. * @throws IOException when there is an error reading the response. */ public void download(String url) throws IOException { OkHttpClient httpclient = new OkHttpClient(); Request request = new Request.Builder() .url(url) .get() .build(); Response response = httpclient.newCall(request).execute(); if (!response.isSuccessful()) { System.out.printf("Call to download content was unsuccessful with response code: %d and message: %s%n", response.code(), response.message()); return; } try (ResponseBody responseBody = response.body(); InputStream inputStream = responseBody.byteStream(); // Note: If the Data Kiosk document is compressed, the 'Content-Encoding' header will indicate the // compression algorithm. Most HTTP clients are capable of automatically decompressing downloaded files // based on the 'Content-Encoding' header. // More Information: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding // // The OkHttp client will automatically set the "Accept-Encoding" header and respect the // "Content-Encoding" header, so it is not required to unzip the stream. // For clients which do not automatically decompress, wrapping the stream in a GZIP stream may be // required, for example: // InputStream unzippedInputStream = new GZIPInputStream(inputStream); InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); BufferedReader reader = new BufferedReader(inputStreamReader)) { String line; while ((line = reader.readLine()) != null) { // Process line by line. System.out.println(line); } } } }

Bu sayfa size yardımcı oldu mu?