--- title: "Shopping insight examples" slug: "naver-api-hub-shopping-insight-examples" updated: 2026-09-17T09:35:44Z published: 2026-09-17T09:35:44Z canonical: "api.ncloud-docs.com/naver-api-hub-shopping-insight-examples" --- > ## Documentation Index > Fetch the complete documentation index at: https://api.ncloud-docs.com/llms.txt > Use this file to discover all available pages before exploring further. # Shopping insight examples Available in Classic and VPC These are implementation examples that demonstrate how to retrieve search click trends by shopping category using the Shopping Insight API. Since the process for implementing other Shopping Insight API operations is similar, you can use these examples as a reference to implement the Shopping Insight API. Note - In the sample code, enter the client ID issued by the NAVER Cloud Platform console into `YOUR_CLIENT_ID`, and the client secret mapped to that client ID into `YOUR_CLIENT_SECRET`. - See the instructions on how to obtain a client ID and client secret in [NAVER API HUB overview](/docs/en/naver-api-hub-overview#API%ED%82%A4). ## Get trends by category This section describes how to use the Shopping Insight API to view click trends in the shopping section of NAVER’s integrated search and on NAVER Shopping, broken down by shopping category. By replacing the `category` in the request body and the search criteria (such as `device`, `ages`, and `gender`) with different values, you can view trends for other categories in the same way. ### Java The following is a Java-based sample code for the Shopping Insight API. ``` package com.naver.apihub.example; import java.io.*; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; public class ApiExampleShoppingCategories { public static void main(String[] args) { String clientId = "YOUR_CLIENT_ID"; // Application's client ID String clientSecret = "YOUR_CLIENT_SECRET"; // Application's client secret String apiUrl = "https://naverapihub.apigw.ntruss.com/shopping/v1/categories"; Map requestHeaders = new HashMap<>(); requestHeaders.put("X-NCP-APIGW-API-KEY-ID", clientId); requestHeaders.put("X-NCP-APIGW-API-KEY", clientSecret); requestHeaders.put("Content-Type", "application/json"); String requestBody = "{\"startDate\":\"2026-01-01\"," + "\"endDate\":\"2026-05-31\"," + "\"timeUnit\":\"month\"," + "\"category\":[{\"name\":\"Fashion apparel\",\"param\":[\"50000000\"]}," + "{\"name\":\"Cosmetics/beauty\",\"param\":[\"50000002\"]}]," + "\"device\":\"pc\"," + "\"gender\":\"f\"," + "\"ages\":[\"20\",\"30\"]}"; String responseBody = post(apiUrl, requestHeaders, requestBody); System.out.println(responseBody); } private static String post(String apiUrl, Map requestHeaders, String requestBody) { HttpURLConnection con = connect(apiUrl); try { con.setRequestMethod("POST"); for (Map.Entry header : requestHeaders.entrySet()) { con.setRequestProperty(header.getKey(), header.getValue()); } con.setDoOutput(true); try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) { wr.write(requestBody.getBytes(StandardCharsets.UTF_8)); wr.flush(); } int responseCode = con.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) { // Normal response return readBody(con.getInputStream()); } else { // Error response return readBody(con.getErrorStream()); } } catch (IOException e) { throw new RuntimeException("API request and response failed", e); } finally { con.disconnect(); } } private static HttpURLConnection connect(String apiUrl) { try { URL url = new URL(apiUrl); return (HttpURLConnection) url.openConnection(); } catch (MalformedURLException e) { throw new RuntimeException("Invalid API URL. : " + apiUrl, e); } catch (IOException e) { throw new RuntimeException("Connection failed. : " + apiUrl, e); } } private static String readBody(InputStream body) { InputStreamReader streamReader = new InputStreamReader(body, StandardCharsets.UTF_8); try (BufferedReader lineReader = new BufferedReader(streamReader)) { StringBuilder responseBody = new StringBuilder(); String line; while ((line = lineReader.readLine()) != null) { responseBody.append(line); } return responseBody.toString(); } catch (IOException e) { throw new RuntimeException("Failed to read the API response.", e); } } } ``` ### PHP The following is a PHP-based sample code for the Shopping Insight API. ``` ``` ### Node.js The following is a Node.js-based sample code for the Shopping Insight API. ``` const client_id = 'YOUR_CLIENT_ID'; const client_secret = 'YOUR_CLIENT_SECRET'; const api_url = 'https://naverapihub.apigw.ntruss.com/shopping/v1/categories'; const request_body = { startDate: '2026-01-01', endDate: '2026-05-31', timeUnit: 'month', category: [ { name: 'Fashion apparel', param: ['50000000'] }, { name: 'Cosmetics/beauty', param: ['50000002'] }, ], device: 'pc', gender: 'f', ages: ['20', '30'], }; (async () => { const response = await fetch(api_url, { method: 'POST', headers: { 'X-NCP-APIGW-API-KEY-ID': client_id, 'X-NCP-APIGW-API-KEY': client_secret, 'Content-Type': 'application/json', }, body: JSON.stringify(request_body), }); console.log(response.status); console.log(await response.text()); })(); ``` ### Python The following is a Python-based sample code for the Shopping Insight API. ``` import urllib.request client_id = "YOUR_CLIENT_ID" client_secret = "YOUR_CLIENT_SECRET" url = "https://naverapihub.apigw.ntruss.com/shopping/v1/categories" body = "{\"startDate\":\"2026-01-01\",\"endDate\":\"2026-05-31\",\"timeUnit\":\"month\",\"category\":[{\"name\":\"Fashion apparel\",\"param\":[\"50000000\"]},{\"name\":\"Cosmetics/beauty\",\"param\":[\"50000002\"]}],\"device\":\"pc\",\"gender\":\"f\",\"ages\":[\"20\",\"30\"]}" request = urllib.request.Request(url) request.add_header("X-NCP-APIGW-API-KEY-ID", client_id) request.add_header("X-NCP-APIGW-API-KEY", client_secret) request.add_header("Content-Type", "application/json") response = urllib.request.urlopen(request, data=body.encode("utf-8")) rescode = response.getcode() if rescode == 200: response_body = response.read() print(response_body.decode("utf-8")) else: print("Error Code:" + str(rescode)) ``` ### C# The following is a C#-based sample code for the Shopping Insight API. ``` using System; using System.IO; using System.Net; using System.Text; namespace NaverApiHubExample { public class ApiExampleShoppingCategories { static void Main(string[] args) { string clientId = "YOUR_CLIENT_ID"; string clientSecret = "YOUR_CLIENT_SECRET"; string url = "https://naverapihub.apigw.ntruss.com/shopping/v1/categories"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Headers.Add("X-NCP-APIGW-API-KEY-ID", clientId); request.Headers.Add("X-NCP-APIGW-API-KEY", clientSecret); request.ContentType = "application/json"; request.Method = "POST"; string body = "{\"startDate\":\"2026-01-01\",\"endDate\":\"2026-05-31\",\"timeUnit\":\"month\",\"category\":[{\"name\":\"Fashion apparel\",\"param\":[\"50000000\"]},{\"name\":\"Cosmetics/beauty\",\"param\":[\"50000002\"]}],\"device\":\"pc\",\"gender\":\"f\",\"ages\":[\"20\",\"30\"]}"; byte[] byteData = Encoding.UTF8.GetBytes(body); request.ContentLength = byteData.Length; using (Stream st = request.GetRequestStream()) { st.Write(byteData, 0, byteData.Length); } try { HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8)) { Console.WriteLine(reader.ReadToEnd()); } } catch (WebException e) // Error response { using (StreamReader reader = new StreamReader(e.Response.GetResponseStream(), Encoding.UTF8)) { Console.WriteLine(reader.ReadToEnd()); } } } } } ```