Json Interface

Joined
Aug 8, 2017
Messages
1
Reaction score
0
I'm a programmer and I'm looking for interfacing with the BlueIris Json Interface. I want running the Login (JAVASCRIPT POST COMMAND) command, I can not get the session variable needed to access. Can anyone tell me something about it?
JSON interface
 
Last edited:

jredcld

n3wb
Joined
Jun 19, 2016
Messages
17
Reaction score
4
Hi, I'm a programmer too. You may want to try/check out this code: https://github.com/magapp/blueiriscmd/blob/master/blueiris.py.

Basically, you request a "session response" by logging onto the BI webserver with your user and password values. You save that "session response" and use it for other commands.

Personally, I think the BI json interface needs a *lot* more functionality added to it. I have a need to change Trigger settings at random times, but that's just me...
 

bp2008

Staff member
Joined
Mar 10, 2014
Messages
12,680
Reaction score
14,041
Location
USA
If you inspect the source of Blue Iris's login page(function login), that page uses the json API to log in.

Basically you just send an empty login command:

Code:
POST http://192.168.0.166:81/json HTTP/1.1
Host: 192.168.0.166:81
Connection: keep-alive
Content-Length: 15
Accept: application/json, text/javascript, */*; q=0.01
Origin: http://192.168.0.166:81
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
Content-Type: text/plain
Referer: http://192.168.0.166:81/login.htm?page=%2Fui3.htm
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9

{"cmd":"login"}
The response contains a new session ID for you, and indicates that you need to generate a "response" field containing the hashed credentials.

Code:
HTTP/1.1 200 OK
Server: BlueIris-HTTP/1.1
Date: Wed, 22 Aug 2018 18:53:06 GMT
P3P: CP="CAO COR CURa ADMa DEVa OUR IND ONL COM DEM PRE"
Access-Control-Allow-Origin: *
Connection: Close
Cache-Control: no-cache, no-store
Content-Type: application/json
Content-Length: 118

{"result":"fail","session":"19713c7d023d4da103c41c95501d22e6","data":{"auth-exempt":true,"reason":"missing response"}}
(note in this case the "auth-exempt":true indicates that anonymous access is enabled)

Anyway you respond to that as outlined in the JSON API documentation.

Code:
POST http://192.168.0.166:81/json HTTP/1.1
Host: 192.168.0.166:81
Connection: keep-alive
Content-Length: 106
Accept: application/json, text/javascript, */*; q=0.01
Origin: http://192.168.0.166:81
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
Content-Type: text/plain
Referer: http://192.168.0.166:81/login.htm?page=%2Fui3.htm
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Cookie: session=65381faf6f6d1b637afa28986ed16d8d

{"cmd":"login","session":"19713c7d023d4da103c41c95501d22e6","response":"4b4fa041c0fa5579a0ad7f9a9ec2f102"}
And BI should respond with success if it worked:

Code:
HTTP/1.1 200 OK
Server: BlueIris-HTTP/1.1
Date: Wed, 22 Aug 2018 18:53:06 GMT
P3P: CP="CAO COR CURa ADMa DEVa OUR IND ONL COM DEM PRE"
Access-Control-Allow-Origin: *
Connection: Close
Cache-Control: no-cache, no-store
Content-Type: application/json
Content-Length: 2446

{"result":"success","session":"19713c7d023d4da103c41c95501d22e6","data":{…}}
 
Top