Skip to main content

Fetching a List of Available Locations

Locations represent a cluster of servers at a specific geographical location. The SDK will use proper caching so that this list is frequently updated.

get_locations_for_protocols ​

Fetch list of locations with an HTTP call or from local HTTP cache, small response payload size. This will return all available locations for the provided subscription id and protocols. A shortcut to this method is get_locations() which will set the protocols to lightway, openvpn and wireguard.

Parameters​

NameDescription
subscription_idID of the subscription which has a VPN entitlement. You can obtain that subscription id as described in Obtaining a VPN Subscription ID
protocolsAn array of protocol identifiers.
lightway
openvpn
wireguard
proxy

Returns​

Array of ServerLocation objects if successful, InstanceDiscoveryException otherwise.

get_full_locations_for_protocols​

Fetch full dataset of all locations and endpoints, around 3MB JSON payload compressed to around 300kb over the wire, or read from local cache. The method returns all available locations for the provided subscription id and protocols.

This method refreshes over the network once the cache expires, so it never returns stale data. The returned FullLocationsResult carries a cacheState flag indicating whether the dataset was freshly Fetched or served from a still-fresh Cached copy. A cached dataset is only reused for the subscription it was originally fetched for.

The set of protocols must be full list of protocols supported by current client.

Parameters​

NameDescription
subscription_idID of the subscription which has a VPN entitlement. You can obtain that subscription id as described in Obtaining a VPN Subscription ID
protocolsAn array of all protocol identifiers supported by current client.
lightway
openvpn
wireguard
proxy

Returns​

FullLocationsResult upon success, InstanceDiscoveryException otherwise.

FullLocationsResult​

NameTypeDescription
locationsArray of ServerLocationThe locations matching the requested protocols
cacheStateCacheStateFetched if retrieved over the network, Cached if served from a still-fresh cache

CacheState​

Indicates where a returned value came from, relative to the local cache.

ValueDescription
FetchedFreshly fetched over the network (and the cache refreshed). Only from getFullLocationsForProtocols.
CachedServed from cache while still within its freshness window.
StaleServed from cache after its freshness window elapsed. Only from the cache-only accessors (getEndpointsForProtocols, getDnsIp).

ServerLocation​

NameDescription
idUnique ID of that location
nameDisplay Name of that location
latitudeGeographical Latitude of that location
longitudeGeographical Longitude of that location
country_codeISO3166-1 alpha2 Country Code
instance_count_minMinimum number of instances in that location
instance_count_maxMaximum number of instances in that location
is_geolocatedIf true, this instance is physically not located in that location, but emulates the location by using a specific set of IPs, which are associated with that location
popularity_orderIf set, it defines the popularity of that location, which can be used to show popular locations in the UI of the app
test_ipsA set of IPs, which this instance provided to run speedtests