Example: eBay Item Details On this page In this example, we will demonstrate how to use the InstantAPI.ai Retrieve API endpoint to scrape detailed information from an eBay listing. We will provide a complete request and explain what each part of the request does. Additionally, we will show the expected response structure.
Complete Request# Here is a complete request to the Retrieve API endpoint:
cURL
Python
Node.js
JavaScript
Go
Ruby
PHP
curl --location 'https://instantapi.ai/api/retrieve/' \
--header 'Content-Type: application/json' \
--data '{
"webpage_url": "https://www.ebay.com/itm/175955440726",
"api_method_name": "getItemDetails",
"api_response_structure": "{\"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": "<your api key>"
}'
import requests
url = "https://instantapi.ai/api/retrieve/"
payload = {
"webpage_url" : "https://www.ebay.com/itm/175955440726" ,
"api_method_name" : "getItemDetails" ,
"api_response_structure" : "{ \" 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" : "<your api key>"
}
headers = {
"Content-Type" : "application/json"
}
response = requests . post ( url , json = payload , headers = headers )
print ( response . text )
const axios = require ( 'axios' );
const data = {
"webpage_url" : "https://www.ebay.com/itm/175955440726" ,
"api_method_name" : "getItemDetails" ,
"api_response_structure" : "{\"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" : "<your api key>"
};
axios . post ( 'https://instantapi.ai/api/retrieve/' , data , {
headers : {
'Content-Type' : 'application/json'
}
})
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
console . error ( error );
});
const url = "https://instantapi.ai/api/retrieve/" ;
const data = {
"webpage_url" : "https://www.ebay.com/itm/175955440726" ,
"api_method_name" : "getItemDetails" ,
"api_response_structure" : "{\"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" : "<your api key>"
};
fetch ( url , {
method : 'POST' ,
headers : {
'Content-Type' : 'application/json'
},
body : JSON . stringify ( data )
})
. then ( response => response . json ())
. then ( data => console . log ( data ))
. catch ( error => console . error ( 'Error:' , error ));
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
type RequestData struct {
WebpageURL string `json:"webpage_url"`
APIMethodName string `json:"api_method_name"`
APIResponseStructure string `json:"api_response_structure"`
APIKey string `json:"api_key"`
}
func main () {
url := "https://instantapi.ai/api/retrieve/"
data := RequestData {
WebpageURL : "https://www.ebay.com/itm/175955440726" ,
APIMethodName : "getItemDetails" ,
APIResponseStructure : "{\"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>\"}" ,
APIKey : "<your api key>" ,
}
jsonData , err := json . Marshal ( data )
if err != nil {
fmt . Println ( "Error marshaling JSON:" , err )
return
}
req , err := http . NewRequest ( "POST" , url , bytes . NewBuffer ( jsonData ))
if err != nil {
fmt . Println ( "Error creating request:" , err )
return
}
req . Header . Set ( "Content-Type" , "application/json" )
client := & http . Client {}
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Error making request:" , err )
return
}
defer resp . Body . Close ()
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Error reading response body:" , err )
return
}
fmt . Println ( string ( body ))
}
require 'net/http'
require 'uri'
require 'json'
uri = URI ( "https://instantapi.ai/api/retrieve/" )
request = Net :: HTTP :: Post . new ( uri , 'Content-Type' => 'application/json' )
request . body = {
webpage_url : "https://www.ebay.com/itm/175955440726" ,
api_method_name : "getItemDetails" ,
api_response_structure : {
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>"
} . to_json ,
api_key : "<your api key>"
} . to_json
response = Net :: HTTP . start ( uri . hostname , uri . port , use_ssl : true ) do | http |
http . request ( request )
end
puts response . body
$url = 'https://instantapi.ai/api/retrieve/' ;
$data = array (
"webpage_url" => "https://www.ebay.com/itm/175955440726" ,
"api_method_name" => "getItemDetails" ,
"api_response_structure" => json_encode ( array (
"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" => "<your api key>"
);
$ch = curl_init ( $url );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , array ( 'Content-Type: application/json' ));
curl_setopt ( $ch , CURLOPT_POST , true );
curl_setopt ( $ch , CURLOPT_POSTFIELDS , json_encode ( $data ));
$response = curl_exec ( $ch );
if ( $response === false ) {
echo "Error: " . curl_error ( $ch );
} else {
echo $response ;
}
curl_close ( $ch );
Request Breakdown# webpage_url : The URL of the eBay item you want to scrape.api_method_name : A user-defined name for the API action, in this case, “getItemDetails”.api_response_structure : The expected structure of the APIs response, defined by you. This includes placeholders for the details you want to scrape.api_key : Get your API key .Expected Response Structure# The expected response structure is defined in the api_response_structure
parameter. Here is the formatted version for clarity:
{
"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>"
}
Example Response# When the request is successfully processed, you can expect a response similar to the following:
{
"item_name" : "Milwaukee 2801-80 M18 18V 1/2\" LED Li-Ion Drill Driver-Bare Tool-Reconditioned" ,
"item_price" : "$60.00" ,
"item_image" : "https://i.ebayimg.com/images/g/aW4AAOSwbl5lJdcd/s-l1600.webp" ,
"item_url" : "https://www.ebay.com/itm/175955440726" ,
"item_type" : "Drill Driver" ,
"item_weight" : "2.5 lb" ,
"item_main_feature" : "Compact design with LED light for visibility in dark areas" ,
"item_review_summary" : "4.9 out of 5 stars based on 44 ratings, with many users praising its power and compact size." ,
"item_available_colors" : "Red" ,
"item_materials" : "Plastic, Metal" ,
"item_shape" : "Compact"
}
By following this example, you can easily use InstantAPI.ai to scrape and transform data from various web pages into structured data tailored to your needs.