InstantAPI

4 months ago 4

Example Code

This code snippet demonstrates how to call our Web Scraping API to fetch and return structured product data from Amazon in a single request, illustrating how easily you can retrieve and use the scraped information. 

### Python ### # # Install our package: pip install web-extract-data # from web_extract_data import WebExtractClient # Initialize the client with your InstantAPI.ai key # Replace %% API_KEY %% with your API key from: # https://web.instantapi.ai/#pricing-03-254921 client = WebExtractClient("%%API_KEY%%") # You can modify the URL and data fields to extract in JSON format result = client.scrape( url="https://www.amazon.com.au/MSI-PRO-MP341CQW-UltraWide-Compatible/dp/B09Y19TRQ2", fields={ "monitor_name": "< The product name of the monitor. >", "brand": "< The brand or manufacturer name. >", "display_size_in_inches": "< Numeric only. >", "resolution": "< Example format: 1920x1080. >", "panel_type": "< Type of panel. >", "refresh_rate_hz": "< Numeric only. >", "aspect_ratio": "< Example format: 16:9. >", "ports": "< A comma-delimited list of available ports (e.g., HDMI, DisplayPort, etc.). >", "features": "< Key selling points or capabilities, comma-delimited (e.g., LED, Full HD, etc.). >", "price": "< Numeric price (integer or float). >", "price_currency": "< Price currency (3 character alphabetic ISO 4217). >", "review_count": "< Total number of customer reviews, numeric only. >", "average_rating": "< Float or numeric star rating (e.g., 4.3). >", "review_summary": "< A 50 words or less summary of all the written customer feedback. >" } ) # Print the extracted data print(result) ### JavaScript ### // // Install our package: npm install web-extract-data // const { WebExtractClient } = require('web-extract-data'); // Initialize the client with your InstantAPI.ai key // Replace %% API_KEY %% with your API key from: // https://web.instantapi.ai/#pricing-03-254921 const client = new WebExtractClient("%%API_KEY%%"); // You can modify the URL and data fields to extract in JSON format client.scrape({ url: "https://www.amazon.com.au/MSI-PRO-MP341CQW-UltraWide-Compatible/dp/B09Y19TRQ2", fields: { "monitor_name": "< The product name of the monitor. >", "brand": "< The brand or manufacturer name. >", "display_size_in_inches": "< Numeric only. >", "resolution": "< Example format: 1920x1080. >", "panel_type": "< Type of panel. >", "refresh_rate_hz": "< Numeric only. >", "aspect_ratio": "< Example format: 16:9. >", "ports": "< A comma-delimited list of available ports (e.g., HDMI, DisplayPort, etc.). >", "features": "< Key selling points or capabilities, comma-delimited (e.g., LED, Full HD, etc.). >", "price": "< Numeric price (integer or float). >", "price_currency": "< Price currency (3 character alphabetic ISO 4217). >", "review_count": "< Total number of customer reviews, numeric only. >", "average_rating": "< Float or numeric star rating (e.g., 4.3). >", "review_summary": "< A 50 words or less summary of all the written customer feedback. >" } }) .then(result => { // Print the extracted data console.log(result); }) .catch(error => { console.error("Error:", error.message); }); ### HTTP ### # Initialize the client with your InstantAPI.ai key # Replace %% API_KEY %% with your API key from: # https://web.instantapi.ai/#pricing-03-254921 API_KEY="%%API_KEY%%" # API endpoint API_URL="https://instantapi.ai/api/scrape/" # You can modify the URL and data fields to extract in JSON format cat > payload.json << 'EOF' { "url": "https://www.amazon.com.au/MSI-PRO-MP341CQW-UltraWide-Compatible/dp/B09Y19TRQ2", "fields": { "monitor_name": "< The product name of the monitor. >", "brand": "< The brand or manufacturer name. >", "display_size_in_inches": "< Numeric only. >", "resolution": "< Example format: 1920x1080. >", "panel_type": "< Type of panel. >", "refresh_rate_hz": "< Numeric only. >", "aspect_ratio": "< Example format: 16:9. >", "ports": "< A comma-delimited list of available ports (e.g., HDMI, DisplayPort, etc.). >", "features": "< Key selling points or capabilities, comma-delimited (e.g., LED, Full HD, etc.). >", "price": "< Numeric price (integer or float). >", "price_currency": "< Price currency (3 character alphabetic ISO 4217). >", "review_count": "< Total number of customer reviews, numeric only. >", "average_rating": "< Float or numeric star rating (e.g., 4.3). >", "review_summary": "< A 50 words or less summary of all the written customer feedback. >" } } EOF # Make the API request and print the extracted data curl "$API_URL" \ -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $API_KEY" \ -d @payload.json \ | json_pp ### MCP ### # Initialize the client with your InstantAPI.ai key # Replace %% API_KEY %% with your API key from: # https://web.instantapi.ai/#pricing-03-254921 { "mcpServers": { "web-scraping-api-by-instantapi-ai": { "command": "npx", "args": [ "-y", "mcp-remote", "https://web-scraping-api-by-instantapi-ai.help-052.workers.dev/sse", "--header", "Authorization:${AUTH_HEADER}" ], "env": { "AUTH_HEADER": "Bearer %%API_KEY%%" } } } }

Example Response

{ "scrape": { "monitor_name": "MSI PRO MP341CQW 34\" UltraWide Business Monitor", "brand": "MSI", "display_size_in_inches": 34, "resolution": "3440x1440", "panel_type": "VA", "refresh_rate_hz": 100, "aspect_ratio": "21:9", "ports": "HDMI, DisplayPort", "features": "1500R Curved, Frameless, 1ms, Tilt Compatible, HDR Ready, Built-in Speakers, VESA", "price": 299, "price_currency": "AUD", "review_count": 443, "average_rating": 4.5, "review_summary": "Customers appreciate the monitor's excellent color accuracy and immersive curved design, making it ideal for both work and entertainment." }, "markdown": "< Markdown of the page >", "html": "< HTML of the page >" }

Emoji icon 1f64c.svg

Web Scraping Made Simple

"After trying other options, we were won over by the simplicity of InstantAPI.ai’s Web Scraping API. It's fast, easy, and allows us to focus on what matters most—our core features." — Juan, Scalista GmbH

Read Entire Article