A developer-friendly Python library for interacting with FileMaker Server via the FileMaker Data API. Connect your apps to FileMaker databases for streamlined data management, automation, and integration
- Authentication: Use Basic Auth for secure sign-in/sign-out and automatic session management
- CRUD Operations: Perform Create, Read, Update, and Delete on FileMaker records.
- File Uploads: Upload files to FileMaker container fields using multipart/form-data.
- Error Handling: Includes robust error handling for API requests and responses.
You can install the package via pip:
pip install python-fm-dapi-weaver
After installing the package, you can start the server by following these steps:
To start the server, import the start_server
function and call it as shown below:
from python-fm-dapi-weaver.main import start_server
start_server()
You can also start the server with custom host, port, and reload settings.
from python_fm_dapi_weaver.main import start_server
start_server(host="0.0.0.0", port=8080, reload=True)
- host – IP address to bind the server (default is
127.0.0.1
) - port – Port number to listen on (default is
8000
) - reload – Enable auto-reloading of server on code changes (default is
False
)
<serverURL>api/dataApi
Example:http://localhost:8000/api/dataApi
POST
Must send Basic Authentication credentials in the headers for each request. The
Authorization
header must contain the FileMaker Database username and password encoded in Base64.
{
"fmServer": "<IpAddress>",
"method": "<methodName>",
"methodBody": {<method specific body>},
"session": {
"token": "<sessionToken>",
"required": <true/false>
}
}
Used for signing into the FileMaker database.
{
"fmServer": "<IpAddress>",
"method": "signin",
"methodBody": {
"database": "<Filemaker_Filename>"
},
"session": {
"token": "",
"required": ""
}
}
Used for signing out from the FileMaker server.
The
session.token
should be the token received from the Signin method.
{
"fmServer": "<IpAddress>",
"method": "signout",
"methodBody": {
"database": "<Filemaker_Filename>"
},
"session": {
"token": "<sessionToken>", // Token received from the Signin method
"required": <true/false>
}
}
Fetches all records from the specified layout, with pagination.
The
session.token
should be the token received from the Signin method.
offset
: The starting point of records to fetch. Ifoffset
is provided (e.g.,1
), it will start fetching from the second record (indexing starts from 0). Default:0
(starts from the first record).limit
: The maximum number of records to fetch. Iflimit
is provided (e.g.,10
), it will fetch up to 10 records per request. Default: No limit (all records will be fetched).
These fields are optional and can be omitted if you want to fetch all records without pagination.
Example:
- If
offset
is1
andlimit
is10
, it will fetch records from index 1 to 10 (inclusive). - If neither
offset
norlimit
is specified, it will fetch all available records.
{
"fmServer": "<IpAddress>",
"method": "getAllRecords",
"methodBody": {
"database": "<Filemaker_Filename>",
"layout": "<Layout_Name>",
"offset": "1", // Optional - Starting from the second record
"limit": 10 // Optional - Fetch up to 10 records
},
"session": {
"token": "<sessionToken>", // Token received from the Signin method
"required": <true/false>
}
}
Used for creating a new product record in a specified FileMaker layout.
The
session.token
should be the token received from the Signin method.
The fields in the record
object should match the product-related field names in the FileMaker layout. Example fields might include ProductName
, ProductCode
, Price
, Quantity
, etc.
Example:
{
"fmServer": "<IpAddress>",
"method": "createRecord",
"methodBody": {
"database": "<Filemaker_Filename>",
"layout": "<Layout_Name>", // The layout that holds the product records
"record": {
"ProductName": "Laptop", // Example product name
"ProductCode": "LP123", // Example product code
"Price": "1200", // Example product price
"Quantity": "50" // Example quantity in stock
}
},
"session": {
"token": "<sessionToken>", // Token received from the Signin method
"required": <true/false>
}
}
Used for deleting a record from a specified FileMaker layout.
The
session.token
should be the token received from the Signin method.
You need to specify the recordId of the record you want to delete. The recordId
refers to the unique identifier for the record in the FileMaker layout.
Example:
{
"fmServer": "<IpAddress>",
"method": "deleteRecord",
"methodBody": {
"database": "<Filemaker_Filename>",
"layout": "<Layout_Name>", // The layout from which the record will be deleted
"recordId": "<Record_ID>" // The unique ID of the record to delete
},
"session": {
"token": "<sessionToken>", // Token received from the Signin method
"required": <true/false>
}
}
Used for updating an existing record in a specified FileMaker layout.
The
session.token
should be the token received from the Signin method.
You need to specify the recordId of the record you want to update. The fields in the record
object should match the field names in the FileMaker layout, and they should be updated with the new values.
Example:
{
"fmServer": "<IpAddress>",
"method": "updateRecord",
"methodBody": {
"database": "<Filemaker_Filename>",
"layout": "<Layout_Name>", // The layout in which the record will be updated
"recordId": "<Record_ID>", // The unique ID of the record to update
"record": {
"ProductName": "Updated Laptop", // Updated product name
"ProductCode": "LP1234", // Updated product code
"Price": "1300", // Updated price
"Quantity": "40" // Updated quantity
}
},
"session": {
"token": "<sessionToken>", // Token received from the Signin method
"required": <true/false>
}
}
Used for finding specific records in a specified FileMaker layout.
The
session.token
should be the token received from the Signin method.
You can specify search criteria in the query
field. Each query defines the fields you want to search for and the values to match. You can also apply sorting and specify scripts to run.
query
: Define search criteria. Each object inside the query array represents a field-value pair that you want to search for.sort
: (Optional) Specify sorting order based on a field, e.g.,CreationTimestamp
.scripts
: (Optional) Specify FileMaker scripts to be executed during the search.limit
: (Optional) Limit the number of records returned.offset
: (Optional) Define the starting point for pagination.
Example:
{
"fmServer": "<IpAddress>",
"method": "findRecord",
"methodBody": {
"database": "<Filemaker_Filename>",
"layout": "<Layout_Name>",
"offset": "1", // Optional
"limit": "10", // Optional
"query": [
{"ProductName": "=Laptop"}, // Search for records where ProductName equals "Laptop"
{"Price": ">1000"} // Search for records where Price is greater than 1000
],
"sort": [
{"fieldName": "CreationTimestamp", "sortOrder": "ascend"}
],
"scripts": {
"script": "<FM_Script_Name>",
"script.param": "<Script_Param>"
}
},
"session": {
"token": "<sessionToken>", // Token received from the Signin method
"required": <true/false>
}
}
Used for uploading a container field (e.g., an image or file) to a specified record in a FileMaker layout.
The
session.token
should be the token received from the Signin method.
database
: The name of the FileMaker database where the container field resides.layout
: The layout that contains the record with the container field.recordId
: The unique ID of the record that will hold the uploaded file.fieldName
: The name of the container field in which the file will be stored.file
: The actual file to upload (this is typically included as a part of the request body, but the example provided does not show the file).
curl --location 'http://<Api Server>/api/dataApi' \
--header 'Authorization: Basic <Base64(username:password)>' \
--form 'method="uploadContainer"' \
--form 'data={
"fmServer": "<IpAddress>",
"database": "DatabaseName",
"layout": "LayoutName",
"recordId": "1",
"fieldName": "ContainerFieldName",
"sessionToken": "Session-token"
}' \
--form 'file=@"/path/to/your/file.jpg"' # path to the file you want to upload
We appreciate and encourage community involvement!
If you're interested in contributing to the python-fm-dapi-weaver
,for detailed instructions on how to set up the development environment and contribute to the project, please refer to our CONTRIBUTING.md.
© Mindfire Digital LLP. All rights reserved.
This project is licensed under the MIT License.