Networked Media Open Specifications

APIs: Query Parameters

←APIs - Load Balancing & Redundancy · Index↑ · Discovery→

The Query API supports a range of query string parameters which may be used as part of GET requests, or within Websocket subscriptions.

The following document describes the expected usage and behaviour of these query parameters alongside the RAML specification in order to aid implementers. A description of each individual query parameter is included within the RAML.

Pagination

Query APIs SHOULD support pagination of their API resources where the ‘paged’ trait is specified in the RAML documentation. Pagination is not used by Websocket subscriptions.

Query API clients MUST detect whether pagination is being used by examining the HTTP response headers for ‘X-Paging-Limit’ which MUST be returned in all cases where pagination is in use.

The following implementation notes should be observed:

Examples

The following examples aim to identify how pagination should behave in the presence of a set of registered data. In order to avoid displaying full resource representations, the only data listed here is the ‘update’ timestamp associated with each registered record. The same procedures can be applied where ‘creation’ timestamps and the ‘?paging.order=create’ parameter are used instead.

Where a paging limit is not specified in a request the server’s default is used.

Sample Data: Registered Node Update Timestamps (Comma-Separated)

[0:1, 0:2, 0:3, 0:4, 0:5, 0:6, 0:7, 0:8, 0:9, 0:10, 0:11, 0:12, 0:13, 0:14, 0:15, 0:16, 0:17, 0:18, 0:19, 0:20]

Each of the above corresponds to the update timestamp of a corresponding Node, in the format <seconds>:<nanoseconds> and displayed in ascending order. These will be used throughout the following examples.

Response payloads in the examples will show these values, but in a real implementation should be replaced by the corresponding JSON objects for the Nodes or other resources being queried.

Example 1: Initial /nodes Request

In this example there are no query parameters used in the request, but as the Query API supports pagination it returns a subset of the results with headers identifying how to page further into the collection.

Request

GET /x-nmos/v1.1/query/nodes

Response

Headers

Link: <http://example.api.com/x-nmos/query/v1.1/nodes/?paging.since=0:20&paging.limit=10>; rel="next", <http://example.api.com/x-nmos/query/v1.1/nodes/?paging.until=0:10&paging.limit=10>; rel="prev"
X-Paging-Limit: 10
X-Paging-Since: 0:10
X-Paging-Until: 0:20

Payload Resources

[
  0:20,
  0:19,
  0:18,
  0:17,
  0:16,
  0:15,
  0:14,
  0:13,
  0:12,
  0:11
]

Notes

Example 2: Request With Custom Limit

This request is similar to Example 1, but the client has chosen to use a custom page size limit.

Request

GET /x-nmos/query/v1.1/nodes?paging.limit=5

Response

Headers

Link: <http://example.api.com/x-nmos/query/v1.1/nodes/?paging.since=0:20&paging.limit=5>; rel="next", <http://example.api.com/x-nmos/query/v1.1/nodes/?paging.until=0:15&paging.limit=5>; rel="prev"
X-Paging-Limit: 5
X-Paging-Since: 0:15
X-Paging-Until: 0:20

Payload Resources

[
  0:20,
  0:19,
  0:18,
  0:17,
  0:16
]

Notes

Example 3: Request With Since Parameter

Request

GET /x-nmos/query/v1.1/nodes?paging.since=0:4

Response

Headers

Link: <http://example.api.com/x-nmos/query/v1.1/nodes/?paging.since=0:14&paging.limit=10>; rel="next", <http://example.api.com/x-nmos/query/v1.1/nodes/?paging.until=0:4&paging.limit=10>; rel="prev"
X-Paging-Limit: 10
X-Paging-Since: 0:4
X-Paging-Until: 0:14

Payload Resources

[
  0:14,
  0:13,
  0:12,
  0:11,
  0:10,
  0:9,
  0:8,
  0:7,
  0:6,
  0:5
]

Example 4: Request With Until Parameter

Request

GET /x-nmos/query/v1.1/nodes?paging.until=0:16

Response

Headers

Link: <http://example.api.com/x-nmos/query/v1.1/nodes/?paging.since=0:16&paging.limit=10>; rel="next", <http://example.api.com/x-nmos/query/v1.1/nodes/?paging.until=0:6&paging.limit=10>; rel="prev"
X-Paging-Limit: 10
X-Paging-Since: 0:6
X-Paging-Until: 0:16

Payload Resources

[
  0:16,
  0:15,
  0:14,
  0:13,
  0:12,
  0:11,
  0:10,
  0:9,
  0:8,
  0:7
]

Example 5: Request With Since & Until Parameters

Request

GET /x-nmos/query/v1.1/nodes?paging.since=0:4&paging.until=0:16

Response

Headers

Link: <http://example.api.com/x-nmos/query/v1.1/nodes/?paging.since=0:14&paging.limit=10>; rel="next", <http://example.api.com/x-nmos/query/v1.1/nodes/?paging.until=0:4&paging.limit=10>; rel="prev"
X-Paging-Limit: 10
X-Paging-Since: 0:4
X-Paging-Until: 0:14

Payload Resources

[
  0:14,
  0:13,
  0:12,
  0:11,
  0:10,
  0:9,
  0:8,
  0:7,
  0:6,
  0:5
]

Notes

Edge Cases

When a client requests data which falls at the extreme ends of the stored data set it may be less clear what values should be returned in the ‘X-Paging-Limit’ and ‘X-Paging-Since’ headers. The following examples are intended to clarify the expectation in these cases.

Where a paging limit is not specified in a request the server’s default is used.

Example 1: Client request occurs at the beginning of the data set

Request

GET /x-nmos/query/v1.1/nodes?paging.until=0:20

In this case, assume that there are stored records for ‘0:21’ and ‘0:22’ but no earlier.

Response

Headers

Link: <http://example.api.com/x-nmos/query/v1.1/nodes/?paging.since=0:20&paging.limit=10>; rel="next", <http://example.api.com/x-nmos/query/v1.1/nodes/?paging.until=0:0&paging.limit=10>; rel="prev"
X-Paging-Limit: 10
X-Paging-Since: 0:0
X-Paging-Until: 0:20

Payload Resources

[]

Example 2: Client request occurs at the end of the data set

Request

GET /x-nmos/query/v1.1/nodes?paging.since=0:20

In this case, assume that there are stored records for ‘0:19’ and ‘0:20’ but no later.

Response

Headers

Link: <http://example.api.com/x-nmos/query/v1.1/nodes/?paging.since=0:20&paging.limit=10>; rel="next", <http://example.api.com/x-nmos/query/v1.1/nodes/?paging.until=0:20&paging.limit=10>; rel="prev"
X-Paging-Limit: 10
X-Paging-Since: 0:20
X-Paging-Until: 0:20

Payload Resources

[]

Notes:

Example 3: Client request includes a query parameter resulting in a single result, but no paging parameters

Request

GET /x-nmos/query/v1.1/nodes?label=My%20Node

In this case, assume that the most recently created or updated Node held in the registry has a paging value of ‘0:20’ associated with it. Also assume that the Node with label ‘My Node’ has a paging time of ‘0:15’.

Response

Headers

Link: <http://example.api.com/x-nmos/query/v1.1/nodes/?label=My%20Node&paging.since=0:20&paging.limit=10>; rel="next", <http://example.api.com/x-nmos/query/v1.1/nodes/?label=My%20Node&paging.until=0:0&paging.limit=10>; rel="prev"
X-Paging-Limit: 10
X-Paging-Since: 0:0
X-Paging-Until: 0:20

Payload Resources

[
  0:15
]

Example 4: Client request includes a query parameter resulting in a no result, with no paging parameters

Request

GET /x-nmos/query/v1.1/nodes?label=My%20Invalid%20Node

In this case, assume that the most recently created or updated Node held in the registry has a paging value of ‘0:20’ associated with it.

Response

Headers

Link: <http://example.api.com/x-nmos/query/v1.1/nodes/?label=My%20Invalid%20Node&paging.since=0:20&paging.limit=10>; rel="next", <http://example.api.com/x-nmos/query/v1.1/nodes/?label=My%20Invalid%20Node&paging.until=0:0&paging.limit=10>; rel="prev"
X-Paging-Limit: 10
X-Paging-Since: 0:0
X-Paging-Until: 0:20

Payload Resources

[]

Downgrade Queries

Query APIs SHOULD support downgrade queries against their API resources where the ‘downgrade’ trait is specified in the RAML documentation.

Downgrade queries permit old-versioned responses to be provided to clients which are confident that they can handle any missing attributes between the specified API versions.

Examples

Example 1: No Downgrade Parameter

Request

GET /x-nmos/query/v1.1/nodes

Response

Example 2: Downgrade From v1.1 to v1.0

Request

GET /x-nmos/query/v1.1/nodes?query.downgrade=v1.0

Response

Example 3: Downgrade From v1.3 to v1.1

Request

GET /x-nmos/query/v1.3/flows?query.downgrade=v1.1

Response

Invalid Examples

Invalid Example 1: Downgrade Between Major API Versions

Request

GET /x-nmos/query/v3.0/flows?query.downgrade=v1.0

Response

Basic Queries

Query APIs SHOULD support basic queries against their API resources.

Queries may be performed using any attribute specified in a given resource’s schema, however the RAML documents only the core resource attributes for simplicity.

If a query parameter is requested which does not match an attribute found in any resource, an empty result set must be returned.

Examples

Example 1: Basic Query Using One Parameter

Request

GET /x-nmos/query/v1.0/senders?transport=urn:x-nmos:transport:rtp

Response

Example 2: Basic Query Using Two Parameters

Request

GET /x-nmos/query/v1.0/sources?format=urn:x-nmos:format:video&device_id=9126cc2f-4c26-4c9b-a6cd-93c4381c9be5

Response

Example 3: Querying Within Objects

Request

GET /x-nmos/query/v1.0/flows?tags.studio=HQ1

Response

Example 4: Querying Within Arrays

Request

GET /x-nmos/query/v1.0/nodes?services.type=urn:x-manufacturer:service:myservice

Response

Invalid Examples

Invalid Example 1: Duplicate Query Parameters

Request

GET /x-nmos/query/v1.0/flows?tags.location=Salford&tags.location=London

Response

Advanced (RQL) Queries (Optional)

Query APIs MAY support Resource Query Language (RQL) queries against their API resources where the ‘rql’ trait is specified in the RAML documentation. A 501 HTTP status code should be returned where a RAML query is attempted using RQL functions or operators which are not supported by a Query API.

Examples

Example 1: Simple Query

Request

GET /x-nmos/query/v1.1/senders?query.rql=eq(transport,urn%3Ax-nmos%3Atransport%3Artp)

Response

Example 2: Advanced Query

Request

GET /x-nmos/query/v1.1/sources?query.rql=and(eq(format,urn%3Ax-nmos%3Aformat%3Avideo),in(tags.location,(Salford,London)))

Response

Ancestry Queries (Optional)

Query APIs MAY support Source and Flow ancestry queries against their API resources where the ‘ancestry’ trait is specified in the RAML documentation. A 501 HTTP status code should be returned where an ancestry query is attempted against a Query API which does not implement it.

Examples

Example 1: Children Of A Source

Request

GET /x-nmos/query/v1.1/sources?query.ancestry_id=c1398579-15bc-468e-91ec-df5bbefe1cd3&query.ancestry_type=children

Response

Headers

X-Ancestry-Generations: 4

Payload

Notes

Example 2: Parents Of A Flow

Request

GET /x-nmos/query/v1.1/flows?query.ancestry_id=ad14888a-3a98-444c-8aa8-4d87b77cbaa1&query.ancestry_type=parents&query.ancestry_generations=2

Response

Headers

X-Ancestry-Generations: 2

Payload

Notes

←APIs - Load Balancing & Redundancy · Index↑ · Discovery→