REST web API for the libgphoto2 library. You can use it to take pictures, previews (handy for implementing poor man's liveview feature), control/obtain various camera settings, and access connected camera's filesystem - all via JSON-based requests.
- Providing a generic camera REST API
- Providing a feature parity with libgphoto2 library
- Being a testbed for gphoto2.cr shard
- Clean and readable code β¨
- Rock-solid stability πͺ¨
- High performance π
- Including customizable business logic
- Including camera-specific features
- Multiple cameras support
- Camera detection
- Camera identification
- Camera connection reloading
- Camera ability detection
- Image capture 1
- Live-view 1
- Configuration reading/modification 1
- Filesystem access 1
- Folder download as ZIP archive 1
- Folder creation 1
- Folder removal 1
- File download (in several formats 2) 1
- File preview (incl. raw camera formats) 1
- File upload 1
- File removal 1
Tip
Passing SENTRY_DSN env var while building/running will provide you with error reporting
- Run
shards installin order to install required dependencies - Next, execute
shards build [--release] [-Dpreview_mt]to build the binary - Now you're ready to go!
- It's as easy as running
./bin/serverin your terminal - Checking the http://localhost:3000/cameras endpoint will give you a list of detected cameras
- It's as easy as running
-
GET /camerasParameters:
name value description reloadtrueReloads the camera list beforehand
-
GET /cameras/:id -
GET /cameras/:id/captureParameters:
name value description deletetrueDeletes the image after capture -
GET /cameras/:id/preview -
GET /cameras/:id/exit
-
GET /cameras/:id/configParameters:
name value description reloadtrueReloads the camera configuration beforehand flattrueReturns one-dimensional configuration map, keyed by widget name -
PATCH /cameras/:id/configExample request:
curl \ -X PATCH \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d '{"whitebalance": "Automatic", "iso": 800, "f-number": "f/4.5"}' \ "http://localhost:3000/cameras/5a337150-30ba-40fd-adc2-b9ffacdad188/config"
-
GET /cameras/:id/config/:widget -
PATCH /cameras/:id/config/:widgetExample request:
curl \ -X PATCH \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d '{"value": "Automatic"}' \ "http://localhost:3000/cameras/5a337150-30ba-40fd-adc2-b9ffacdad188/config/whitebalance"
-
GET /cameras/:id/fs -
GET /cameras/:id/fs/*path -
DELETE /cameras/:id/fs/*path -
PUT /cameras/:id/fs/*pathExample request:
curl \ -X PUT \ -H "Accept: application/json" \ "http://localhost:3000/cameras/5a337150-30ba-40fd-adc2-b9ffacdad188/fs/store_00010001/DCIM007"
-
GET /cameras/:id/blob/*filepathParameters:
name value description downloadtrueMakes the browser download the image instead of displaying it formatjpeg/webp/avif/png/autoReturns the image in a given format, autochooses between the original format, if it's supported by the browser, and falls back tojpegotherwisewidthinteger Returns the image scaled down to the given width heightinteger Returns the image scaled down to the given height -
DELETE /cameras/:id/blob/*filepath -
PUT /cameras/:id/blob/*pathExample request:
curl \ -X PUT \ -H "Accept: application/json" \ -F file="@/path/to/file.jpg" \ "http://localhost:3000/cameras/5a337150-30ba-40fd-adc2-b9ffacdad188/blob/store_00010001/DCIM007/IMG_0001.jpg"
GET /cameras/:id/zipGET /cameras/:id/zip/*path
Tip
You can use a smartphone for basic development and testing.
- Pass
DEBUG=1inshards buildstep to compile-in the debug support. Afterwards you can use it by passingDEBUG=1env variable when running the server (DEBUG=1 ./bin/server)
- Fork it (https://github.com/Sija/gphoto2-web/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
- Sija Sijawusz Pur Rahnama - creator, maintainer