Use HTTP SERP API client for search

Replace the old JsonRpc2 relay-based product search with a direct HTTP client call to a SERP API endpoint. The search function signature changed from search(s) to search(keyword, limit) and now sends a GET to the workers.dev /api/v1/products/search endpoint with keyword and limit parameters, returning the HTTP responseBody. Also updated VERSIONINFO and removed the previous security notice and remote script relay logic. Note: callers must update usages due to the signature and return-value change.
This commit is contained in:
Namhyeon Go 2026-02-11 16:36:48 +09:00
parent ef11f06661
commit aaac19406b

View File

@ -1,33 +1,29 @@
// coupang.js
// Coupang SERP API Client
// Copyright 2019-2025, Namhyeon Go <gnh1201@catswords.re.kr> 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;