`
Welcome to the Smartproxy SDK documentation! This SDK provides developers with tools to easily integrate proxy functionality into their applications.
You can install the Smartproxy SDK via npm:
npm install smartproxy-sdk --save
Or via Yarn:
yarn add smartproxy-sdk
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!
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.
Fetches an array of proxy users.
-
proxyType
(string): The proxy product type.
Sends an HTTP request via the proxy.
-
scraperType
(string): The scraper product type.
client
.login("user@example.com", "password")
.then(() => {
console.log("User authenticated successfully");
})
.catch((error) => {
console.error("Authentication failed:", error);
});
client
.getProxyUsers("mobile")
.then((proxyUsers) => {
console.log("Proxy users:", proxyUsers);
})
.catch((error) => {
console.error("Failed to retrieve proxy users:", error);
});
client
.getRtcUser("rtc")
.then((user) => {
console.log("User:", user);
})
.catch((error) => {
console.error("Failed to retrieve rtc user:", error);
});
Sends a request via the proxy.
-
proxy
(object): Proxy configuration. -
target
(string): Target URL.
Generate proxy endpoint URL.
-
proxy
(object): Proxy configuration.
Gernerate proxy username.
-
proxy
(object): Proxy configuration.
Sends a request via SERP API to Google.
-
parameters
(object): Scraping parameters for SERP scraper.
Sends a request via WEB Scraping API.
-
parameters
(object): Scraping parameters Google hotels.
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);
});
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);
});
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);
});
Sends a request via the proxy.
-
proxy
(object): Proxy configuration. -
target
(string): Target URL.
Generate proxy endpoint URL.
-
proxy
(object): Proxy configuration.
Gernerate proxy username.
-
proxy
(object): Proxy configuration.
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);
});
This project is licensed under the MIT License - see the LICENSE file for details. `