API Reference

Get Optimized Server

Estimated reading: 6 minutes

Optimizing VPN server selection is crucial for ensuring the best possible performance and user experience. By leveraging APIs, users can dynamically find and connect to the most suitable VPN servers based on various factors such as latency, load, and geographical location. This article provides a technical overview of how to retrieve an optimized VPN server via API for a better VPN connection.

Overview

Retrieving an optimized VPN server via API involves sending a request to an endpoint designed to assess and return the best available server based on current conditions. This operation helps users and administrators select a server that provides optimal performance, minimizing latency and improving connection stability.

  • URL: <base url>/speedtest/v4/serversWithoutPsk
  • Request Method: POST

Payload

KeyTypePass inDescription
X-AccessToken*StringHeader accessToken retrieved from Get Access Token endpoint
sCountrySlug*StringBodycountries.iso_code retrieved from Get Subscribed Countries endpoint
iCityIdIntegerBodycities.id retrieved from Get Subscribed Cities endpoint
iResellerId*IntegerBodyresellerId retrieved from Get Access Token endpoint
sProtocolSlug1*StringBodyprotocols.protocol retrieved from Get Subscribed Protocols endpoint
sProtocolSlug2StringBodyprotocols.protocol retrieved from Get Subscribed Protocols endpoint
sProtocolSlug3StringBodyprotocols.protocol retrieved from Get Subscribed Protocols endpoint
sUsername*StringBodyVPN Username of the user requesting connection
sDeviceType*StringStringType of device
Possible values: android | ios | mac | windows
iChannelIdStringStringchannels.id retrieved from Get Subscribed Channels endpoint
iMcsIntegerBody0 for returning free servers and 1 for paid.
(0/1)
iMultiPortIntegerBody0 for getting multiport servers
(0/1)
sDataCentersjsonBodyJson array of datacenters [123,122]
sIpStringBodyIP address of the user
iNattingIntegerBody1 for returning non-natted servers, 2 for natted
aServerFilterJsonBodyExclude servers from server selection logic
Sample JSON: [ { ‘nasidentifier’ : ‘lux-01-01-01′,’type’ : ‘include | exclude’} ]
aTagsFilterJsonBodyExclude tags from server selection logic
Sample [“TAG_RAM_BASED”, TAG_OVPN_OBF]
bIsExperimentUserIntegerBodyIndicates either the given user belongs to experiment cohort, 0=no,1=Yes
sPasswordStringBodyVpn user password in encrypted for (api link for password encryption)
*Mandatory if WireGuard protocol is requested
sClientPublicKeyStringBodyClients device public key
*Mandatory if WireGuard protocol is requested
sSdkVersionStringBodySDK version for telemetry(not in use rightnow)
*Mandatory if WireGuard protocol is requested
(*) Required Parameter

Response

KeyTypeDescription
headerObjectContains Object describing error code and error messages
bodyArrayObject containing servers
serversArrayarray of servers containing keys mentioned below
hostStringHost name of the server to be dialed
hub_keyStringHub key the password required for connection in case of stealthvpn
acknowledgement_serverStringHost of the acknowledgement server
port_numberStringPort number to be pinged for checking servers availability
protocol_noIntegerProtocol number Requested
destination_countryIntegerId of the destination country
server_typeStringType of server (windows/linux)
speedtest_methodStringCalculation method against which the server is returned. Dc is for Datacenter, LL is for Latitude/Longitude, FO is for failover and AFO is for advance feature failovers .
(DC/LL/FO/AFO)
filter_successInteger0 or 1
Indicated either the provided json of server filter applied to result or not
ram_basedInteger0 or 1
Indicated that return server is ram based or not
ovpn_obfInteger0 or 1
Indicates that return server supports ovpn obfuscation
ip_translationInteger0 or 1
Integer 0 or 1 Indicates that return server is natted or non-natted 0=non-natted,1=natted
nasidentiferStringServer’s Name
iperf_client_ipStringIperf client ip
iperf_port_rangeStringIperf port range
iperf_client_statusStringIperf client status
configuration_versionStringOVPN configuration version
configurationStringOVPN configuration
is_experiment_serverInteger0 or 1
Indicates that either the returned server belongs to experiment cohort
wireguard_configurationStringConfiguration required for wireguard connection

Possible API error codes

CodeMessageDescription
1001Invalid Device Type Provided !Provided device type is invalid.
1002Reseller id provided is either Invalid or Expired !Reseller has expired or is invalid .
1003Country Not Allowed !Reseller not allowed connection to the requested country
1004City Not Allowed !Reseller not allowed connection to the requested city
40001Protocol is either not available or not allowed, please try again later or switch to other protocol!Reseller not allowed connection to the requested protocol
40002Advance Features Not Allowed !Reseller not allowed connection with requested advance features
1007Failed to Validate Connection Request !Some error occurred while validating reseller’s inventory.
1008Sorry! Your Multi Login Limit has ExceededAllowed logins per day exceeded by user. Renews 24 hrs.
1009Session Limit for User Exceeded !Allowed sessions per day exceeded by user.
Renews 24 hrs.
1010Unable to generate Psk!Some error occurred while generating psk.
1011Something went wrong, inserting data!Some error occurred while generating psk.
1012Invalid Reseller Id Provided !Invalid Reseller Id Provided
1013Invalid Country Id Provided !Invalid Country Id Provided
1014Invalid Protocol No Provided !Invalid Protocol No Provided
1015Invalid Ip Address Provided !Invalid clients ip address provided
1016Invalid Username Provided !Invalid Username Provided
1017Invalid Channel Id Provided !Invalid Channel Id Provided
1032All NAT Servers are busy, please try again later or switch to other network type !All NAT Servers are busy, please try again later or switch to other network type
1031No Servers Found !No Servers Found with provided params.
1050Invalid Params !One of the Required Params are not provided.
1051Username Not found !The provided username does not exists
5002invalid service KeysProvided advance features slugs are invalid
5004User not foundProvided username not found in system
5006Country not found in user inventoryProvided country not found in users inventory
5007Protocol not found in user inventoryProvided Protocol not found in users inventory
5008Invalid protocol number providedProvided protocol number is invalid
10007Your account has expired. Buy premium account and enjoy unlimited freedomIncase VPN account has been expired
10008Your account has been disabled, please contact our 24×7 live chat support for more detailsProvided VPN account is disabled
1009Reseller not foundProvided reseller id not found
1009Reseller not foundProvided reseller id not found
1052Channel belongs to country which is not allowed to resellerChannel belongs to country which is not allowed to reseller
40007Invalid Tag Provided!Tags provided in aTag params are not valid
40008All Ram based servers are busy, please try again later or switch to other network type!!No ram based server is available is requested destination
1036failed to upload client public keyWireguard middleware failed to upload client’s public key
1035No response from WireGuard ServerNo wireguard server is available against provided params
40003password is invalidGiven password is invalid
40004Unable to connect with WireGuard Server!Wireguard server failed to respond
40005sPassword, sClientPublicKey & sSdkVersion is mandatory when WireGuard protocol is requested!Not all Parameters are provided
40006WireGuard protocol is not allowed on this endpoint!If someone provide wireguard protocol to old endpoints of speedtest

Sample Response

{
  "header": {
    "code": 1,
    "message": "Success"
  },
  "body": {
    "servers": [{
      "host": "xxxxxx.pointtoserver.com",
      "hub_key": "",
      "acknowledgement_server": "xxxxxx.pointtoserver.com",
      "port_number": "30",
      "protocol_no": 8,
      "country": "US",
      "multiport": 0,
      "server_type": "linux",
      "speedtest_method": "DC"
      "filter_success": false
      "ram_based": 0
      "ovpn_obf": 0
      "ip_translation": 1
      "nasidentifer": "lux-01-xx-xx",
      "iperf_client_ip": "...........com",
      "iperf_port_range": "5201:5210",
      "iperf_client_status": 0,
      "configuration_version": "",
      "configuration": "", 
      "Wireguard_configuration" : "",
      "Is_experiment_server" : ""
    }]
  }
}
Share this Doc

Get Optimized Server

Or copy link

On This Page