SDKs overview
WebScraping.AI offers its functionality primarily through a direct HTTP API, which developers interact with by sending requests to a single endpoint and receiving JSON responses. Rather than providing traditional, installable SDK packages for each language, WebScraping.AI's approach emphasizes direct API interaction. The official WebScraping.AI documentation includes code examples in several popular programming languages, such as Python, Node.js, PHP, Ruby, and cURL, to demonstrate how to construct requests, pass parameters for features like JavaScript rendering and proxy selection, and process the returned data.
This method allows for flexibility, as developers are not tied to specific SDK versions and can use any HTTP client library available in their chosen language. While this means there are no formal 'SDKs' to install via package managers like pip or npm for WebScraping.AI specifically, the provided code snippets serve a similar purpose by illustrating the correct API call structure and response handling. Developers utilize standard web development libraries for making HTTP requests (e.g., Python's requests, Node.js's axios, PHP's Guzzle) to interface with the WebScraping.AI service.
Official SDKs by language
WebScraping.AI does not provide dedicated, installable SDK packages. Instead, it offers extensive code examples within its API documentation for direct integration using standard HTTP client libraries. The table below outlines the primary languages for which official code examples are available, demonstrating how to interact with the API.
| Language | Integration Method | Example Client Library | Maturity/Support |
|---|---|---|---|
| Python | Direct HTTP API calls | requests |
Official documentation examples |
| Node.js | Direct HTTP API calls | axios or built-in http/https |
Official documentation examples |
| PHP | Direct HTTP API calls | GuzzleHttp/guzzle |
Official documentation examples |
| Ruby | Direct HTTP API calls | Net::HTTP |
Official documentation examples |
| cURL | Command-line HTTP requests | cURL |
Official documentation examples |
Installation
Since WebScraping.AI does not offer dedicated SDK packages, there is no specific installation process for an 'SDK'. Instead, developers install and use standard HTTP client libraries relevant to their chosen programming language. These libraries are typically installed via the language's package manager.
Python
For Python, the requests library is a common choice for making HTTP requests. Install it using pip:
pip install requests
More information on installing Python packages can be found in the Python Packaging User Guide.
Node.js
In Node.js, axios is a popular promise-based HTTP client. Install it using npm or yarn:
npm install axios
# or
yarn add axios
Alternatively, the built-in http or https modules can be used without any additional installation. Details on Node.js package management are available in the npm documentation.
PHP
For PHP, Guzzle is a widely used HTTP client. Install it via Composer:
composer require guzzlehttp/guzzle
Ensure Composer is installed and properly configured. The official Composer documentation provides installation instructions.
Ruby
Ruby often uses its built-in Net::HTTP library, which requires no installation. For more advanced HTTP features, gems like httparty can be installed via Bundler:
gem install httparty
# or add to Gemfile and run bundle install
Refer to the Ruby on Rails guides for general Ruby gem management.
Quickstart example
The following examples demonstrate how to make a basic request to the WebScraping.AI API to retrieve the HTML content of a webpage. Replace YOUR_API_KEY with your actual WebScraping.AI API key.
Python Example
This Python example uses the requests library to fetch the content of a target URL.
import requests
api_key = "YOUR_API_KEY" # Replace with your actual API key
target_url = "https://example.com"
params = {
"api_key": api_key,
"url": target_url,
"render_js": 1, # Enable JavaScript rendering (optional)
"proxy_country": "us" # Use a US proxy (optional)
}
response = requests.get("https://api.webscraping.ai/html", params=params)
if response.status_code == 200:
print(response.text)
else:
print(f"Error: {response.status_code} - {response.text}")
Node.js Example
This Node.js example utilizes the axios library for making the API request.
const axios = require('axios');
const apiKey = "YOUR_API_KEY"; // Replace with your actual API key
const targetUrl = "https://example.com";
async function fetchData() {
try {
const response = await axios.get('https://api.webscraping.ai/html', {
params: {
api_key: apiKey,
url: targetUrl,
render_js: 1, // Enable JavaScript rendering (optional)
proxy_country: 'us' // Use a US proxy (optional)
}
});
console.log(response.data);
} catch (error) {
console.error(`Error: ${error.response ? error.response.status : error.message}`);
if (error.response) {
console.error(error.response.data);
}
}
}
fetchData();
PHP Example
This PHP example uses the Guzzle HTTP client to interact with the WebScraping.AI API.
<?php
require 'vendor/autoload.php'; // Include Composer autoloader
use GuzzleHttp\Client;
$apiKey = "YOUR_API_KEY"; // Replace with your actual API key
$targetUrl = "https://example.com";
$client = new Client();
try {
$response = $client->request('GET', 'https://api.webscraping.ai/html', [
'query' => [
'api_key' => $apiKey,
'url' => $targetUrl,
'render_js' => 1, // Enable JavaScript rendering (optional)
'proxy_country' => 'us' // Use a US proxy (optional)
]
]);
echo $response->getBody();
} catch (GuzzleHttp\Exception\GuzzleException $e) {
echo 'Error: ' . $e->getMessage();
if ($e->hasResponse()) {
echo ' ' . $e->getResponse()->getBody();
}
}
?>
Community libraries
While WebScraping.AI does not provide official SDKs, the nature of its API (standard HTTP requests) means that developers can readily integrate it using existing, well-established HTTP client libraries in virtually any programming language. As such, there is less emphasis on community-created wrapper libraries specifically for WebScraping.AI, as the direct integration path is straightforward and well-documented. Developers typically leverage general-purpose libraries like Python's requests, Node.js's axios, or PHP's Guzzle, which are maintained by broad open-source communities and offer robust features for handling web requests, authentication, and response parsing.
Exploring community repositories on platforms like GitHub using keywords such as "webscraping.ai python" or "webscraping.ai nodejs" may reveal user-contributed code snippets, examples, or small utility functions designed to simplify common tasks. However, these are not typically formal 'libraries' in the sense of a comprehensive, maintained SDK. When considering third-party code, it is advisable to review its source, activity, and compatibility with the latest WebScraping.AI API specifications. For most use cases, direct integration using the official documentation's code examples and standard HTTP libraries is the recommended and most reliable approach.