API v1 Query Filters
Overview
Filters can be passed to supported endpoints as regular GET parameters.
Accepted parameters are:
- primary (alias p)
- sub (alias s)
- extension (alias e)
If any other param(s) are provided, the server will respond with an error status 400 with error details in the JSON body.
The query semantics are different for multiple parameters depending on if they are different or if the same parameter is provided more than once. If two different parameters are provided, they are treated as a logical AND, but if the same parameter is provided more than once, that parameter is treated as a logical OR of all the values provided. For example, the request:
GET https://www.typicalmime.com/api/v1/type?p=application&s=xml&s=json
Negative Queries
Negative queries are supported as well.
To provide a negative query value, an exclamation point "!" should be percent-encoded at the beginning of the value. E.g. %21application
The semantics of negative queries are the same as positive queries but result in exclusion of the matched resources instead of inclusion, so negating the same query values used in a positive query will result in the inverse set of resources being returned.
Positive and negative queries can be used together and are interpreted as a logical AND of the respective sets of positive and negative query values. For example, the request:
GET https://www.typicalmime.com/api/v1/type?p=audio&p=video&s=%21mp4&s=%21aac
Negative queries are useful for excluding a specific MIME type from a request. E.g. .../type?p=%21application&s=%21json
Primary Type Parameter
GET https://www.typicalmime.com/api/v1/endpoint?primary=value
or
GET https://www.typicalmime.com/api/v1/endpoint?p=value
Filter the results to the specified primary type. E.g. "application" from "application/json".
When used on an endpoint that returns type resources or any data derived from them, this filters the results to media types that have the corresponding primary type.
When used on an endpoint that returns extension resources or any data derived from them, this filters the results to the extensions that are used by media types that have the corresponding primary type.
Sub Type Parameter
GET https://www.typicalmime.com/api/v1/endpoint?sub=value
or
GET https://www.typicalmime.com/api/v1/endpoint?s=value
Filter the results to the specified sub type. E.g. "json" from "application/json".
When used on an endpoint that returns type resources or any data derived from them, this filters the results to media types that have the corresponding sub type.
When used on an endpoint that returns extension resources or any data derived from them, this filters the results to the extensions that are used by media types that have the corresponding sub type.
File Extension Parameter
GET https://www.typicalmime.com/api/v1/endpoint?extension=value
or
GET https://www.typicalmime.com/api/v1/endpoint?e=value
Filter the results to the specified file extension. E.g. "json" for .json files.
When used on an endpoint that returns type resources or any data derived from them, this filters the results to media types that use the corresponding file extension.
When used on an endpoint that returns extension resources or any data derived from them, this filters the results to the extensions that have a name property matching the value of the query parameter.