API improvements

Development never stops :slight_smile:

Yesterday a new release of the website/backend has been released and it adds the following improvements:

Package/Asset API speedup

The API calls for listing packages and listing assets have been improved and they should now be twice as fast. This might make a difference if you have a large number of assets or packages in your account. The package improvement reduced some load to the database by intelligent caching of often accessed package information like package information and their node configuration options. You can see the difference to the database load in the graph from the monitoring system:

API call list filters

Previously only the device check API call supported filters. Now this has been extended to other API calls. This feature is still undocumented at the moment. Until that’s done, here’s a small preview of what’s possible now (all query strings unquoted to make them more readable. Use a library to construct them in a real world use case!):

  • Filtering device list by device location:

    https://info-beamer.com/api/v1/device/list?filter:location=HQ/*
    

    This would return a list of only those devices with a location starting with HQ/

  • Filtering by other properties:

    https://info-beamer.com/api/v1/device/list?filter:feature=hevc
    

    Only return devices that can play HEVC (H265) videos.

  • Filter by nested information:

    https://info-beamer.com/api/v1/device/list?filter:setup.id=1234
    

    Only return devices that have the setup 1234 assigned.

  • Filter by userdata:

    https://info-beamer.com/api/v1/device/list?filter:userdata.dummy=true
    

    Only return devices with a userdata value that includes the boolean value dummy set to true.

Right now the device list, setup list and asset list calls have support for filtering. Note that not all properties can be filtered. Official documentation will follow. Feedback welcome.

3 Likes

Looks like we requests that are urlencoded wont be answerd…

curl -u ":XXX" "https://info-beamer.com/api/v1/device/list?filter%3Alocation%3DHQ"
{"error":"Cannot list devices: Cannot filter by location=HQ"}

can you enable this too?

That quoted the name/value separator =. The name in the case is filter%3Alocation, which is the correctly quoted value filter:location. The value is HQ and doesn’t need quoting in that case. The combined correct parameter is therefore filter%3Alocation=HQ. The = must not be quoted itself, otherwise it becomes part of the name/value rather than being a separator. Are you using a library to construct the query url?

thx, with this information i was able to create a workaround.
i do indeed use a library (Flexirest) which uses : in the query as an indicator for variable substitution.

i now explict use the urlencoded : (%3A) in the request builder:
get :list_filtered, '/device/list?filter%3A:filter=:location', ignore_root: 'devices'

Interesting. Didn’t expect that. Good to know that the workaround is rather trivial.