This repo contains a few starter projects used by the Flatfile Platform Operations team to ensure proof-of-life on environments.
- Node 18+
- PNPM v7
# clone this repo:
git clone https://github.com/FlatFilers/platform-ops-starter.git
cd platform-ops-starter/use-cases/listener
# ensure you are using at least NodeJS v18, e.g. if you use NVM:
nvm use 18
# install dependencies:
pnpm i
Flatfile uses the concept of an "agent" and an event system to create and manage your Spaces and Workbooks (e.g. the things that hold data) as well as manipulate data. An easy way to get started is to run the agent locally on your machine where we will send all the events to be handled. Get started quickly by:
- Go to one of the Flatfile Platform environments and create an account, then install the Portal application
- Switch to the Development environment, go to
Developer Settings
and copy your secret key - If you are running the
develop
command (not deploy) you will also need to set the environment variableexport FLATFILE_API_URL=https://platform.uk.flatfile.com/api
(or whichever environment you are using) - Deploy or run the listener locally --
pnpm run dev --api-url=https://platform.uk.flatfile.com/api
(you only need the--api-url
if you are using a region outside of the default US) - Choose the API key option and paste in your secret key
- Create a new space in the Flatfile dashboard
- Upload a file
After getting the basics sorted locally, deploy your agent to the Flatfile cloud so that it can listen for events independent of your local machine:
Ctrl+c
to stop running the local agentpnpm run deploy --api-url=...
- Choose the API key option and paste in your secret key
- Now, go to the Flatfile dashboard and create a space - this will open a new tab where you can upload data
It's a pretty simple list of contacts:
First Name Last Name Email
Esther Swanson [email protected]
Myrtle Curtis [email protected]
Isabel Goodman [email protected]
Rosie Douglas [email protected]
Francis Dunn [email protected]
Nina Torres [email protected]
Gabriel Gilbert [email protected]
Maude McCarthy [email protected]
Mabelle Brooks [email protected]
Elnora Ballard [email protected]
Generate your own or use the provided fake data getting-started.csv
The use-cases/react
project contains a minimal starter for embedding a space into a webpage. A new space is created each time it launches. To use this project, go to your dashboard Developer Settings, and collect the following:
- Environment ID
- Publishable key
Edit the file use-cases/react/src/App.tsx
and plug in the environment ID and the publishable key, then add the appropriate regional API endpoint. Change directories into the react
folder and run npm run start
The sheets/:sheetId/records
endpoint is used to page through data. To obtain the ID for the sheet, first copy your environment ID and secret key from the Developer Settings
page, fetch a list of Spaces to find the Space ID, then fetch the workbook ID (alternatively, reverse engineer the ID from the network tab while in the space itself).
An example via cURL:
# Fetch
curl -G https://platform.uk.flatfile.com/api/v1/spaces \
-H "Authorization: Bearer sk_ABC" \
-d environmentId=uk_env_123
# Use the Space ID from previous request:
curl -G https://platform.uk.flatfile.com/api/v1/workbooks \
-H "Authorization: Bearer sk_ABC" \
-d spaceId=uk_sp_123 \
-d includeCounts=true
# Use the Sheet ID from the previous request:
curl https://platform.uk.flatfile.com/api/v1/sheets/uk_sh_123/records \
-H "Authorization: Bearer sk_ABC"