PHPBitLaunch is a PHP client library for accessing the BitLaunch API.
You can view BitLaunch API docs here: https://developers.bitlaunch.io/
composer require "bitlaunchio/phpbitlaunch"
require_once('vendor/autoload.php');
// Create a PHPBitLaunch Client
$client = new PHPBitLaunch\Client('API_KEY');
Show account details
use \PHPBitLaunch\Exceptions\RuntimeException;
try {
$account = $client->account()->show();
} catch (RuntimeException $e) {
// Handle Error
}
Show account usage
use \PHPBitLaunch\Exceptions\RuntimeException;
try {
$usage = $client->account()->usage('2022-01');
} catch (RuntimeException $e) {
// Handle Error
}
Show account activity
use \PHPBitLaunch\Exceptions\RuntimeException;
try {
$history = $client->account()->history(1, 20);
} catch (RuntimeException $e) {
// Handle Error
}
Show create options for a host
use \PHPBitLaunch\Exceptions\RuntimeException;
try {
$opts = $client->createOptions()->show(4);
} catch (RuntimeException $e) {
// Handle Error
}
Add an SSH key
use \PHPBitLaunch\Exceptions\RuntimeException;
$keyName = 'My SSH Key';
$keyContent = 'ssh-rsa AAA......';
try {
$key = $client->sshKey()->create($keyName, $keyContent);
} catch (RuntimeException $e) {
// Handle Error
}
List the SSH keys
use \PHPBitLaunch\Exceptions\RuntimeException;
try {
$keys = $client->sshKey()->list();
} catch (RuntimeException $e) {
// Handle Error
}
Delete an SSH key
use \PHPBitLaunch\Exceptions\RuntimeException;
try {
$client->sshKey()->delete('aaaaaaaaaaabbbbbbbbbbbbb');
} catch (RuntimeException $e) {
// Handle Error
}
Create a new transaction
use \PHPBitLaunch\Exceptions\RuntimeException;
$amountUsd = 20;
$cryptoSymbol = 'BTC';
try {
$transaction = $client->transaction()->create($amountUsd, $cryptoSymbol);
} catch (RuntimeException $e) {
// Handle Error
}
List the transaction history
use \PHPBitLaunch\Exceptions\RuntimeException;
try {
$transactions = $client->transaction()->list(1, 25);
} catch (RuntimeException $e) {
// Handle Error
}
Show a transaction
use \PHPBitLaunch\Exceptions\RuntimeException;
try {
$transaction = $client->transaction()->show('aaaaaaaaaaabbbbbbbbbbbbb');
} catch (RuntimeException $e) {
// Handle Error
}
Create a server
use \PHPBitLaunch\Exceptions\RuntimeException;
$opts = new \PHPBitLaunch\Types\ServerCreateOptions([
'name' => 'My Server',
'hostID' => 4,
'hostImageID' => '10002',
'sizeID' => 'nibble-1024',
'regionID' => 'ams1',
'password' => 'secure_password',
]);
try {
$server = $client->server()->create($opts);
} catch (RuntimeException $e) {
// Handle Error
}
List your servers
use \PHPBitLaunch\Exceptions\RuntimeException;
try {
$servers = $client->server()->list();
} catch (RuntimeException $e) {
// Handle Error
}
Show a server
use \PHPBitLaunch\Exceptions\RuntimeException;
try {
$server = $client->server()->show('aaaaaaaaaaabbbbbbbbbbbbb');
} catch (RuntimeException $e) {
// Handle Error
}
Destroy a server
use \PHPBitLaunch\Exceptions\RuntimeException;
try {
$client->server()->destroy('aaaaaaaaaaabbbbbbbbbbbbb');
} catch (RuntimeException $e) {
// Handle Error
}
Rebuild a servers image
use \PHPBitLaunch\Exceptions\RuntimeException;
$hostImageID = '12001';
$imageDescription = 'Debian 10';
try {
$client->server()->rebuild('aaaaaaaaaaabbbbbbbbbbbbb', $hostImageID, $imageDescription);
} catch (RuntimeException $e) {
// Handle Error
}
Resize a server
use \PHPBitLaunch\Exceptions\RuntimeException;
try {
$client->server()->resize('aaaaaaaaaaabbbbbbbbbbbbb', 'nibble-2048');
} catch (RuntimeException $e) {
// Handle Error
}
Restart a server
use \PHPBitLaunch\Exceptions\RuntimeException;
try {
$client->server()->restart('aaaaaaaaaaabbbbbbbbbbbbb');
} catch (RuntimeException $e) {
// Handle Error
}
Stop a server
use \PHPBitLaunch\Exceptions\RuntimeException;
try {
$client->server()->stop('aaaaaaaaaaabbbbbbbbbbbbb');
} catch (RuntimeException $e) {
// Handle Error
}
Enable/Disable protection for a server
use \PHPBitLaunch\Exceptions\RuntimeException;
try {
$server = $client->server()->protect('aaaaaaaaaaabbbbbbbbbbbbb', true);
} catch (RuntimeException $e) {
// Handle Error
}
Set the ports to use for protection
use \PHPBitLaunch\Exceptions\RuntimeException;
$ports = [
new \PHPBitLaunch\Types\Port([
'portNumber' => 1234,
'protocol' => 'tcp',
]),
new \PHPBitLaunch\Types\Port([
'portNumber' => 1235,
'protocol' => 'tcp',
]),
];
try {
$server = $client->server()->setPorts('aaaaaaaaaaabbbbbbbbbbbbb', $ports);
} catch (RuntimeException $e) {
// Handle Error
}