# @flatfile/sdk

> Flatfile SDK

Latest version **2.5.0** (published 2023-06-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install @flatfile/sdk
pnpm add @flatfile/sdk
yarn add @flatfile/sdk
bun add @flatfile/sdk
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.5.0 |
| Published | 2023-06-29 |
| First published | 2021-09-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 158.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Max Blank |
| Maintainers | haleymt, mmccooyyy, ahollenbeck, howarddierking_flatfile, maerf0x0, rjhyde, mpoythress, flatderek, ashleygmulligan, renatonouman, alnoor, flatfilecolin, bigcountrycrane, flatfileinfra, bangarang, madmandrit, roberto-alcantara-ffile, mairechew, jmmander, srmotter, driscollrp, sarocu, dboskovic, brentkulwicki, nate.ferrero, jaredwalters |

## Links

- npm: https://www.npmjs.com/package/@flatfile/sdk
- Repository: https://github.com/FlatFilers/sdk
- Homepage: https://github.com/FlatFilers/sdk#readme
- Issues: https://github.com/FlatFilers/sdk/issues
- npm.io page: https://npm.io/package/@flatfile/sdk

## Dependencies (4)

- [graphql](https://npm.io/package/graphql.md) ^15.5.0
- [eventemitter3](https://npm.io/package/eventemitter3.md) ^4.0.7
- [graphql-request](https://npm.io/package/graphql-request.md) ^3.4.0
- [graphql-subscriptions-client](https://npm.io/package/graphql-subscriptions-client.md) ^0.16.0

## Recent versions

- 2.5.0 (latest) — 2023-06-29
- 2.2.0 (beta) — 2022-11-18
- 2.2.0-rc0 (unstable) — 2022-11-18
- 2.3.5 — 2023-06-29
- 2.4.5 — 2023-03-17
- 2.3.4 — 2023-02-02
- 2.3.3 — 2023-01-17
- 2.3.2 — 2022-12-09
- 2.3.1 — 2022-12-09
- 2.3.0 — 2022-12-09
- 2.2.2 — 2022-12-08
- 2.2.1 — 2022-12-07
- 2.1.9 — 2022-11-18
- 2.1.8 — 2022-11-16
- 2.1.7 — 2022-11-16
- … 46 more at https://npm.io/package/@flatfile/sdk/versions

## README

# @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:

```ts
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: "john@doe.com" },
    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](https://flatfile.com/docs/embedding-flatfile/accepting-data/#options).

## Next steps

Check out the [Flatfile developer docs](https://flatfile.com/docs) to see what's needed to get your Portal working in production, including:

1. [Accepting data](https://flatfile.com/docs/embedding-flatfile/accepting-data)
2. [Securing data](https://flatfile.com/docs/embedding-flatfile/securing-data/)
3. [Using Data Hooks®](https://flatfile.com/docs/data-hooks/overview/)

---
_Source: https://npm.io/package/@flatfile/sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
