InstantAPI.ai Demo: eBay Item Data

node v18.11.0
version: 4.0.0
endpointsharetweet
This example demonstrates how to use the InstantAPI.ai Retrieve API endpoint to scrape detailed information from an eBay listing.
const data = JSON.stringify({ "webpage_url": "https://www.ebay.com/itm/175955440726", "api_method_name": "getItemDetails", "api_response_structure": JSON.stringify({ "item_name": "<the item name>", "item_price": "<the item price>", "item_image": "<the absolute URL of the first item image>", "item_url": "<the absolute URL of the item>", "item_type": "<the item type>", "item_weight": "<the item weight>", "item_main_feature": "<the main feature of this item that would most appeal to its target audience>", "item_review_summary": "<a summary of the customer reviews received for this item>", "item_available_colors": "<the available colors of the item, converted to closest primary colors>", "item_materials": "<the materials used in the item>", "item_shape": "<the shape of the item>" }), "api_key": process.env.INSTANTAPI_API_KEY }); /** * DO NOT EDIT BELOW */ const https = require('https'); const url = "https://instantapi.ai/api/retrieve/"; const options = { hostname: "instantapi.ai", port: 443, path: "/api/retrieve/", method: "POST", headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(data) }, timeout: 5 * 60 * 1000 // 5 minutes in milliseconds }; const req = https.request(options, (res) => { let responseData = ""; res.on("data", (chunk) => { responseData += chunk; }); res.on("end", () => { try { const parsedData = JSON.parse(responseData); console.log(parsedData); } catch (error) { console.error("Error parsing response:", error); } }); }); req.on("error", (error) => { console.error("HTTPS request error:", error); }); req.on("timeout", () => { console.error("Request timed out after 5 minutes"); req.destroy(); }); req.write(data); req.end();
Loading…

no comments

    sign in to comment