Skip to main content
What you’ll learn:
  • How to install the Metorial JavaScript SDK
  • How to use the SDK in the browser, Node.js, and Deno environments
  • How to make requests to the Metorial API using the SDK
Before you start:External resources:
1

Install the SDK

To install the Metorial JavaScript SDK, use npm or yarn:
npm install metorial
2

Using the SDK

To use the SDK, import the Metorial class and create an instance with your API key:
import Metorial from 'metorial';

let metorial = new Metorial({
  apiKey: '$$SECRET_TOKEN$$'
});
You can now use the metorial instance to make requests to the Metorial API.
3

Making Requests

To make a request, use the resource methods on the metorial instance:
// Get a server by ID
let server = await metorial.servers.get('srv_Rm4Mnheq2bfEPhBhP7SY');

// Update a server instance
let result = await metorial.serverImplementations.update('svi_Rm4Mnheq2bfEPhBhP7SY', {
  name: "updated name",
  description: "updated description"
});
Each method returns a Promise that resolves with the response data.
4

Using TypeScript

The SDK is written in TypeScript and includes type definitions for all API resources. You can use TypeScript to benefit from type checking and IntelliSense support:
import Metorial from 'metorial';

let metorial = new Metorial({
  apiKey: '$$SECRET_TOKEN$$'
});

let server = await metorial.servers.get('srv_Rm4Mnheq2bfEPhBhP7SY');