@flatfile/sdk

中文文档
2.5.0发布于 2023/06/30ISCTypeScriptCommonJS近 30 天下载 2.4万

Flatfile SDK

原始使用文档
文档目录5 节
  1. Install
  2. Getting started
  3. Get your Embed ID
  4. Embed your Portal
  5. Next steps

@flatfile/sdk

Install

npm install @flatfile/sdk

Getting started

Make sure you are in Developer Mode by clicking the toggle in the bottom left corner of the Flatfile dashboard.

Get your Embed ID

First, grab your Embed ID for the Portal you want to embed. You can find this on the Edit Portal page in the Flatfile dashboard, and it should look something like this:

76aa0b10-d7f8-4dc7-a007-4a791736eed1

Embed your Portal

Use the following code to embed your Portal into your app:

import { Flatfile } from "@flatfile/sdk";

// find this in your Flatfile dashboard after creating a new Portal
const EMBED_ID = "";

// use this wherever you need to trigger an import
export function importData() {
  Flatfile.requestDataFromUser({
    embedId: EMBED_ID,
    user: { id: 99, name: "John Doe", email: "[email protected]" },
    org: { id: 77, name: "Acme Inc." },
    onData(chunk, next) {
      /* handle submitted data here */
    },
  });
}

// change this to whatever DOM trigger you want to use
document.getElementById("button").addEventListener("click", importData);

This should open the Portal upon clicking the element you passed to document.getElementById. Try it out by uploading a CSV, and see your cleaned data appear in your Flatfile dashboard!

Check out additional options for requestDataFromUser in the Flatilfe developer docs.

Next steps

Check out the Flatfile developer docs to see what's needed to get your Portal working in production, including:

  1. Accepting data
  2. Securing data
  3. Using Data Hooks®

版本与发布记录

@flatfile/sdk 共发布 61 个版本,首次发布于 2021/09/18;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.5.0latest2023/06/303 年前
2.3.52023/06/303 年前
2.4.52023/03/183 年前
2.3.42023/02/023 年前
2.3.32023/01/173 年前
2.3.22022/12/103 年前

其他发布通道:unstable → 2.2.0-rc0,beta → 2.2.0,stable → 2.2.0,next → 2.2.0。

关于 @flatfile/sdk 的常见问题

@flatfile/sdk 是什么?

Flatfile SDK

如何安装 @flatfile/sdk?

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

@flatfile/sdk 支持 TypeScript 吗?

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

@flatfile/sdk 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@flatfile/sdk 可以商用吗?

@flatfile/sdk 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

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

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

@flatfile/sdk 还在维护吗?

最新版本 2.5.0 发布于 2023/06/30(3 年前);至今共发布 61 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/09/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。