Currently, the SDK is compatible with Bun, Node.js and Deno.

Installing

# NPM
npm i @onehop/js

# Or with Yarn
yarn add @onehop/js

# Or with Bun
bun add @onehop/js

Or in Deno, we recommend serving from jspm.dev. This will ensure dependencies are bundled and cached for you.

import {Hop} from 'https://jspm.dev/@onehop/js@<version>';

Creating an SDK Instance

To use the SDK, you must first create a project token. You can also use a PAT (personal access token), however this is not recommended as it has access to all of your projects.

JS
import {Hop} from '@onehop/js';

const token = 'ptk_xxx';

// Export the Hop SDK instance so you can use it throughout your codebase
export const hop = new Hop(token);

// Example: Creating a deployment
await hop.ignite.deployments.create({
	name: 'postgres',
	container_strategy: 'manual',
	type: RuntimeType.EPHEMERAL,
	version: '12-12-2022',
	image: {
		name: 'postgres',
		auth: null,
		gh_repo: null,
	},
	env: {
		POSTGRES_PASSWORD: 'password',
		POSTGRES_USER: 'postgres',
		POSTGRES_DB: 'postgres',
	},
	resources: {
		vcpu: 0.5,
		ram: '128MB',
		vgpu: [],
	},
	restart_policy: RestartPolicy.NEVER,
});