SteveO-112358 Posted May 19, 2022 Share Posted May 19, 2022 I've been attempting to query Unraid's api for the past few days. My use case is to retrieve metrics for a grafana dashboard. I see there are some attempts to create an api for Unraid (e.g ElectricBrainUK's Unraid-API docker available in the CA). But I'm wondering if anyone has successfully used the official unraid-api implemented by the My Servers plugin to gather metrics from their own server? It uses graphql instead of the more well know REST-API. I'm part way there but I'm hoping someone with more experience than me can provide some concrete examples of how to authenticate and then get real information from a query. I finally stumbled across some information in /usr/local/bin/unraid-api/README.md and was able to find my api-key here: /boot/config/plugins/dynamix.my.servers/myservers.cfg Using the information in these, I enabled the graphQL playground at http://tower.local/graphql by restarting the unraid-api in debug mode (unraid-api restart -d) and then visiting the "/graphql" endpoint of my server. Tons of information in the graphql playground at that url, including the entire api schema and documentation. Unfortunately I'm not experienced enough with GraphQL to put 2 and 2 together to get what I need. So far I can query the endpoint with: query welcome { welcome { message } } and get back: { "data": { "welcome": { "message": "Welcome my_servers to this Unraid 6.10.0 server" } } } but anything else I try requires authentication - which I haven't yet cracked. E.g. see below query Info { info{ os {uptime } } } results in: { "errors": [ { "message": "my_servers doesn't have permission to access \"os\".", "locations": [ { "line": 3, "column": 5 } ], "path": [ "info", "os" ], "extensions": { "code": "INTERNAL_SERVER_ERROR" } } ], "data": { "info": { "os": null } } } I guess that's because the api-key I'm using and sending in the HTTP header is one that is generated by the "my_servers" user. But how to generate one that I can query my own server with? Or maybe I've got the wrong end of the stick and I can't actually use this to do what I want? Any help appreciated! Cheers Link to comment
ljm42 Posted May 19, 2022 Share Posted May 19, 2022 Our goal is to open this up to folks but we aren't ready yet. Link to comment
Sander0542 Posted April 9, 2023 Share Posted April 9, 2023 On 5/19/2022 at 9:21 PM, ljm42 said: Our goal is to open this up to folks but we aren't ready yet. Is there any update on this? I would love to use this for some projects Link to comment
Recommended Posts