Skip to content

Optional Parameters ​

These parameters provide a flexible way to modify API requests or plan commands. Use them to apply filters, specify sorting options, or include additional data as needed. Their function remains consistent across both API requests and plan commands.

All parameters are described in the table below:

ParameterUsageGET
select
POST
insert
PATCH
update
DELETE
delete
JS ContextMetal version
📜filtersimple filterđŸŸĸ-đŸŸĸđŸŸĸ$schema, $entityv0.4+
📜filter-expressioncomplex filter expressionđŸŸĸ-đŸŸĸđŸŸĸ$schema, $entityv0.4+
📜fieldsselect fields to returnđŸŸĸ---$schema, $entityv0.4+
📜sortsort data with a given orderđŸŸĸ---$schema, $entityv0.4+
cachecache returned data for a given timeđŸŸĸ---N/Av0.1+
đŸ“œâ‡ī¸datadata to send to provider-đŸŸĸđŸŸĸ-$schema, $entityv0.4+

📜: Supports JavaScript Expression Engine (see: JavaScript Expression Engine)

â‡ī¸: supports Field Escape Engine (see: Field Escape Engine)

How Optional Parameters are handled by Data Providers ​

Data Providerdatafilterfilter-expressionfieldssortcache
Azure SQL Database/Microsoft SQL ServerđŸ”ĩđŸ”ĩđŸ”ĩđŸ”ĩđŸ”ĩđŸŸĸ
FilesđŸŸĸđŸŸĸđŸŸĸđŸŸĸđŸŸĸđŸŸĸ
MemoryđŸŸĸđŸŸĸđŸŸĸđŸŸĸđŸŸĸđŸŸĸ
Metal ServerđŸ”ĩđŸ”ĩđŸ”ĩđŸ”ĩđŸ”ĩđŸ”ĩ
MongoDBđŸ”ĩđŸ”ĩđŸ”ĩđŸ”ĩđŸ”ĩđŸŸĸ
MySqlđŸ”ĩđŸ”ĩđŸ”ĩđŸ”ĩđŸ”ĩđŸŸĸ
Plan-đŸŸĸđŸŸĸđŸŸĸđŸŸĸđŸŸĸ
PostgreSQLđŸ”ĩđŸ”ĩđŸ”ĩđŸ”ĩđŸ”ĩđŸŸĸ
WebService🟡đŸŸĸđŸŸĸđŸŸĸđŸŸĸđŸŸĸ
Cosmos DBđŸ”ĩđŸ”ĩđŸ”ĩđŸ”ĩđŸ”ĩđŸŸĸ

đŸ”ĩ Handled natively by the data provider driver

🟡 Partially handled by the data provider driver

đŸŸĸ Handled by Metal Server

Parameters ​

filter ​

Simple filtering feature by providing fields and values.

Supports JavaScript Expression Engine.

Example

To filter people with name = John and location = USA:

GET Request

http
GET /schema/my-schema/my-entity
    ?filter={"Name":"John","Location":"USA"}

PATCH Request

http
PATCH /schema/my-schema/my-entity
Content-Type: application/json

{
	"filter": {
		"Name": "John",
		"Location": "USA"
	}
}

DELETE Request

http
DELETE /schema/my-schema/my-entity
Content-Type: application/json

{
	"filter": {
		"Name": "John",
		"Location": "USA"
	}
}

filter-expression ​

Free expression for more complex data filtering expressed in SQL-like syntax.

Supports JavaScript Expression Engine.

Example

GET Request

http
GET /schema/my-schema/my-entity
    ?filter-expression=name LIKE '%%ing'

PATCH Request

http
PATCH /schema/my-schema/my-entity
Content-Type: application/json

{
	"filter-expression": "name LIKE '%ing' "
}

DELETE Request

http
DELETE /schema/my-schema/my-entity
Content-Type: application/json

{
	"filter-expression": "name LIKE '%ing' "
}

â„šī¸ NOTE

When employing the LIKE operator with the wildcard % in a GET method, remember to escape it using double %%.

Example:

filter-expression=name LIKE '%%ing'

fields ​

Select fields to return.

Supports JavaScript Expression Engine.

Example

http
GET /schema/my-schema/my-entity
    ?fields="name, country"

sort ​

sort data with given order.

Supports JavaScript Expression Engine.

Sorting OperatorUsageSQL like
ascAscending orderASC
descDescending orderDESC

Example

To sort data with name ascending then email descending:

http
GET /schema/my-schema/my-entity
    ?sort={"name": "asc","email": "desc"}

cache ​

Instruct Metal to cache the data returned from the source for a given time in seconds before displaying it to the user end point, meanwhile users that hit again the same query will receive the cached data until it expires.

Example

To cache returned data for 60 seconds:

http
GET /schema/my-schema/my-entity
    ?cache=60

data ​

this paramater is used for inserting or updating data.

Supports JavaScript Expression Engine and Field Escape Engine only for updates (see: Field Escape Engine)

Inserting data ​

:data accept whether a JSON object if it is a single row to insert or a JSON Array if many rows

Example: single row insert

Request

http
POST /schema/my-schema/my-entity
Content-Type: application/json

{
	"data":
	{
		"name":"Facebook",
		"color": "blue"
	}
}

Response

http
HTTP/1.1 201 Created

Example: multiple rows insert

Request

http
POST /schema/my-schema/my-entity
Content-Type: application/json

{
	"data": [
		{ "name":"Facebook", "color": "blue" },
		{ "name":"YouTube",  "color": "red"  }
	]
}

Response

http
HTTP/1.1 201 Created

Updating data ​

:data accept a JSON object of key:value where key is the field to modify and value is the new value

Example

Request

http
PATCH /schema/my-schema/my-entity
Content-Type: application/json

{
	"data":
	{
		"name":"Facebook",
		"color": "blue"
	}
}

Response

http
HTTP/1.1 204 No Content

Released under the GNU v3 License.