View Full Version : REST API server on Girder

March 16th, 2016, 06:48 AM
is possible to read some values from Girder via http, like REST API? I have other device, who need some information from Girder.

http://user: password@IP/api/Variables/LGTV_STATE

and answer would be
{"name: "LGTV_STATE",
"Input": "HDMI1",
"Power": "off",
"PowerTimeStamp": ""

like at my variable at printscreen at attachment.
Thank you

March 18th, 2016, 07:36 AM
Came to think about your post when I saw this in the manual, maybe it will help...

addModRewrite allows you to create URL that do not exists in your httpd folder and translate them to existing files. This for example is very handy if you wish to create a Restful server in Girder.

For example say you'd like to accept a url in this form:


You could create a .lhtml that takes 3 cgi parameters:

local cgi = getCGI()
print(cgi['deviceId'] .. "<BR>")
print(cgi['actionName'] .. "<BR>")
print(cgi['actionParam'] .. "<BR>")

let's name that modrewrite.lhtml and place it in the httpd directory. In a scripting action register the rewrite. Probably a good idea to attached a GirderStarted event to this scripting action.

webserver.addModRewrite("http://([a-zA-Z0-9.]+)/devices/(\\d+)/action/([^/]+)/(.*)", "http://$1/modrewrite.lhtml?deviceId=$2&actionName=$3&actionParam=$4")

Now next time you pull up this page you should see the parameters displayed.

Note: webserver.addModRewrite should be called before the HTTP request is made.

March 20th, 2016, 11:08 AM
Yes, thanks, this works. It get back parameters from url.
Can it get back some actual informations from Girder?