Skip to main content

pybitlaunch is a python client library for accessing the BitLaunch API.

Project description

pybitlaunch

pybitlaunch is a python library for accessing the BitLaunch API.

You can view BitLaunch API docs here: https://developers.bitlaunch.io/

Install

Source

git clone https://github.com/bitlaunchio/pybitlaunch.git
cd pybitlaunch
python setup.py install

PIP

pip install -U pybitlaunch

Usage

import pybitlaunch

Authentication

You must use your API Token to authenticate with BitLaunch API. You can (re)generate your access token on the BitLaunch API Page.

You can then use your token to create a new client.

client = pybitlaunch.Client(token)

Documentation

For a comprehensive list of examples, check out the API documentation.

Account

Show

accountObj = client.Account.Show()
if accountObj is not None:
    # process data

Usage

usage = client.Account.Usage("2020-10")
if usage is not None:
    # process data

History

history = client.Account.History(1, 25)
if history is not None:
    # process data

SSHKeys

List

sshKeyObjArray = client.SSHKeys.List()
if sshKeyObjArray is not None:
    # process data

Create

newKey = pybitlaunch.SSHKey(name="sshkey_name", content="sshkey_rsa_pub")

sshKeyObj, err = client.SSHKeys.Create(newKey)
if err is not None:
    # handle error
else:
    # process data

Delete

err = client.SSHKeys.Delete(sshKeyObj.id)
if err is not None:
    # handle error

Transactions

List

transactionObjArray, err = client.Transactions.List(page=1, pPage=25) # Optional: page, pPage
if err is not None:
    # handle error
else:
    # process data

Show

transactionObj, err = client.Transactions.Show(transactionObj.id)
if err is not None:
    # handle error
else:
    # process data

Create

newTransaction = pybitlaunch.Transaction(
    amountUSD = 20,
    cryptoSymbol = None, # Optional
    lightningNetwork = None # Optional
)

transactionObj, err = client.Transactions.Create(newTransaction)
if err is not None:
    # handle error
else:
    # process data

CreateOptions

Show

createOptionsArray, err = client.CreateOptions.Show(hostID)
# createOptionsArray = ['hostID', 'image', 'region', 'size', 'available', 'bandwidthCost', 'planTypes', 'hostOptions']
if err is not None:
    # handle error
else:
    # process data

Servers

List

serverObj, err = client.Servers.List()
if err is not None:
    # handle error
else:
    # process data

Show

serverObj, err = client.Servers.Show(serverObj.id)
if err is not None:
    # handle error
else:
    # process data

Create

newServer = pybitlaunch.Server(
    name = "myServer",
    hostID = 4,
    hostImageID = "10000",
    sizeID = "nibble-1024",
    regionID = "lon1",
    password = "MySecurePassword", # Optional must use sshKeys instead
    sshKeys = [sshKeyObj["id"]], # Optional must use password instead
    initscript = None # Optional
)

serverObj, err = client.Servers.Create(serverObj)
if err is not None:
    # handle error
else:
    # process data

Destroy

err = client.Servers.Destroy(serverObj.id)
if err is not None:
    # handle error

Rebuild

createOpts, err = client.CreateOptions.Show(4)
if err is not None:
    # handle error

newImage = pybitlaunch.RebuildImage(
    createOpts["image"][0]["versions"][1]["id"],
    createOpts["image"][0]["versions"][1]["description"]
)

err = client.Servers.Rebuild(serverObj.id, newImage)
if err is not None:
    # handle error

Resize

err = client.Servers.Resize(serverObj.id, "nibble-2048")
if err is not None:
    # handle error

Restart

err = client.Servers.Restart(serverObj.id)
if err is not None:
    # handle error

Protection

server, err = client.Servers.Protection(serverObj.id, True)
if err is not None:
    # handle error
else:
    # process data

SetPorts

ports = [
    pybitlaunch.Port(1234, "tcp"),
    pybitlaunch.Port(1234, "udp"),
    pybitlaunch.Port(1235, "tcp"),
]

server, err = client.Servers.SetPorts(serverObj.id, ports)
if err is not None:
    # handle error
else:
    # process data

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybitlaunch-1.1.1.tar.gz (8.4 kB view details)

Uploaded Source

File details

Details for the file pybitlaunch-1.1.1.tar.gz.

File metadata

  • Download URL: pybitlaunch-1.1.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.62.3 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.9

File hashes

Hashes for pybitlaunch-1.1.1.tar.gz
Algorithm Hash digest
SHA256 6947254cb241ce143fe6446af0d5a1d7cd6d9f2342f28d97ca4fc4ad246bb34f
MD5 fc056206a3842bb340a6149b581937ca
BLAKE2b-256 4107035e9f86d6574fa6d112049e38e6f47befa0439110aef6d11dd7551136d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page