@skycatch-api/skylink-node
v0.2.1
Published
Nodejs library for accessing Skycatch's REST API
Readme
skylink-node
TypeScript / Node.js client for the Skycatch 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.
Install
pnpm add @skycatch-api/skylink-node
# or: npm install @skycatch-api/skylink-nodeUsage
Create a client with your API base URL and bearer token. Both are required.
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.
const sites = await api.getSites({ organizationId })
for (const site of sites?.items ?? []) {
console.log(site.id, site.name)
}CommonJS
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,getOrganizationgetSites,getSitegetDatasets,getDataset,createDatasetgetProcessingJobs,getProcessingJob,getProcessingOutputsgetAnalytics,getAnalyticgetFileManagerCredentialsBySite
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_URLSKYLINK_API_TOKENSKYLINK_API_ORGANIZATION_ID
Then run pnpm run test from the repository root.
Links
- JavaScript docs (package homepage)
- Issues: github.com/skycatch/skylink-node
