Nanit Baby Monitor Integration

did you grab the correct baby_id from the results?

I got babies[0].id. for GET /babies/1234/events

EDIT: seems like it should be babies[0].uid

EDIT2: Be careful the events endpoint isnā€™t paginated by default, put a ?limit=100 on it to make sure it doesnā€™t take forever to return.

1 Like

Here is the info from the apk:
https://mega.nz/folder/CPgFHDDR#XaQECBeO1DhFkqEHZ3KJTw

I have very little experience in using this info, but assuming the info in the file
smali_classes2 > nanit \ baby > login

may help?

if you check out nanit/res/values/strings.xml thereā€™s a bunch of paths listed, unfortunately in my exploration I havenā€™t been able to figure out how to put them together to find other endpoints. Iā€™m looking for the stuff that populates the insights tab. But that may just be client-side aggregation of data from /events

are you able to load any of the event video urls?

Sorry if I missed this but does anybody have a link to the Nanit API docs or anything? I canā€™t find any info about the API.

Iā€™m going to try creating an integration.

2 Likes

No formal documentation but a bit of info a few posts up. Bless you for taking a crack at this, just took the plunge with a second monitor. Lol

They load for me:

1 Like

are you able to play the videos?

Iā€™m not sure how to structure the video with the key (so getting access denied)

At the bottom of the request, the videos are hosted on cloud front and I can play those. I canā€™t play the ones hosted by AWS.

Iā€™m happy to help out with this project. I reached out to Nanit support and confirmed that they have to public API.

What are you all using to MITM the Nanit requests in an unencrypted format?

1 Like

Iā€™ve tried using Charles and mitmproxy to figure out APIs to control the camera, but no luck. There seem to be no outgoing requests when I turn on the night light. Is this because camera control is implemented using websockets? If so, what should I look for to sniff out the camera controls?

Thatā€™s all cool Iā€™m in to sniff around

Here is an incomplete postman collection of Nanit API calls. Mostly GETs. All from nanit/res/values/strings.xml Also found these lines:

<string name="local_live_stream_url">rtmps://%1$s/nanit/local</string>
<string name="local_live_stream_url_no_tls">rtmp://%1$s/nanit/local</string>
<string name="nanit_base_media_url">rtmps://media-secured.nanit.com/</string>

%1$s probably needs to be replaced with either "public_address" or "private_address" from GET /babies response. But this is as close as cloud get to live streaming. Donā€™t know much about rtmps protocol.

Tried vlc -v tmps://<address>/nanit/local/?access_token=<token> Does not play.

2 Likes

I also couldnā€™t get rtmpdump working with that url :confused:

Hi All,

While I wouldnā€™t be very useful as a developer, Iā€™m happy to help test out an integration. I have a Nanit and Home Assistant running on a Synology NAS.

My two kids share a room, with the older one 7 years older than the new baby. Assuming there is a way to develop a state definition of in crib, alseep, crib empty (or something like that), I could imagine fantastic uses cases; hallway light in front of the kids room red when the baby is asleep, auto put Alexa on do not disturb or set Sonos volume to 0. Would also be nice to be able to pull the temperature & humidity data (one less sensor to buy), but that seems less critical.

Anyway, excited to help in anyway I can and happy to test any code.

Thanks,

  • Adi
1 Like

Hi everyone! Iā€™m quite new at this! I think Iā€™m missing the first step that allows me to find my access token. Is someone able to share steps in how to first connect to Nanitā€™s API? Sorry if Iā€™m not using the right terminology.

Dave

Hello guys, I did some digging and was able to stream the live feed. I hasnā€™t figure out how to connect to the camera locally yet, but you can load the cam stream through their servers (as the mobile app does).

The URL is: rtmps://media-secured.nanit.com/nanit/{{baby_uid}}.{{access_token}}

You can get both baby_uid and access_token through the API, I used the attached Postman collection in one of the posts above (thank you!).

I was able to successfully dump the stream to file with both rtmpdump and ffmpeg. However I was not able to open the stream directly in VLC. There seem to be some wonky support for RTMPS.

Currently I am using ffmpeg + nginx to restream the cam locally using HLS (so that it can be opened in Safari and from there AirPlay it to my TV in full resolution).

Hope these pieces of information will help somebody.

Happy hacking :slight_smile:

4 Likes

Hi Dave,

have you used the attached Postman collection for that? If so, you need to set your login / password as environment variables inside of Postman and run the first request. In the response body you will see access token.

A.

would you mind sharing more detail on how to get the stream to be usable?
do you need to refresh the token - it so how do you do that?

holy crap - that works, and really well - thanks for the url! hero
I wonder if there is a docker rtmpdump - then can add the output as a generic IP camera hmmmmm

EDIT:
docker run --name=nanit --restart=unless-stopped -v /mnt/user/appdata/nanit:/tmp/workdir amine/alpine-rtmpdump -r rtmps://media-secured.nanit.com/nanit/{BABYID}.{AccessToken} -o nanit.mp4

2 Likes