-
Notifications
You must be signed in to change notification settings - Fork 8
Home
This package is designed to make working with the FileMaker Data API much easier. Here's just a few key features:
- Otto Data API proxy support
- TypeScript support for easy auto-completion of your fields
- Automated type generation based on layout metadata
- Supports both node and edge runtimes (v3.0+)
This library requires zod as a peer depenency and Node 18 or later
npm install @proofgeist/fmdapi zod
yarn add @proofgeist/fmdapi zod
Version 4 changes the way the client is created to allow for Custom Adapters, but the methods on the client remain the same. If you are using the codegen CLI tool, simply re-run codegen after upgrading to apply the changes.
- adapters
- pass layout into some functions (exposed from client)
Note: For the best experience, use the codegen tool to generate layout-specific clients and get autocomplete hints in your IDE with your actual field names. This minimal example just demonstrates the basic setup
Add the following envnironment variables to your project's .env
file:
FM_DATABASE=filename.fmp12
FM_SERVER=https://filemaker.example.com
# if you want to use the Otto Data API Proxy
OTTO_API_KEY=KEY_123456...789
# otherwise
FM_USERNAME=admin
FM_PASSWORD=password
Initialize the client with credentials, depending on your adapter
// to use the Otto Data API Proxy
import { DataApi, OttoAdapter } from "@proofgeist/fmdapi";
const client = DataApi({
adapter: new OttoAdapter({
auth: { apiKey: process.env.OTTO_API_KEY },
db: process.env.FM_DATABASE,
server: process.env.FM_SERVER,
}),
});
// to use the raw Data API
import { DataApi, FetchAdapter } from "@proofgeist/fmdapi";
const client = DataApi({
adapter: new FetchAdapter({
auth: {
username: process.env.FM_USERNAME,
password: process.env.FM_PASSWORD,
},
db: process.env.FM_DATABASE,
server: process.env.FM_SERVER,
}),
});
Then, use the client to query your FileMaker database. View all available methods here.
Basic Example:
const result = await client.list({ layout: "Contacts" });