Package: pybitlaunch
pybitlaunchpybitlaunch is a python library for accessing the BitLaunch API.You can view BitLaunch API docs here:https://developers.bitlaunch.io/InstallSourcegitclonehttps://github.com/bitlaunchio/pybitlaunch.gitcdpybitlaunch
pythonsetup.pyinstallPIPpipinstall-UpybitlaunchUsageimportpybitlaunchAuthenticationYou must use your API Token to authenticate with BitLaunch API. You can (re)generate your access token on the BitLaunchAPI Page.You can then use your token to create a new client.client=pybitlaunch.Client(token)DocumentationFor a comprehensive list of examples, check out theAPI documentation.AccountShowaccountObj=client.Account.Show()ifaccountObjisnotNone:# process dataUsageusage=client.Account.Usage("2020-10")ifusageisnotNone:# process dataHistoryhistory=client.Account.History(1,25)ifhistoryisnotNone:# process dataSSHKeysListsshKeyObjArray=client.SSHKeys.List()ifsshKeyObjArrayisnotNone:# process dataCreatenewKey=pybitlaunch.SSHKey(name="sshkey_name",content="sshkey_rsa_pub")sshKeyObj,err=client.SSHKeys.Create(newKey)iferrisnotNone:# handle errorelse:# process dataDeleteerr=client.SSHKeys.Delete(sshKeyObj.id)iferrisnotNone:# handle errorTransactionsListtransactionObjArray,err=client.Transactions.List(page=1,pPage=25)# Optional: page, pPageiferrisnotNone:# handle errorelse:# process dataShowtransactionObj,err=client.Transactions.Show(transactionObj.id)iferrisnotNone:# handle errorelse:# process dataCreatenewTransaction=pybitlaunch.Transaction(amountUSD=20,cryptoSymbol=None,# OptionallightningNetwork=None# Optional)transactionObj,err=client.Transactions.Create(newTransaction)iferrisnotNone:# handle errorelse:# process dataCreateOptionsShowcreateOptionsArray,err=client.CreateOptions.Show(hostID)# createOptionsArray = ['hostID', 'image', 'region', 'size', 'available', 'bandwidthCost', 'planTypes', 'hostOptions']iferrisnotNone:# handle errorelse:# process dataServersListserverObj,err=client.Servers.List()iferrisnotNone:# handle errorelse:# process dataShowserverObj,err=client.Servers.Show(serverObj.id)iferrisnotNone:# handle errorelse:# process dataCreatenewServer=pybitlaunch.Server(name="myServer",hostID=4,hostImageID="10000",sizeID="nibble-1024",regionID="lon1",password="MySecurePassword",# Optional must use sshKeys insteadsshKeys=[sshKeyObj["id"]],# Optional must use password insteadinitscript=None# Optional)serverObj,err=client.Servers.Create(serverObj)iferrisnotNone:# handle errorelse:# process dataDestroyerr=client.Servers.Destroy(serverObj.id)iferrisnotNone:# handle errorRebuildcreateOpts,err=client.CreateOptions.Show(4)iferrisnotNone:# handle errornewImage=pybitlaunch.RebuildImage(createOpts["image"][0]["versions"][1]["id"],createOpts["image"][0]["versions"][1]["description"])err=client.Servers.Rebuild(serverObj.id,newImage)iferrisnotNone:# handle errorResizeerr=client.Servers.Resize(serverObj.id,"nibble-2048")iferrisnotNone:# handle errorRestarterr=client.Servers.Restart(serverObj.id)iferrisnotNone:# handle errorProtectionserver,err=client.Servers.Protection(serverObj.id,True)iferrisnotNone:# handle errorelse:# process dataSetPortsports=[pybitlaunch.Port(1234,"tcp"),pybitlaunch.Port(1234,"udp"),pybitlaunch.Port(1235,"tcp"),]server,err=client.Servers.SetPorts(serverObj.id,ports)iferrisnotNone:# handle errorelse:# process data