Quick Start - Manual
Note: For the best experience, use the @proofkit/typegen 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 OttoFMS Data API Proxy
OTTO_API_KEY=dk_123456...789
# otherwise
FM_USERNAME=admin
FM_PASSWORD=password
Initialize the client with credentials, depending on your adapter
// to use the OttoFMS Data API Proxy
import { DataApi, OttoAdapter } from "@proofkit/fmdapi";
const client = DataApi({
adapter: new OttoAdapter({
auth: { apiKey: process.env.OTTO_API_KEY },
db: process.env.FM_DATABASE,
server: process.env.FM_SERVER,
}),
layout: "API_Contacts",
});
// to use the raw Data API
import { DataApi, FetchAdapter } from "@proofkit/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,
}),
layout: "API_Contacts",
});
Then, use the client to query your FileMaker database. View all available methods here.
Basic Example:
const result = await client.list({ layout: "Contacts" });
TypeScript Support
If you define a schema in your client, the types will be inferred automatically. Learn more
The basic client will return the generic FileMaker response object by default. You can also create a type for your expected response and get a fully typed response that includes your own fields.
type TContact = {
name: string;
email: string;
phone: string;
};
// if you have portals
type TOrders = {
"Orders::orderId": string;
"Orders::orderDate": string;
"Orders::orderTotal": number;
};
type TPortals = {
orders: TOrders; // key is based on the portal object name
};
const client = DataApi<TContact, TPortals>({
layout: "API_Contacts",
// ... your adapter, other config
});
💡 TIP: For a more ergonomic TypeScript experience, use the @proofkit/typegen tool to generate these types based on your FileMaker layout metadata.