Quick Start

Get up and running with the LegionEdge Platform in minutes

This guide walks you through installing the SDK, authenticating, creating your first project, and making API calls -- all in under five minutes.

Prerequisites

  • Node.js 18+ installed
  • A LegionEdge account with an API key (get one here)

Step 1: Initialize Your Project

mkdir my-legionedge-app && cd my-legionedge-app
npm init -y
npm install @legionedge/sdk typescript tsx

Step 2: Configure Your API Key

Create a .env file:

LEGIONEDGE_API_KEY=le_live_your_api_key_here

Step 3: Create the Client

Create a file called index.ts:

import { LegionEdge } from "@legionedge/sdk";

const client = new LegionEdge({
  apiKey: process.env.LEGIONEDGE_API_KEY!,
});

async function main() {
  // Verify authentication
  const me = await client.auth.whoami();
  console.log(`Hello, ${me.name}!`);

  // List your organizations
  const orgs = await client.organizations.list();
  console.log(`You belong to ${orgs.data.length} organization(s).`);

  const orgId = orgs.data[0].id;

  // Create a new project
  const project = await client.projects.create({
    name: "quickstart-demo",
    organizationId: orgId,
    description: "My first LegionEdge project",
    settings: {
      defaultEnvironment: "development",
    },
  });
  console.log(`Project created: ${project.id}`);

  // List projects in the organization
  const projects = await client.projects.list({ organizationId: orgId });
  for (const p of projects.data) {
    console.log(`  - ${p.name} (${p.id})`);
  }

  // Fetch project details
  const details = await client.projects.get(project.id);
  console.log(`Project "${details.name}" is in ${details.settings.defaultEnvironment} mode.`);

  // Clean up: delete the demo project
  await client.projects.delete(project.id);
  console.log("Demo project deleted.");
}

main().catch(console.error);

Step 4: Run It

npx tsx index.ts

Expected output:

Hello, Jane Developer!
You belong to 1 organization(s).
Project created: proj_a1b2c3d4
  - quickstart-demo (proj_a1b2c3d4)
Project "quickstart-demo" is in development mode.
Demo project deleted.

Step 5: Explore the API

The SDK client is organized into namespaces that mirror the API:

// Authentication
client.auth.whoami();
client.auth.refreshToken();

// Organizations
client.organizations.list();
client.organizations.get(orgId);

// Projects
client.projects.create({ ... });
client.projects.list({ organizationId });

// Users and teams
client.users.get(userId);
client.teams.addMember({ teamId, userId, role: "member" });

// Resources
client.resources.list({ projectId });
client.resources.allocate({ projectId, type: "compute", config: { ... } });

Next Steps