# How to Migrate from the FileMaker PHP API to the Data API

A practical guide to moving an existing FileMaker PHP API integration to the FileMaker Data API without rewriting the entire PHP application.

The FileMaker API for PHP and the FileMaker Data API solve the same broad problem: allowing a web application to exchange data with a hosted FileMaker database. They use very different architectures, however.

The PHP API is a PHP library built around FileMaker Custom Web Publishing. The Data API is an HTTPS REST API that accepts requests and returns JSON. Migrating therefore means replacing the FileMaker-specific PHP calls, not replacing PHP itself. Your website can remain entirely written in PHP.

## Before You Start

Inventory every place where the existing application communicates with FileMaker:

- authentication and connection setup;

- find requests;

- record creation, editing, duplication, and deletion;

- portal and related-record access;

- global fields;

- FileMaker script execution;

- container uploads and downloads;

- error handling;

- pagination and found-set handling.

Also identify the layouts used by the PHP API. The Data API also works through layouts, so these layouts may remain useful, but they should be reviewed before being exposed to the new integration.

## Prepare the FileMaker File

Create or review a dedicated account and privilege set for the integration. Enable the extended privilege required for FileMaker Data API access and grant access only to the layouts, records, fields, scripts, and containers the application actually needs.

Dedicated integration layouts are usually preferable to layouts used by FileMaker Pro users. They make the available fields predictable and reduce the risk that a future interface change breaks the website.

## Replace the Connection Model

The PHP API creates a FileMaker object and sends requests through that library. The Data API uses HTTPS requests.

A Data API client must:

1. open a database session;

2. retrieve an access token;

3. include that token in subsequent requests;

4. close the session when the work is complete;

5. reconnect when a token expires.

A token remains valid while it is being used, but expires after a period of inactivity. Your application should therefore handle session expiration and authentication errors cleanly rather than assuming that one connection lasts indefinitely.

See the [official connection documentation](https://help.claris.com/en/data-api-guide/content/connect-disconnect-database.html).

## Map the Existing Operations

| PHP API operation | Data API replacement |
| --- | --- |
| Create a record | POST to the records endpoint |
| Retrieve records | GET a record or a range of records |
| Perform a find | POST a JSON find request to the _find endpoint |
| Edit a record | PATCH the record endpoint |
| Delete a record | DELETE the record endpoint |
| Set global fields | PATCH the globals endpoint |
| Run a FileMaker script | Call the script endpoint or attach script parameters to a request |
| Upload a container | POST multipart data to the container endpoint |

The [FileMaker Data API reference](https://help.claris.com/en/data-api-guide/content/data-api-reference.html) documents the available endpoints and request formats.

## Adapt the Response Handling

The PHP API returns PHP objects with methods such as record and field accessors. The Data API returns JSON.

Create a small application layer that converts Data API responses into the structures your existing code expects. This avoids spreading raw API-response handling throughout the project and makes the migration easier to test.

Pay particular attention to:

- FileMaker error codes returned in the response;

- record IDs and modification IDs;

- field names and related-set names;

- dates, times, timestamps, and numbers;

- empty values versus missing values;

- portal pagination;

- container URLs.

## Keep Business Logic in FileMaker Where Appropriate

Existing FileMaker scripts can still be executed through the Data API. This can reduce the amount of business logic that must be rewritten during the migration.

Check every script for context assumptions. A script started through the Data API runs in the context established by the API request and may not behave exactly like a script started interactively in FileMaker Pro.

## Migrate Incrementally

Avoid rewriting the entire integration in one step.

A safer sequence is:

1. create the authentication and request layer;

2. migrate read-only operations;

3. migrate record creation and editing;

4. migrate scripts and container operations;

5. run the old and new implementations against controlled test data;

6. compare results and error handling;

7. switch production traffic only after the critical paths have been validated.

Keep the former integration available for rollback until the new implementation has been observed in production.

## What About the Open-Source PHP API?

An open-source modernization of the former FileMaker PHP API was historically useful as an intermediate step. It allowed older PHP projects to adopt namespaces, Composer, modern error handling, and a cleaner code structure without immediately changing their FileMaker communication model.

It should not be confused with the FileMaker Data API. Before using any legacy library as part of a current migration, verify its maintenance status, compatibility with the PHP version in production, and compatibility with the FileMaker Server version being used.

For a new integration, communicate with the Data API directly or use an actively maintained Data API client.

## Data API or OData?

Migrating an existing PHP API project to the Data API is often the shortest path because both technologies use FileMaker layouts and scripts.

For a larger redesign, also evaluate the [FileMaker OData API](/what-is-the-filemaker-odata-api/). OData uses standard database concepts more directly and is now the preferred starting point for many new integrations.

## Need Help With the Migration?

fmcloud.fm supports the FileMaker Data API on its hosting plans. We can review an existing PHP integration, identify the FileMaker layouts and scripts it depends on, and plan a progressive migration without an unnecessary full rewrite.

For a general explanation of the API, see [What Is the FileMaker Data API?](/what-is-the-filemaker-data-api/).
