Skip to content

Commit 1676b0a

Browse files
committed
cp dines
1 parent c01168f commit 1676b0a

1 file changed

Lines changed: 84 additions & 3 deletions

File tree

README.md

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,92 @@
22

33
[![NPM version](https://img.shields.io/npm/v/@runloop/api-client.svg)](https://npmjs.org/package/@runloop/api-client) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@runloop/api-client)
44

5-
This library provides convenient access to the Runloop REST API from server-side TypeScript or JavaScript.
5+
This library provides convenient access to the Runloop SDK & REST API from server-side TypeScript or JavaScript.
6+
7+
The additional documentation guides can be found at [docs.runloop.ai](https://docs.runloop.ai). The full API of this library can be found in [api.md](api.md).
8+
9+
The **RunloopSDK** is the recommended, modern way to interact with the Runloop API. It provides high-level object-oriented interfaces for common operations while maintaining full access to the underlying REST API through the `.api` property.
10+
11+
## Installation
12+
13+
```sh
14+
npm install @runloop/api-client
15+
```
16+
17+
## Quickstart
18+
19+
Here's a complete example that demonstrates the core SDK functionality:
20+
21+
```typescript
22+
import { RunloopSDK } from '@runloop/api-client';
23+
24+
const sdk = new RunloopSDK({
25+
bearerToken: process.env.RUNLOOP_API_KEY, // This is the default and can be omitted
26+
});
27+
28+
// Create a new devbox and wait for it to be ready
29+
const devbox = await sdk.devbox.create();
30+
31+
// Execute a synchronous command
32+
const result = await devbox.cmd.exec({ command: 'echo "Hello, World!"' });
33+
console.log('Output:', await result.stdout()); // "Hello, World!"
34+
console.log('Exit code:', result.exitCode); // 0
35+
36+
// Start a long-running HTTP server asynchronously
37+
const serverExec = await devbox.cmd.execAsync({
38+
command: 'npx http-server -p 8080',
39+
});
40+
console.log(`Started server with execution ID: ${serverExec.executionId}`);
41+
42+
// Check server status
43+
const state = await serverExec.getState();
44+
console.log('Server status:', state.status); // "running"
45+
46+
// Later... kill the server when done
47+
await serverExec.kill();
48+
49+
await devbox.shutdown();
50+
```
51+
52+
## Core Concepts
53+
54+
### RunloopSDK
55+
56+
The main SDK class that provides access to all Runloop functionality:
57+
58+
```typescript
59+
import { RunloopSDK } from '@runloop/api-client';
60+
61+
const sdk = new RunloopSDK({
62+
bearerToken: 'your-api-key',
63+
// ... other options
64+
});
65+
```
66+
67+
### Available Resources
68+
69+
The SDK provides object-oriented interfaces for all major Runloop resources:
70+
71+
- **`sdk.devbox`** - Devbox management (create, list, execute commands, file operations)
72+
- **`sdk.blueprint`** - Blueprint management (create, list, build blueprints)
73+
- **`sdk.snapshot`** - Snapshot management (list disk snapshots)
74+
- **`sdk.storageObject`** - Storage object management (upload, download, list objects)
75+
- **`sdk.api`** - Direct access to the legacy REST API client
76+
77+
78+
79+
80+
81+
82+
83+
84+
85+
86+
87+
88+
689

7-
The REST API documentation can be found on [runloop.ai](https://runloop.ai). The full API of this library can be found in [api.md](api.md).
890

9-
It is generated with [Stainless](https://www.stainless.com/).
1091

1192
## Installation
1293

0 commit comments

Comments
 (0)