Perform a find request

To perform a find request, use an HTTP POST method with the _find API endpoint specifying the database name and the layout, and additional information to specify the query fields and criteria, sort order, starting record, and number of records. You can also specify portal information to limit the number of related records that are returned.

HTTP method

POST

URL

/fmi/data/version/databases/database-name/layouts/layout-name/_find

version – the FileMaker Data API version requested can use v1, v2, or vLatest

  • version 1 (v1) - the structure for returned portal data is based on the view setting (Form View or Table View) of the specified layout.

    • Form View - returns all related records

    • Table View - returns the first related record

      Note  Changing the view setting alters the portal data structure for the returned value.

  • version 2 (v2) - the structure for returned portal data is based on Form View.

  • latest version (vLatest) - the behavior is based on the last version of the API.

database-name – the name of the hosted database

layout-name – the layout to use as the context for the find request

HTTP header

Content-Type: application/json

Authorization: Bearer session-token, where session-token is the unique X-FM-Data-Access-Token value for the database session

Parameters

A query in JSON format specifying the fields and find criteria. You can use optional parameters to specify omit requests, the sort order, starting record (offset), number of records (limit), and portals for limiting the number of related records that are returned. The offset, limit, and sort parameters work on records found in the layout's table and not related portal records. To restrict the number of records and rows to display in a related set, specify the offset.portal-name and limit.portal-name parameters.

If you want the response data in the context of a different layout, use the layout.response parameter.

For example:

Copy
{
  "query":[
    {"Group": "=Surgeon"},
    {"Work State" : "NY", "omit" : "true"}],
  "sort":[
    {"fieldName": "Work State","sortOrder": "ascend"},
    {"fieldName": "First Name", "sortOrder": "ascend"} ]
}

Example with offset, limit, and portals:

Copy
{
  "query":[
    {"Group": "=Surgeon"},
    {"Work State" : "NY", "omit" : "true"}],
  "portal": ["Portal1","Portal2"],
  "limit": "10",
  "offset": "1",
  "offset.Portal1": "1",
  "limit.Portal1": "5",
  "layout.response": "Doctors"
}

You can run FileMaker scripts as part of this request by including the script.prerequest, script.presort, and script parameters in the request body. See Run FileMaker scripts.

Response

The record data in JSON format and a messages array showing an error code of 0.

For example:

Copy
{
  "response": {
    "data": [ 
    ...  
    ]
  },
  "messages": [{"code":"0","message":"OK"}]
}

See Error responses.

Notes 

  • Sorting and returning records can be time consuming. Reduce record download time by limiting the number of fields on the requested layout and omitting fields that contain comments.

  • You cannot specify global fields as find criteria. If you specify a global field with a find request, you receive an error message. Instead, set the global field value before the find request. See Set global field values.