Skip to content

cp6/hosthatch-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HostHatch VPS API class wrapper

An easy to implement and use PHP class wrapper for the HostHatch VPS API version 1.

Generic badge Generic badge Generic badge

Table of contents

Note the Host Hatch API is seemingly still in development and not finalized or reliable

0.1 changes

  • Initial commits and files

Requirements

  • PHP 8.2

Usage

Install with composer:

composer require corbpie/hosthatch-api

Use like:

require __DIR__ . '/vendor/autoload.php';

use Corbpie\HostHatchAPI\HostHatch;

$hh = new HostHatch();

Setting your API key:

Option 1

Line 9 HostHatch.php

const API_KEY = 'XXXX-XXXX-XXXX';

Option 2

When you call a new class you can initialise with the API key

$hh = new HostHatch('PUT-API-KEY-HERE');

List available Host Hatch servers to deploy

$hh->getProducts();

returns array


Get your current servers

$hh->getServers();

returns array


Get server

int $server_id

$hh->getServer($server_id);

returns array


Get server status

int $server_id

$hh->getServerStatus($server_id);

returns array


Boot server

int $server_id

$hh->bootServer($server_id);

returns array


Shutdown server

int $server_id

$hh->shutdownServer($server_id);

returns array


Reboot server

int $server_id

$hh->rebootServer($server_id);

returns array


Upgrade server

int $server_id

array $parameters

$parameters = [
  'product' => 'nvme-8gb',
  'upgrade_disk' => false 
];

$hh->upgradeServer($server_id, $parameters);

returns array


Cancel server

int $server_id

array $parameters

$parameters = [
  'reason' => 'No longer need this VPS',
  'immediate' => false
];

$hh->cancelServer($server_id, $parameters);

returns array


Deploy / create a server

array $parameters

$parameters = [
  'product' => 'nvme-2gb',
  'location' => 'AMS',
  'billing' => 'monthly',
  'image' => 'ubuntu22',
  'hostname' => 'test.com'
];

$hh->deployServer($parameters);

returns array


Releases

No releases published

Packages

No packages published

Languages