SolarNetwork

News » SolarQuery supports metadata search filters

For a long time now SolarNetwork has supported APIs for managing a flexible metadata object structure, which can be attached to various things like accounts, nodes, and node sources. There hasn’t been a good way to query the metadata, however. For example, you might want to know which nodes in your account have a metadata field hardware with a value raspberry-pi.

To help answer queries like that, we’ve added a new metadataFilter query parameter to various endpoints like /nodes and /range/sources. The syntax of the metadata filter is similar to LDAP search filters. Thus, to answer the query of which nodes are based on Raspberry Pi hardware, you would use a query like this:

/nodes?metadataFilter=(/p/hardware=raspberry-pi)

Or for another example, a metadata filter to find nodes based on Raspberry Pi running the Debian Buster OS or later:

(&(/p/hardware=raspberry-pi)(/p/os=debian)(/p/os-version>=10))

Given how flexible the SolarNetwork metadata structure is, the ability to perform queries like this can be very useful when building SolarNetwork based applications.