> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dataerai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Node SDK

> Upload, download, and manage Dataerai metadata from Node.js. An event-based client over the transfer daemon.

The Node SDK is an event-based client for the `dataerai` transfer daemon. Operations resolve as soon as the daemon **accepts** them; transfer **progress** and **completion** arrive as events.

## Requirements

* Node.js 18+
* The `dataerai` binary on your system (see the [CLI overview](/cli/overview)).
* Signed in with `dataerai auth login` (see [Authenticate](/cli/authenticate)).

## Install

```bash theme={null}
npm install @dataerai/ipc-sdk
```

## Quickstart

```ts theme={null}
import { statSync } from "node:fs";
import { DataeraiClient } from "@dataerai/ipc-sdk";

const client = new DataeraiClient({ binaryPath: "/usr/local/bin/dataerai" });
await client.connect();

const { userEmail } = await client.authCheck();
console.log(`Logged in as ${userEmail}`);

client.on("transfer:progress", (e) => {
  const pct = ((e.bytesDone / e.bytesTotal) * 100).toFixed(0);
  console.log(`  ${pct}%`);
});

const path = "/path/to/data.csv";
const done = new Promise((resolve) => client.once("asset:uploadComplete", resolve));

const accepted = await client.assetUpload({
  title: "My dataset",
  ownerType: "project",
  ownerId: "proj-abc123",
  tags: ["csv", "demo"],
  files: [{ localPath: path, filename: "data.csv", size: statSync(path).size }],
});

await done;
console.log(`Uploaded asset ${accepted.assetId}`);

client.destroy();
```

## Methods

| Method                                                | Description                                                                                |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| `connect()`                                           | Connect to the daemon (auto-starts it when `binaryPath` is set).                           |
| `authCheck()`                                         | Return the logged-in user and token expiry.                                                |
| `login(params?)` / `logout()`                         | Sign in via the browser flow / clear stored credentials.                                   |
| `assetUpload(params)`                                 | Start an upload; resolves with `{ transferId, assetId, contentId, ... }`.                  |
| `assetDownload(params)`                               | Start a download to `destDir`; resolves with accepted file info.                           |
| `getMetadata(assetId)`                                | Retrieve metadata.                                                                         |
| `setMetadata(assetId, patch)`                         | Update metadata fields.                                                                    |
| `listTransfers()`                                     | List known transfers.                                                                      |
| `pauseTransfer` / `resumeTransfer` / `cancelTransfer` | Control a running transfer.                                                                |
| `listTree()`                                          | Fetch the destination tree — your personal collections plus the projects you can write to. |
| `createProject(params)`                               | Create a new project.                                                                      |
| `listProjectAllocations(projectId)`                   | List the storage allocations available in a project.                                       |
| `ping()`                                              | Check that the daemon is reachable.                                                        |
| `shutdown()`                                          | Ask the daemon to stop.                                                                    |
| `destroy()`                                           | Disconnect and clean up.                                                                   |

## Events

Listen for progress and completion:

| Event                                         | Fires when                                                       |
| --------------------------------------------- | ---------------------------------------------------------------- |
| `transfer:progress`                           | A chunk completes — carries `bytesDone` / `bytesTotal`.          |
| `transfer:fileComplete`                       | One file within a multi-file transfer finishes.                  |
| `transfer:complete`                           | A transfer finishes.                                             |
| `transfer:paused`                             | A transfer is paused.                                            |
| `transfer:error` / `transfer:failed`          | A transfer hits an error / fails — carries `code` and `message`. |
| `asset:uploadComplete`                        | An upload finishes — carries `assetId`, `contentId`.             |
| `asset:downloadComplete`                      | A download finishes — carries `destDir`.                         |
| `asset:uploadFailed` / `asset:downloadFailed` | An upload or download fails.                                     |
| `connected` / `disconnected`                  | The daemon connection changes.                                   |
| `error`                                       | A client- or connection-level error occurs.                      |

## Next steps

<CardGroup cols={2}>
  <Card title="CLI" icon="terminal" href="/cli/overview">
    The command-line client the SDK builds on.
  </Card>

  <Card title="Python SDK" icon="circle" href="/sdks/python">
    The same operations from Python.
  </Card>
</CardGroup>
