@geolens/sdk

中文文档
1.31.0发布于 2026/11/10Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 2926

Auto-generated TypeScript SDK for the GeoLens API. Typed clients with Bearer + API-key auth helpers.

原始使用文档
文档目录4 节
  1. Install
  2. Quickstart
  3. Errors
  4. Redirects

@geolens/sdk (TypeScript)

Auto-generated TypeScript SDK for the GeoLens API.

Apache-2.0 licensed. Native fetch client + typed request/response interfaces + Bearer-token + API-key auth helpers. Requires Node 18+ (or any runtime with native fetch).

See docs.getgeolens.com for installation, regeneration, and version-pin policy.

Install

npm install @geolens/sdk

The package is ESM only (import, not require).

Quickstart

import { createGeolensClient } from '@geolens/sdk';

const sdk = createGeolensClient({
  // The deployed API is served under /api, so include that suffix in baseUrl.
  baseUrl: 'https://geolens.example.com/api',
  bearerToken: '...',
});
// See docs.getgeolens.com for endpoint usage examples.

Errors

Generated calls return { data, error, response } and don't throw on an HTTP error status. error is the parsed application/problem+json body (type, title, status, detail):

import { createGeolensClient, getSingleDatasetDatasetsDatasetIdGet } from '@geolens/sdk';

const sdk = createGeolensClient({ baseUrl: 'https://geolens.example.com/api', apiKey: '...' });
const { data, error, response } = await getSingleDatasetDatasetsDatasetIdGet({
  client: sdk.client,
  path: { dataset_id: '00000000-0000-0000-0000-000000000000' },
});
if (error) {
  console.error(response.status, error.detail);
}

With throwOnError: true the call throws the parsed error body, a plain object rather than an Error instance.

createGeolensClient() returns a client scoped to that call (sdk.client). Pass it explicitly to every generated endpoint call — { client: sdk.client } — when you build more than one client in the same process (for example, one per request in a server), so concurrent callers cannot interfere with each other. Omitting client from a generated call falls back to a shared process-wide default that the most recent createGeolensClient() call configures; that default is fine for a single-client script but is last-caller-wins across concurrent clients.

Redirects

When a redirect leaves the GeoLens origin, which happens when a COG download is served from object storage, the SDK doesn't send credentials or client headers there. Only Range and the If-* precondition headers go along.

In Node the SDK follows GET and HEAD redirects itself. A hop that leaves the GeoLens origin goes through the global fetch, not the client's fetch option (a proxy set with undici's setGlobalDispatcher still applies).

In a browser, where a redirect's target can't be read, a request carrying Authorization or X-API-Key fails with RedirectError, and any other request is sent again, without cookies, for the browser to follow. To download a COG there, mint a download token (POST /auth/download-token/{dataset_id}) and fetch /datasets/{dataset_id}/download/cog?token=... without credentials.

This applies to the default redirect: 'follow'. Set redirect: 'manual' or 'error', per call or on the client, and you get what fetch gives: the redirect returned unfollowed, or a TypeError.

版本与发布记录

@geolens/sdk 共发布 61 个版本,首次发布于 2026/05/03;过去 12 个月发布了 61 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.31.0latest2026/11/106 天前
1.30.12026/11/097 天前
1.30.02026/11/088 天前
1.29.22026/11/0214 天前
1.29.12026/10/3115 天前
1.29.02026/10/3115 天前

关于 @geolens/sdk 的常见问题

@geolens/sdk 是什么?

Auto-generated TypeScript SDK for the GeoLens API. Typed clients with Bearer + API-key auth helpers.

如何安装 @geolens/sdk?

在项目目录运行 npm install @geolens/sdk,或使用 pnpm add / yarn add / bun add。

@geolens/sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@geolens/sdk 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@geolens/sdk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@geolens/sdk 可以商用吗?

@geolens/sdk 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@geolens/sdk 的下载量有多少?

根据 npm 官方下载统计,@geolens/sdk 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,926 次,日均约 98 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@geolens/sdk 还在维护吗?

最新版本 1.31.0 发布于 2026/11/10(6 天前);至今共发布 61 个版本,其中过去 12 个月发布了 61 个;首次发布于 2026/05/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。