npm package: @skycatch-api/skylink-node
Description: Nodejs library for accessing Skycatch's REST API
Author: Christian Sanz
Latest version: 0.2.0

# skylink-node

TypeScript / Node.js client for the [Skycatch](https://skycatch.com) Data Hub REST API. The published package is compiled JavaScript with declaration files; the HTTP layer is generated from `schema.json` via [@hey-api/openapi-ts](https://github.com/hey-api/openapi-ts).

## Install

```bash
pnpm add @skycatch-api/skylink-node
# or: npm install @skycatch-api/skylink-node
```

## Usage

Create a client with your API base URL and bearer token. Both are **required**.

```typescript
import SkyLink from "@skycatch-api/skylink-node"

const api = SkyLink({
  API_URL: process.env.SKYLINK_API_URL!,
  API_TOKEN: process.env.SKYLINK_API_TOKEN!
})

const org = await api.getOrganization({
  organizationId: process.env.SKYLINK_API_ORGANIZATION_ID!
})

console.log(org?.organization?.name)
```

### Parameters

Path and query arguments use **camelCase** (for example `organizationId`, `siteId`, `datasetId`, `processingJobId`, `analyticId`).

### Response shape

Each method resolves to the API’s inner **`data`** payload (the object inside the HTTP JSON envelope). For example, `getOrganization` resolves to an object with an `organization` field, and list endpoints expose `items` on that payload—not a second nested `data` wrapper.

```typescript
const sites = await api.getSites({ organizationId })
for (const site of sites?.items ?? []) {
  console.log(site.id, site.name)
}
```

### CommonJS

```javascript
const SkyLink = require("@skycatch-api/skylink-node").default

const api = SkyLink({ API_URL: "...", API_TOKEN: "..." })
api.getOrganization({ organizationId: "..." }).then((res) => {
  console.log(res?.organization?.name)
})
```

## API surface

The default export is a factory `SkyLink(config)` that returns an object with methods such as:

- `getOrganizations`, `getOrganization`
- `getSites`, `getSite`
- `getDatasets`, `getDataset`, `createDataset`
- `getProcessingJobs`, `getProcessingJob`, `getProcessingOutputs`
- `getAnalytics`, `getAnalytic`
- `getFileManagerCredentialsBySite`

Types for payloads and responses are re-exported from the package entry (for example `GetOrganizationResponse`, `SiteParams`, `CreateDatasetPayload`).

## Development

| Command | Description |
|--------|-------------|
| `pnpm install` | Install dependencies |
| `pnpm run build` | Compile `src/` to `dist/` |
| `pnpm run lint` | Typecheck (`tsc --noEmit`) |
| `pnpm run test` | Run tests (see below) |
| `pnpm run generate:client` | Regenerate `src/sdk` from `schema.json` |

After `generate:client`, check `src/sdk/client.gen.ts`: if the `createClientConfig` import points at `./src/skd-config.ts`, change it to `@/skd-config` so the project resolves correctly.

## Integration tests

Tests load `test/.env`. Copy `test/.env-sample` to `test/.env` and set:

- `SKYLINK_API_URL`
- `SKYLINK_API_TOKEN`
- `SKYLINK_API_ORGANIZATION_ID`

Then run `pnpm run test` from the repository root.

## Links

- [JavaScript docs](https://docs.skycatch.com/js) (package homepage)
- Issues: [github.com/skycatch/skylink-node](https://github.com/skycatch/skylink-node)