VPN Unlimited SDK for Windows is shipped as a dynamic link library. It is written in C++ and is available for Windows Vista and later. Supports MSVC 2019 compilers. You may download both 32 bit and 64 bit versions of the library.
Drag and drop the 'lib' folder into your project directory.
In order to use the SDK, you have to link the following libraries to your project:
Then, include header files from the 'include' folder into your project.
After that, copy the 'openvpn' and 'wireguard' folders somewhere into the project output directory. You'll need it to connect to VPN servers and configure the Windows network. Below you can find more detailed infromation.
After setup is done, you will be able to use all the classes from the SDK by including header files from the 'include' folder.
The Ńurrent version of the VPN Unlimited SDK uses the following libraries under the hood:
If your project uses one of these libraries and you get conflicts, please contact the VPN Unlimited support team for further investigation.
This SDK is designed in the classical OOP style. We don't provide one single interface, but rather a variety of interfaces which you can use in any desired combination. All API network calls are asynchronous, but are processed in a single thread query. All classes and structures belong to the VPNU namespace.
You can view the complete documentation for each class at the Reference page.
Here we just briefly describe the standard workflow.
There are three main SDK parts: API Talker, VPN Manager, VPN Service.
In order to use the SDK, it is necessary to set a unique service name (you can recieve it from the VPN Unlimited team) and override some interfaces. You can find complete information below.
The ApiTalker class allow you to send requests to VPN Unlimited API servers. To send a specific request you just need to call one of the ApiTalker methods. To retrieve the result, you need to override the IAPIDelegate interface and declare response handlers. Each handler has a unique operation id (the same as the one returned by the ApiTalker method), a response status, and related info such as parameters.
The IAppInfoProvider interface must be overridden and used as a parameter of the ApiTalker constructor. There are 4 methods you need to override:
The VPNManager class is a singleton class, which provides any VPN related logic. To initialize this class you need to define VPNSettings, which set the path to the 'openvpn.exe' file (part of the SDK package), the path to the temporary folder (where logs and configs will be placed), the unique service name (the same as for ApiTalker), and the unique IKEv2 protocol connection name. Also you need to override the IVPNDelegate interface to handle VPN connection statuses and errors.
The VPNService class is a singleton class, which helps you to maintain the VPN Connection outside the app. It is needed when you don't want your application to request admin rights. The best way to implement this is to create the Windows service that starts automatically and doesn't require to request admin rights everytime.
IAppInfoProvider override example:
class AppInfoProvider : public VPNU::IAppInfoProvider { virtual std::string getApplicationName() { return "BestVPNApplicationEver"; } virtual std::string getApplicationVersion() { return "1.0"; } virtual void saveValue(const std::string& key, const std::string& value) { // save somewhere inside a user's system, in the registry, for example } virtual std::string getValue(const std::string& key) const { // read from the registry, for example } };
IAPIDelegate override example:
class APIDelegate : public VPNU::IAPIDelegate { virtual void onAccountStatus(uint64_t operation_id, const VPNU::AccountStatus& status, VPNU::tVPNError error) { checkOperationId(operation_id); // You may implement the method to check if the response with such id is valid and not expired. Not necessary. if(error != VPNU::SUCCESS) { // something is wrong } else { // process status } } ... };
IVPNDelegate override example:
class VPNDelegate : public VPNU::IVPNDelegate { virtual void stateChanged(const VPNU::VPNState& state) { // update the VPN connection status in the application UI } virtual void errorOccurred(const VPNManagerError& error) { // show an error notification } ... };
Initialization:
AppInfoProvider* infoProvider = new AppInfoProvider(); APIDelegate* apiDelegate = new APIDelegate(); VPNU::APITalker* talker = new VPNU::APITalker("bestvpnserviceever.42", infoProvider, vpnDelegate); VPNDelegate* vpnDelegate = new VPNDelegate(); VPNU::VPNSettings settings("bestvpnserviceever.42", "C://bestvpn-temp/", "openvpn.exe", "BESTVPN IKEv2 Connection", "WireImpl.exe"); VPNU::VPNManager::getInstance().init(vpnDelegate, settings)
If you want to use OpenVPN or Wise protocols, then TAP-Windows is required to be installed on a user's system. Otherwise you will not be able to connect this user to any VPN server via OpenVPN or Wise. You may find it inside the SDK package. It's only be possible to connect via IKEv2 protocol.
In every example in the FAQ section it is implicitly considered that the SDK is set up properly before any calls.
First, get the APITalker instance.
VPNU::APITalker* talker = ...
Then, you can log in using user's credentials:
std::string login = "login@some.domain"; std::string password = "password"; talker->login(login, password);
You will receive the operation response inside your IAPIDelegate instance: IAPIDelegate::onLoginComplited(...)
If the authorization is successful, you may continue to use APITalker. Otherwise you'll always get the INVALID_SESSION error.
First, get the APITalker instance.
VPNU::APITalker* talker = ...
Then, you can register the new user with user's credentials.
std::string login = "login@some.domain"; std::string password = "password"; std::string firstName = "Lorem"; std::string lastName = "Ipsum"; talker->registerAccount(login, password, firstName, lastName, "", "");
You will receive the operation response inside your IAPIDelegate instance: IAPIDelegate::onRegistrationCompleted(...)
If the registration is successful, the newly created user will be automatically logged in.
First, get the APITalker instance.
VPNU::APITalker* talker = ...
In order to perform this operation successfully, you have to be logged in. Please see two previous answers.
talker->logout();
You will receive the operation response inside your IAPIDelegate instance: IAPIDelegate::onLoggedOut(...)
If the logout is successful, you need to log in or register a new user before you continue to send any other requests to API servers.
First, get the APITalker instance.
VPNU::APITalker* talker = ...
In order to perform this operation successfully, you have to be logged in.
talker->getAccountStatus();
You will receive user account status info inside your IAPIDelegate instance: IAPIDelegate::onAccountStatus(...)
First, get the APITalker instance.
VPNU::APITalker* talker = ...
In order to perform this operation successfully, you have to be logged in.
talker->getVPNServersList();
You will receive VPN servers list inside your IAPIDelegate instance: IAPIDelegate::onVPNServersList(...)
First, get the APITalker instance.
VPNU::APITalker* talker = ...
In order to perform this operation successfully, you have to be logged in.
// get VPN Server from VPNServersList you want connect to. VPNU::VPNServer server = ... // get profile for the server // Note: you may choose any supported protocol. talker->getVPNProfile(server.mRegion, VPNU::VPNProtocol::OpenvpnPlain);
You will receive VPN profile inside your IAPIDelegate instance: IAPIDelegate::onVPNProfile(...)
Then, get the VPNManager instance.
VPNU::VPNManager* vpnmanager = ... // Set retrieved inside IAPIDelegate::onVPNProfile(...) profile VPNU::VPNProfile profile = ... vpnmanager->runVPN(VPNU::VPNProtocol::OpenvpnPlain, profile);
You will receive VPN connection state inside your IVPNDelegate instance: IVPNDelegate::stateChanged(...)
Note: if there any problems with VPN connection, IVPNDelegate::errorOccurred(...)
method may be emitted.First, get the VPNManager instance.
VPNU::VPNManager* vpnmanager = ... // terminate vpn connection vpnmanager->stopVPN();
You will receive VPN connection state changed inside your IVPNDelegate instance: IVPNDelegate::stateChanged(...)
Note: you may try to stop VPN connection even if it's not running. Nothing will happen.