smartproxy-sdk
v1.0.16-alpha
Published
`
Downloads
24
Readme
`
Smartproxy SDK Documentation
👋 Welcome
Welcome to the Smartproxy SDK documentation! This SDK provides developers with tools to easily integrate proxy functionality into their applications.
Table of Contents
Installation
You can install the Smartproxy SDK via npm:
npm install smartproxy-sdk --save
Or via Yarn:
yarn add smartproxy-sdk
Usage
To use the smartproxy SDK in your project, import it into your code:
const { SmartproxyClient } = require("smartproxy-sdk");
Then, login to the SDK with your dashboard authentication credentials:
const client = SmartproxyClient().getInstance();
client.login("username", "password");
Now you're ready to use the SDK to perform various proxy and scraping operations in your application!
Client API Reference
client.login(username, password)
Authenticates a user with the proxy service using their dashboard username and password.
username
(string): The user's username.password
(string): The user's password.
client.getProxyUsers(proxyType)
Fetches an array of proxy users.
proxyType
(string): The proxy product type.
client.getRtcUser(scraperType)
Sends an HTTP request via the proxy.
scraperType
(string): The scraper product type.
Examples
Authenticate a User
client
.login("[email protected]", "password")
.then(() => {
console.log("User authenticated successfully");
})
.catch((error) => {
console.error("Authentication failed:", error);
});
Retrieve Mobile Proxy Users List
client
.getProxyUsers("mobile")
.then((proxyUsers) => {
console.log("Proxy users:", proxyUsers);
})
.catch((error) => {
console.error("Failed to retrieve proxy users:", error);
});
Retrieve RTC Scraper User
client
.getRtcUser("rtc")
.then((user) => {
console.log("User:", user);
})
.catch((error) => {
console.error("Failed to retrieve rtc user:", error);
});
Spcraping API Reference
proxy({proxy, target})
Sends a request via the proxy.
proxy
(object): Proxy configuration.target
(string): Target URL.
EndpointBuilder(proxy)
Generate proxy endpoint URL.
proxy
(object): Proxy configuration.
UsernameBuilder
Gernerate proxy username.
proxy
(object): Proxy configuration.
Scraping API Reference
serpScraper(parameters)
Sends a request via SERP API to Google.
parameters
(object): Scraping parameters for SERP scraper.
webScrape(parameters)
Sends a request via WEB Scraping API.
parameters
(object): Scraping parameters Google hotels.
Examples
Make Google Scraping Request
const parameters = {
target: 'google',
url: 'www.example.com',
geo: 'Congo',
device_type: 'Mobile',
session_id: '1',
parse: false,
};
serpScraper(parameters)
.then((response) => {
console.log("SERP API response:", response);
})
.catch((error) => {
console.error("SERP API request failed:", error);
});
Make Google Search Scraping Request
const parameters = {
target: 'google_search',
query: 'pizza',
domain: 'www.pizza.com',
page_from: '1',
num_pages: '2',
locale: 'en-us',
geo: 'Congo',
device_type: 'Mobile',
google_results_language: 'en-us',
google_tbm: 'yes',
google_tbs: 'yes',
google_safe_search: 'no',
session_id: '1',
parse: false,
};
serpScraper(parameters)
.then((response) => {
console.log("SERP API response:", response);
})
.catch((error) => {
console.error("SERP API request failed:", error);
});
Make Web Scraping Request
const parameters = {
url:"https://ip.smartproxy.com/json",
parse:false
};
webScrape(parameters)
.then((response) => {
console.log("WEB Scraping API response:", response);
})
.catch((error) => {
console.error("WEB Scraping API request failed:", error);
});
Proxy API Reference
proxy({proxy, target})
Sends a request via the proxy.
proxy
(object): Proxy configuration.target
(string): Target URL.
EndpointBuilder(proxy)
Generate proxy endpoint URL.
proxy
(object): Proxy configuration.
UsernameBuilder
Gernerate proxy username.
proxy
(object): Proxy configuration.
Examples
Make HTTP Proxy Request
const proxyConfig = {
output: "https",
username: "username",
password: "password",
adress: "gate.smartproxy.com",
port: "7000",
};
const target = "ip.smartproxy.com/json";
proxy({ proxy: proxyConfig, target })
.then((response) => {
console.log("Target response:", response);
})
.catch((error) => {
console.error("Proxy request failed:", error);
});
License
This project is licensed under the MIT License - see the LICENSE file for details. `