API Examples

*This service is only available for use in overseas network environments, it is recommended to use it in overseas servers, and does not support IP links to proxy servers in China.

Code language:
Common Mode
Batch Generation
Shell
Node.js
Java
C#
Go
PHP
Python
Scrapy
Ruby
Rust
Sticky proxy Switching
By accessing the sticky proxy switching link, you can change the current IP without modifying the proxy configuration, IP switching link: http://flush.smartproxy.cn/
If in doubt. View Tutorial
Instructions for use
causality
element
Parameter description

username username

password: password

session: Not fill in: provide different ip for each request; Fill in: ensure to provide the same ip as far as possible; Maximum 12 bits

life: Time to keep ip in use, in minutes, min 1, max 24*60

area: Global area code e.g. US area-USClick to view

city: City e.g. New York city-newyorkClick to view

state: State code Example: New York state-NewyorkClick to view

ip: Specify data centre address

response code
400
Incorrect request
If the request does not contain the host to which you want to connect, or if there is a general error when parsing an HTTP request, the proxy server will return this error code. Make sure that your request is formatted correctly and that the URL is included in the request, then retry;
407
Proxy verification required
The request is missing proxy authentication information, or the username or password is invalid. Please include the Proxy Authorisation header in your request and ensure that your username and password are in the correct format, then retry.
500
Internal server error
The proxy server encountered an internal error and will retry the request later.
502
broken gate
The proxy server received an invalid response from the upstream server. Retry the request. Response code 502 indicates that the IP assigned to your session ID is no longer available. If you encounter this error, there are two ways to resolve it. The first method is to wait one minute and the system will automatically assign a new IP address to your session ID. The other way is to simply switch to a new session ID (i.e. change the sessid parameter) so that you will receive a new IP address.
522
timeout
The proxy server did not receive a timely response from the upstream server. Retry the request.
525
Can't find the exit.
Custom HTTP status code - this means that the agent could not find an exit node to fulfil the request. Please change the request filter parameters or retry later.
Quick Start

Smartproxy uses basic access authentication that requires you to provide a username and password when connecting to the proxy server. You can manage your user list in the Personal Centre Proxy Accounts after logging in. Or contact your dedicated account manager and technical support team to obtain your credentials.

Replace USERNAME and PASSWORD in the code with the contents of your credentials.

curl -x USERNAME:[email protected]:1000 https://api.ip.cc/
parametric descriptions
username
session
password
username
Use the session ID to keep the same IP address for upcoming queries. Sessions have no expiration time and will run indefinitely. Random string; 0-9, A-z characters are supported.
password
In this example, the query proxy.smartproxycn.com is executed from a random IP.
  var request = require('request');

  request({
    'url':'https://api.ip.cc/',
    'method': "GET",
    'proxy':'http://USERNAME:PASSWORD@proxy.smartproxycn.com:1000'
  },function (error, response, body) {
    if (!error && response.statusCode == 200) {
      console.log(body);
    }
  })
Issue a request

No session control requests will be sent using a random IP each time:

curl -x USERNAME:[email protected]:1000 https://api.ip.cc/

Specify the region and use the IP of the specified region:

curl -x USERNAME_area-US:[email protected]:1000 https://api.ip.cc/

Holds the session, which remains unchanged for as long as the agent is available:

curl -x USERNAME_session-testsession:[email protected]:1000 https://api.ip.cc/

Maintains the session and automatically changes to a new IP every 1 minute:

curl -x USERNAME_life-1:[email protected]:1000 https://api.ip.cc/
Test example
Control session
Control of multiple areas
Control of egress IPs
Control of global mixing
smartproxy