Package: openblu
OpenBlu-Python-WrapperOfficial Python wrapper around OpenBlu APIOverviewThis wrapper can be used to fetch servers from the OpenBlu API and retrieve their OpenVPN configuration.To make things easy, the library abstracts the JSON responses from the API inside three objects:Server-> Contains more detailed information from the server as described inOpenBlu's DocumentationServerListing-> Contains metadata from a server such as ping, country and locationOpenVPN-> Contained inside aServerobject, stores the OpenVPN configuratiom for the serverTheServerListingandServerobjects can be printed to get an overview of the server's information.InstallationTo install this wrapper, simply clone this repo withgit clone, then runpython3 setup.py installUsageFetch multiple serversTo fetch multiple servers, without their OpenVPN configuration, you can use thelist_servers()method of theopenblu.OpenBluAPIclass like shown belowfromopenbluimportOpenBluAPIapi=OpenBluAPI('access_key')# Get your access key at openblu.intellivoid.netservers=api.list_servers(filter_by=("germany","country"))Below the full documentation for thelist_serversmethod in Sphinx formatFetches OpenVPN servers from the OpenBlu API

:param filter_by: If not ``None``, filter the results by the given parameter. It must be a tuple containing a country name and either one of these strings (In this order): "country", "country_short". If "country_short" is the second element of the tuple, the country name must be the short form of its name (e.g. 'de' for germany or 'jp' for Japan) otherwise, the full extended form is required. Defaults to ``None``
:type filter_by: tuple, None, optional
:param order_by: If not ``None``, order the results by this order. It can either be ``'ascending'`` or ``'descending'``, defaults to ``None``.
:type order_by: str, None, optional
:param sort_by: Sorts the list by the given condition, defaults to ``None`` (no sorting). Possible choices are "score", "ping", "sessions", "total_sessions", "last_updated" and "created"
:type sort_by: str, None, optional
:param verbose: If ``True``, make the output verbose, default to ``False``
:type verbose: bool, optional
:returns servers_list: A list of class:ServerListing objects
:rtype servers_list: list
:raises OpenBluError: An proper subclass of OpenBluError is raised if something goes wrong. If the error cannot be determined, a generic OpenBluError is raisedGet a single serverAs described in OpenBlu's documentation, servers can be identified by a unique ID. That ID can be used to fetch a more detailed server object containing the OpenVPN server configuration from the OpenBlu API as shown below.
This server object also contains the server's IP addressfromopenbluimportOpenBluAPIapi=OpenBluAPI('access_key')# Get your access key at openblu.intellivoid.netservers=api.list_servers(filter_by=("germany","country"))server=servers[0]# Take the first entrysrv=api.get_server(server.id)# Retrieve the server's configurationBelow the full documentation for theget_servermethod in Sphinx formatFetches a single OpenVPN server from the OpenBlu API, given its unique ID

:param uuid: The unique ID of the desired server
:type uuid: string
:param verbose: If ``True``, make output verbose, default to ``False``
:type verbose: bool, optional
:returns: A class:Server object
:rtype: class: Server
:raises OpenBluError: An proper subclass of OpenBluError is raised if something goes wrong. If the error cannot be determined, a generic OpenBluError is raisedFor more examples and a deeper description check theexamples.pyfile in this repoObjects' overviewHere are some example objects to get you started straight awayNote: All objects, when printed out, show all the information inside the object itself (includingNonevalues and such)ServerListingWhen printed out, aServerListingobject should look like the following, although the corresponding parameters may differ.ServerListing(
id=dbd24ff8e4802f22,
host_name=vpn774575625,
country=Germany,
country_short=DE,
score=366198,
ping=28,
sessions=66,
total_sessions=30926,
last_updated=1576539451,
created=1576529629)ServerThe server object has a similar output to theServerListing, but (of course) it contains different and more descriptive information about a single server.Server(
id=dbd24ff8e4802f22,
host_name=vpn774575625,
country=Germany,
country_short=DE,
score=366198,
ping=28,
sessions=66,
total_sessions=30926,
ip_address=78.54.226.91,
openvpn=<OpenVPN object at 0x7b2b706f10>,
last_updated=1576539451,
created=1576529629)OpenVPN objectsOpenVPN objects' output is much less verbose, because printing all of the object's parameters would literally need pages of output, their attributes are still accessible both via dot notation and via dict-like accessing.For the sake of completeness, all the object's parameters are listed here; to get detailed info about their meaning refer toOpenBlu's official docs- parameters
- certificate_authority
- certificate_authority_b64
- certificate
- certificate_b64
- key
- key_b64
- ovpn_configurationExceptionsThe wrapper implements 3 exceptions:OpenBluError-> Generic parent class for all exceptions, also raised when an error other than 401 and 404 is returned by the APIServerNotFound-> When an invalid server ID is provided to the APIUnauthorizedAccess-> When an invalid access key is provided to the APIOther errors, such as JSON decoding errors or HTTP failures, are not catched and must be handled by the end user itself.Last, but not leastAll objects objects support dict-like accessing as well as dot notation, which means that doingserver["id"]orserver.idyields the same result.