Using REST and cURL with FileMaker’s Data API

FileMaker 19 introduced a couple of important new features related to using the FileMaker Data API. Here, we’ll cover an overview of the new authorization endpoint, Validate Session, API versioning updates, as well as a new script step, Execute FileMaker Data API.

At the end of this article, you’ll find the demo file for learning more and trying out various REST and cURL functionality with FileMaker’s Data API. Enjoy!

FileMaker Data API: A Brief History

This blog post, and the latest example/tutorial file (see below) were put together by several Beezwax developers, led by Darren Burgess. Darren has been sharing resources for learning and using the FileMaker Data API since it was first introduced with FileMaker 16.

Here are links to these previous updates, if you want to review the evolution of the FM Data API over the years, or if you’re new and need a refresher on how it all works.

  • FileMaker 16 – FileMaker Data API in “beta”
  • FileMaker 17 – Official release of FileMaker Data API with 10 endpoints
  • FileMaker 18 – 5 new metadata endpoints and nicer documentation
  • FileMaker 19 – 1 new auth endpoint, Execute FileMaker Data API Script Step

For any newbies, don’t forget to turn on the setting for FileMaker Data API, under Connectors > FileMaker Data API – General Settings within FileMaker Server. This allows you to make HTTP requests against the files hosted on the server.

Validate Session

https://{your-server}/fmi/data/{version}/validateSession

If you’ve ever wondered whether an API token you’ve generated can still be used to make additional API requests, FileMaker 19 added a useful validateSession endpoint.

Sending a GET request to this endpoint will check if the given API token that is part of the authorization header is still valid.

Tokens are invalidated when a user logs out with the token or due to inactivity if no API requests have been made with the token for 15 minutes.

Note that when called, the validateSession endpoint itself does not extend the life of the token.

A Note on API Versioning

FileMaker 19 accepts API requests from a new “v2” version for its REST API endpoints. This means FileMaker 19 can accept v1, v2, and vLatest as valid API versions.

While our testing showed no discernible differences in the responses generated between these different versions when FileMaker 19.0 was released (in May 2020), this versioning support is certainly a promising indicator of plans to extend the FileMaker Data API in the future.

Note: On release of FileMaker 19.0 (in May 2020) the Claris FileMaker Data API documentation remained at version v1.0.0.

The Execute FileMaker Data API Script Step

FileMaker 19 introduced a new way to query the FileMaker Data API with the Execute FileMaker Data API script step. The benefits from using this approach are that it doesn’t require an API token, and it has the ability to work on files stored on your local machine. This is quite useful if you want to make queries to a file via a JSON payload and you’d rather not deal with cURL options or SQL queries.

The drawback is that this currently only supports reading data. So, you won’t get the full suite of CRUD operations available from the HTTP methods and endpoints you are able to access using cURL options.

The following is a simple example that gets all the records under the context of the rest_layout and saves the JSON response into a $_data_json variable. In FM 19, it only takes one line to get a JSON response with all the records.

Execute FileMaker Data API [Select ; Target: $_data_json ;  JSONSetElement ( "{}" ; "layouts" ; "rest_layout"; JSONString) ]

Check out the demo file for more examples. And speaking of demo file…

Demo file: FileMaker 19 Data API and cURL Options

Download the demo file here.

Username: admin
Password: admin

The demo file must be hosted on FileMaker Server 19.x (or later) for full functionality.

This is a simple demonstration file designed to help you get started in your understanding of FileMaker 19’s Data API and cURL options.

This file sends REST requests to itself, and so makes for a good demonstration of Data API and cURL features. To get the most out of the demo, please check out the scripts, especially execute rest request. You can also study the results of requests in the fields to the right side of each layout.

This demo also uses the Execute FileMaker Data API script step with FileMaker 19. Check out the execute data api script as an alternative way to query the Data API.

Getting Started

  • 1. Host this file on a FileMaker Server 19.x (or later)
  • 2. Enter the URL or IP address of your server. Example 192.168.1.50 or hostname.your-domain.com
  • 3. Enter the account name and password for the FileMaker user account that will access the API. The default for this file is already entered.
  • 4. Enter the file name you wish to access, without the .fmp12 extension (default is this file).

Note: No official new documentation for the Execute FileMaker Data API script step was made available in the FileMaker 19 Help docs upon release of FileMaker 19.0 (in May 2020). There’s documentation for the Execute FileMaker Data API script step. We will try to update this article when there’s additional new documentation, but you should always check the Help docs or Claris FileMaker support website for updates.

Documentation on the Validate Session endpoint can be found in the API docs available with your FM 19 server (i.e. https://{your-server}/fmi/data/apidoc/#operation/validateSession).

Leave a Reply