diff --git a/lib/coupang.js b/lib/coupang.js index 10b5252..12df212 100644 --- a/lib/coupang.js +++ b/lib/coupang.js @@ -1,33 +1,29 @@ // coupang.js +// Coupang SERP API Client // Copyright 2019-2025, Namhyeon Go and the WelsonJS contributors. // SPDX-License-Identifier: GPL-3.0-or-later // https://github.com/gnh1201/welsonjs // -// SECURITY NOTICE -// Due to potential security issues, the Public API URL is not provided. If you need to request access, please refer to the project's contact information. -// You can download the server-side script that implements this functionality from the link below: -// https://github.com/gnh1201/caterpillar -// -var JsonRpc2 = require("lib/jsonrpc2"); +var HTTP = require("lib/http"); -function search(s) { - var rpc = JsonRpc2.create(JsonRpc2.DEFAULT_JSONRPC2_URL); - var result = rpc.invoke("relay_invoke_method", { - "callback": "load_script", - "requires": [ - "https://scriptas.catswords.net/coupang.class.php" - ], - "args": [ - "$search = new CoupangProductSearch(); return $search->searchProducts('" + s + "')" - ] - }, ""); +function search(keyword, limit) { + limit = (typeof limit !== "number" && limit > 0 ? 10 : limit); - return result.data; + return HTTP.create() + .setParameters({ + "keyword": keyword, + "limit": limit + }) + .setDataType("json") + .open("GET", "https://cold-math-31f3.gnh1201.workers.dev/api/v1/products/search") + .send() + .responseBody + ; } exports.search = search; -exports.VERSIONINFO = "Coupang Product Search Client (coupang.js) version 0.1.1"; +exports.VERSIONINFO = "Coupang SERP API Client (coupang.js) version 1.0"; exports.AUTHOR = "gnh1201@catswords.re.kr"; exports.global = global; exports.require = global.require;