WaWy Camera API is a set of APIs written in Node JS that allow any thirds applications like Smartphone App or Web App to take photo, create a timelapse or streaming a video from a Raspberry Pi.
This API is the main piece of an entiere project call "WAWY". More information about WaWy can be found here https://wawy.io
Wanted to start playing with WaWy Camera API in a couple of minutes ? Just wget https://raw.githubusercontent.com/wawycam/installer/master/wawycam-install-dependencies.sh then chmod u=rx wawycam-install-dependencies.sh and sudo ./wawycam-install-dependencies.sh
You can get more information about the installer here.
After installation completed, the API should be up and running on port 3001. On your Raspberry Pi, just execute this request :
curl "http://localhost:3001/service/version" -H 'Content-Type: application/json; charset=utf-8'
The answer should be
{"version":"0.4.0"}
You can also send a request to the API from your computer. Just be sure that your Raspberry and your computer are on the same Wifi network and replace "localhost" by the name of your raspberry (can be found in /etc/hostname)
curl "http://{your-raspberypi-name}.local:3001/service/version" -H 'Content-Type: application/json; charset=utf-8'
Note: depending on your environmment, the dependencies installation can take up to 10 minutes on a Rapsberry PI 3
First, well, clone this repository ;-)
git clone https://github.com/wawycam/api.git
and then
npm install
and then
npm start
Note: as some features require dependencies, we encourage you to run the installer before. You can get more information about the installer here.
Clone this repository
git clone https://github.com/wawycam/api.git
and then
npm install
and then
npm run dev
The APIs is running on your Raspberry PI on port 3001 in "development" mode.
npm run test
Be sure that the Rapsberry Pi and your Computer are on the same WiFi.
You can request the API depending on the name of your Rapsberry PI. The name can be found by typing
/etc/hostname
Open up a terminal on your computer and type the folowing command (please change "wawycam" according to the name of your Raspberry Pi)
curl "http://wawycam.local:3001/service/version" -H 'Content-Type: application/json; charset=utf-8'
Wich should return this result
HTTP/1.1 200 OK
Server: API
Content-Type: application/json
Content-Length: 7
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, Api-Version, Response-Time
Access-Control-Allow-Methods: GET
Access-Control-Expose-Headers: Api-Version, Request-Id, Response-Time
Connection: close
Content-MD5: I2N2ZdnviPIQIH8gzt1yIQ==
Date: Sun, 26 Nov 2017 12:49:48 GMT
Api-Version: 1.0.0
Request-Id: f7db37ca-2264-40da-9410-c7310a710441
Response-Time: NaN
{"version":"0.4.0"}
This API allow you to stream a real-time video. The API use Picam for recording and ffmpeg+nginx to broadcast.
Please go to https://github.com/wawycam/installer to get more informations about dependencies and configuration.
To start broadcasting :
curl -X "POST" "http://localhost:3001/video/broadcast" \
-H 'Content-Type: application/json; charset=utf-8'
The API should respond
{
"url":{
"local":"http://{your-camera-name}.local/live/index.m3u8",
"remote":"http://xxx.xxx.xxx.xxx/live/index.m3u8"
}
}
Open a video player like VLC and copy/paste the "local" url. You should see the video streaming.
Note : The HTTP Live Streaming latency is 3-4 seconds.
Start broadcasting video
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body: -
-
Status: 200
-
Body:
{
"url":{
"local":"http://wawycam.local/live/index.m3u8",
"remote":"http://xxx.xxx.xxx.xxx/live/index.m3u8"
}
}
Stop broadcasting video
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body: -
- Status: 204
Take a photo
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body: -
-
Status: 200
-
Body:
{
"photo": "025d7c1e-3766-45c1-bf41-ed0c4469c08f.png"
}
note: assuming you correctly set the nginx configuration you can display the photo in a browser via http://{your-raspberypi-name}/photo/{photo-url}
Apply a filter on a photo.
Filters can be : 'xpro2', 'willow', 'lofi', 'juno', 'clarendon', '1977'
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body:
{
"filter": "xpro2",
"photo": "timelapse-2017-11-20-10:29/0002.png"
}
Start a timelapse
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body:
{
"interval": "30"
}
- Status: 201
Stop a timelapse
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body: -
- Status: 204
Create a timelapse video based on a photos series.
Note: this route call WaWy Microservice API read more
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body:
{
"folder": "timelapse-2017-11-20-10:29"
}
Delete timelapse images and folder
-
Headers: No specific headers needed.
-
Url Params: timelapse folder
-
Body: -
- Status: 204
Get last photo of a timelapse
-
Headers: No specific headers needed.
-
Url Params: timelpasefolder.
-
Body: -
-
Status: 200
-
Body:
{
"photo": "0044.png"
}
List all photos in ./snap folder
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body: -
-
Status: 200
-
Body:
{
"photos": [
"snap/025d7c1e-3766-45c1-bf41-ed0c4469c08f.png",
"snap/538946eb-03f0-42ee-8a40-20a9c829b42c.png",
"snap/7e9b8d57-fc68-4912-9993-f119137088ea.png",
"snap/801c2edf-9ee7-47bc-8e05-702238354326.png",
"snap/be02b3c1-a3f1-4c73-9289-22a04ec5a5aa.png",
"snap/timelapse-2017-11-20-10:29/0001.png",
"snap/timelapse-2017-11-20-10:29/0001_1977.png",
"snap/timelapse-2017-11-20-10:29/0002.png",
"snap/timelapse-2017-11-20-10:29/0002_lofi.png",
"snap/timelapse-2017-11-20-10:29/0002_xpro2.png",
"snap/timelapse-2017-11-20-10:29/0003.png",
"snap/timelapse-2017-11-20-10:29/480x_0001.png",
"snap/timelapse-2017-11-20-10:29/480x_0002.png",
"snap/timelapse-2017-11-20-10:29/480x_0003.png",
"snap/timelapse-2017-11-20-10:29/photos.tgz",
"snap/timelapse-2017-11-20-10:29/timelapse.mp4"
]
}
Return WaWy informations
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body: -
-
Status: 200
-
Body:
{
"__v": 0,
"_id": "5a11a80f3208f10ce34944bb",
"createdAt": "2017-11-19T15:49:35.953Z",
"isBroadcasting": false,
"isSnapping": false,
"name": "wawycam",
"rotation": 270,
"serial": "00000000fe864d2f",
"updatedAt": "2017-11-26T11:30:09.938Z",
"timelapses": [
{
"_id": "5a12aea294151736e654f5d7",
"count": 3,
"name": "timelapse-2017-11-20-10:29",
"status": "processing",
"updatedAt": "2017-11-20T10:30:27.421Z",
"photos": [
{
"_id": "5a12aeaf94151736e654f5d8",
"name": "0001.png"
},
{
"_id": "5a12aeb994151736e654f5d9",
"name": "0002.png"
},
{
"_id": "5a12aec394151736e654f5da",
"name": "0003.png"
}
]
},
{
"_id": "5a1aa5b7b134fd217008bdf2",
"count": 0,
"name": "timelapse-2017-11-26-11:29",
"photos": []
}
]
}
Change Camera name
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body:
{
"name": "wawycam"
}
- Status: 201
Change Camera Rotation Lens
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body:
{
"degree": 90
}
- Status: 201
Create QR Code based on WaWy's name
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body: -
- Status: 201
Return WaWy QRCode in SVG
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body: -
-
Status: 200
-
Body:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" baseProfile="full" width="132" height="132" viewBox="0 0 132 132" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events">
<rect x="0" y="0" width="132" height="132" fill="rgb(255,255,255)" fill-opacity="1.00" />
<defs><rect id="p" width="4" height="4" /></defs>
<g fill="rgb(0,0,0)" fill-opacity="1.00">
<use x="16" y="16" xlink:href="#p" />...
Return API version
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body: -
-
Status: 200
-
Body:
{
"version": "0.4.0"
}
Return API status
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body:-
-
Status: 200
-
Body:
"alive"
Return WaWy Uptime and Disk strorage information
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body: -
-
Status: 200
-
Body:
{
"disk": {
"free": "3.32",
"total": "7.19"
},
"uptime": 1511538891
}
Return WaWy Serial number
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body: -
-
Status: 200
-
Body:
{
"serial":"00000000fe864d3f"
}
reboot wawy camera
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body: -
- Status: 201
halt wawy camera
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body: -
- Status: 201
Return ssids list
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body: -
-
Status: 200
-
Body:
{
"list": [
{
"bssid": "f4:ca:e5:e7:da:52",
"signalLevel": 2467,
"ssid": "home"
},
{
"bssid": "f4:ca:e5:e7:da:5b",
"signalLevel": 2467,
"ssid": "office"
},
{
"bssid": "f4:ca:e5:e7:ca:52",
"signalLevel": 2467,
"ssid": "open"
}
]
}
Associate to a ssid
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body:
{
"ssid": "home",
"psk": "secret"
}
- Status: 201
Return enabled ssids list
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body: -
-
Status: 200
-
Body:
{
"list": [
{
"id": 0,
"ssid": "iPhone"
},
{
"id": 1,
"ssid": "home"
}
]
}
Get Wifi status
-
Headers: No specific headers needed.
-
Url Params: No specific query parameters needed.
-
Body: -
-
Status: 200
-
Body:
{
"ssid": "home",
"ip_address": "192.168.0.51"
}