npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@aokiapp/reark-lark-api

v0.5.1

Published

[![npm version](https://img.shields.io/npm/v/@aokiapp/reark-lark-api.svg)](https://www.npmjs.com/package/@aokiapp/reark-lark-api) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](../../LICENSE)

Readme

@aokiapp/reark-lark-api

npm version License: MIT

Utilities and TypeScript types for interacting with the Lark (Feishu) API.
Provides a unified data-fetching and transformation layer for the reark monorepo.


Table of Contents


Overview

@aokiapp/reark-lark-api provides utilities and types for interacting with the Lark (Feishu) API, focusing on:

  • Fetching and processing document blocks and comments
  • Downloading files
  • Accessing Bitable (Base) records
  • Ensuring type safety and consistency across the monorepo

Role in Monorepo:
This package is used by the core, renderer, and server packages to provide a unified, type-safe data model for Lark content.


Key Features

  • Fetch Lark document blocks (paged or all)
  • Download files and fetch comments
  • Batch file download URL retrieval (with chunking/rate limit handling)
  • Access Lark Bitable (Base) records
  • Comprehensive TypeScript types for all API objects

Installation

npm install @aokiapp/reark-lark-api
# or
yarn add @aokiapp/reark-lark-api
# or
pnpm add @aokiapp/reark-lark-api

Usage

1. Authentication

Before making any API calls, set your Lark app credentials:

import { setCredentials } from "@aokiapp/reark-lark-api";

setCredentials("your-app-id", "your-app-secret");

2. Fetch Document Blocks

import {
  getDocumentBlocks,
  fetchAllDocumentBlocks,
} from "@aokiapp/reark-lark-api";

// Fetch a single page of blocks
const page = await getDocumentBlocks("doc-id");

// Fetch all blocks (handles pagination)
const allBlocks = await fetchAllDocumentBlocks("doc-id");

3. Download a File

import { getFile } from "@aokiapp/reark-lark-api";

const blob = await getFile("file-token");
// Use blob as needed (e.g., download, display)

4. Fetch Comments

import { getComments } from "@aokiapp/reark-lark-api";

const comments = await getComments("file-token");

5. Batch Download URLs

import {
  batchGetTmpDownloadUrls,
  batchGetTmpDownloadUrlsChunked,
} from "@aokiapp/reark-lark-api";

const urls = await batchGetTmpDownloadUrls(["token1", "token2"]);
const chunkedUrls = await batchGetTmpDownloadUrlsChunked(
  ["token1", "token2"],
  10,
);

6. Access Bitable (Base) Records

import { listBaseRecords } from "@aokiapp/reark-lark-api";

const records = await listBaseRecords({
  appToken: "app-token",
  tableId: "table-id",
  pageSize: 100,
});

API Reference

Functions

setCredentials(appId: string, appSecret: string): void

Set the Lark app credentials for all subsequent API calls.

getDocumentBlocks(documentId: string, pageToken?: string): Promise<DocumentBlockResponse>

Fetch a single page of blocks for a given document.

fetchAllDocumentBlocks(documentId: string): Promise<Block[]>

Fetch all blocks for a document, handling pagination.

getFile(fileToken: string): Promise<Blob>

Download a file as a Blob.

getComments(fileToken: string): Promise<CommentListResponse>

Fetch comments for a given file (docx).

batchGetTmpDownloadUrls(fileTokens: string[]): Promise<Record<string, string>>

Fetch temporary download URLs for multiple file tokens.

batchGetTmpDownloadUrlsChunked(fileTokens: string[], batchSize?: number): Promise<Record<string, string>>

Fetch temporary download URLs for multiple file tokens, splitting requests into chunks to avoid rate limits.

listBaseRecords(params: ListBaseRecordsParams): Promise<ListBaseRecordsResponse>

Fetch records from a Lark Bitable (Base) table.


Types

Block

export type Block = {
  block_id: string;
  block_type: number;
  parent_id?: string;
  // ...plus all fields as per Lark API (see source for full details)
  // Includes text, style, children, etc.
};
  • See types/block.ts for all fields and subtypes (Align, CodeLanguage, TextStyle, TextElementStyle, Link, TextRun, MentionUser, MentionDoc, Reminder, etc.)

DocumentBlockResponse

export type DocumentBlockResponse = {
  code: number;
  msg: string;
  data: {
    has_more?: boolean;
    page_token?: string;
    items: (Partial<Block> & {
      block_id?: string;
      block_type?: number;
      parent_id?: string;
    })[];
  };
};

CommentListResponse

export type CommentListResponse = {
  code: number;
  msg: string;
  data: {
    has_more?: boolean;
    page_token?: string;
    items: CommentData[];
  };
};

CommentData

export type CommentData = {
  comment_id: string;
  user_id: string;
  create_time: number;
  update_time: number;
  is_solved: boolean;
  solved_time: number;
  solver_user_id: string;
  has_more: boolean;
  page_token: string;
  is_whole: boolean;
  quote: string;
  reply_list?: ReplyList;
};

ListBaseRecordsParams

export type ListBaseRecordsParams = {
  appToken: string;
  tableId: string;
  viewId?: string;
  pageSize?: number;
  pageToken?: string;
  filter?: string;
  sort?: string[];
  fieldNames?: string[];
  textFieldAsArray?: boolean;
  userIdType?: "open_id" | "union_id" | "user_id";
  displayFormulaRef?: boolean;
  automaticFields?: boolean;
};

BaseRecord

export type BaseRecord = {
  record_id: string;
  fields: Record<string, unknown>;
  created_by?: Person;
  created_time?: number;
  last_modified_by?: Person;
  last_modified_time?: number;
};

ListBaseRecordsResponse

export type ListBaseRecordsResponse = {
  code: number;
  msg: string;
  data: {
    items: BaseRecord[];
    page_token?: string;
    has_more?: boolean;
    total?: number;
  };
};

All other types (Align, CodeLanguage, TextStyle, etc.)

See src/types/block.ts and src/types/api.ts for exhaustive details.


Extension & Customization

  • Authentication: Use setCredentials to provide your Lark app credentials.
  • Advanced Usage: You may extend or wrap API utilities for custom needs (e.g., custom error handling, logging, etc.).
  • Type Safety: All API responses are fully typed for safe integration.

Related Documentation


Contributing

Contributions are welcome! Please see the monorepo root README for guidelines.

  • Run tests and lint before submitting PRs.
  • Keep documentation and types up to date with code changes.

Changelog

See CHANGELOG.md for release history.


License

MIT © AokiApp Contributors