Five ways to get a picture to the API
Your own service, the camera itself, a recorder over FTP, a direct call or the Camly Bridge: what each way needs on site, what it gives, and how to choose.
The first question in any camera integration is not about the analysis. It is about plumbing: how does a picture get from that camera, on that network, behind that firewall, to an API on the internet?
There is no single good answer, because sites differ. One has a video management system (VMS) with an SDK. Another has a ten-year-old recorder and nothing else. A third has one network camera and no computer at all. The Camly API accepts pictures in five ways so that the answer can follow the site instead of the other way round.1
The five ways
1. Push from your own service. Code of yours, beside the VMS or on a gateway, takes a picture and sends it to POST /v1/cameras/{id}/frames. The most control: you choose the cameras, the moments and the size of the picture.
2. The camera sends itself. Most network cameras can send a JPEG to an HTTPS address on an event or a timer. Give the camera an upload URL and it feeds Camly directly. No code, no box.
3. A recorder over FTP. A DVR or an NVR usually cannot call an HTTPS address, but nearly all can upload snapshots by FTP. One FTP login, and each channel becomes a camera.
4. A direct check. POST /v1/runs with a picture and a question, answer in the same call. No camera object, no monitor. Right for a one-off question or a picture exported from a recording.
5. The Camly Bridge. A small program on the site’s network that reads the cameras over RTSP or ONVIF, keeps the schedule on site and only calls out, so no port is opened.
What each one gives
| Way in | Monitors and incidents | Questions about the past | On site |
|---|---|---|---|
| Push from your service | Yes | No | Your service and a key that can only push |
| Camera upload URL | Yes | No | Nothing: an address |
| Recorder FTP | Yes | No | Nothing: an FTP login |
| Direct check | No, one answer per call | Pictures from your own recordings | Your code and a key |
| Camly Bridge | Yes | Yes: look-back, pictures of a window, clips | The Bridge program |
A picture sent by any way is checked at the same price, and an incident keeps the picture that was checked as evidence.
The column to look at is the third. Searching the past needs an archive, and only the Bridge keeps one, on the site’s own machine. If your product has to answer “show me the handover at 19:34 yesterday”, that decides it. If it only has to say “the exit is blocked now”, any of the first three will do.
Choosing, in one pass
Take the first line that is true for the site.
- The VMS or the camera can send a snapshot to an HTTPS address on an event: use an upload URL. Nothing to write.
- The recorder or the VMS can upload snapshots by FTP: create a recorder, give it the login.
- The VMS has an API or an SDK that returns a camera’s current picture: write a small service beside it that pushes.
- None of these: install the Bridge.
A service beside a VMS
Option 3 is about thirty lines:
import requests
API = 'https://api.camly.ai/v1/cameras/{}/frames'
KEY = 'cmly_sk_live_...' # a Push only key
CAMERAS = {'vms-cam-12': 'cam_123'} # your VMS camera id -> Camly camera id
def vms_snapshot(vms_camera):
"""Return the current JPEG of a camera, from your VMS's own API or SDK."""
...
def send(vms_camera, trigger='schedule'):
jpeg = vms_snapshot(vms_camera)
r = requests.post(API.format(CAMERAS[vms_camera]), timeout=30,
headers={'Authorization': f'Bearer {KEY}'},
files={'image': ('frame.jpg', jpeg, 'image/jpeg')},
data={'trigger': trigger})
return r.json().get('next_frame_seconds') if r.ok else None
Call send(camera, 'motion') from the VMS’s motion event, and send(camera) on a timer that follows the next_frame_seconds of each answer. If the VMS already detects motion, you pay only for pictures that matter.
Three details save trouble later.
Send the main stream, not the thumbnail. Each check uses the picture at 1280 pixels on its longest side. A sub-stream at 640 pixels is enough for “is there a van”, and not enough for a label or a small object.
Drop a picture you could not send. When the connection fails, do not queue the picture to send it later. It would be checked as the present, and an old picture says nothing about now. Take a fresh one.
Give the site a key that can only push. What sits on a site can be stolen with the box it runs on. A Push only key can send pictures and nothing else: it cannot read incidents, list cameras or change anything.
Which credential goes where
| Where | Credential | What it can do |
|---|---|---|
| Your back end | Full access key | Creates cameras and monitors, reads incidents |
| A service on site | Push only key | Sends pictures, nothing else |
| A camera or a VMS rule | Upload URL | Sends pictures to one camera |
| A recorder | FTP login | Sends pictures to the channels of one recorder |
| Code that runs direct checks | Run only key | Runs checks, nothing else |
In VMS words
For a team that thinks in VMS terms, the mapping is short: a VMS camera is a push camera, an analytic on a camera is a monitor, an alarm is an incident, the alarm notification is a webhook event, and the alarm snapshot is the evidence picture. One thing has no equivalent: there is nothing to call to acknowledge or close an incident. It closes by itself when the scene clears. Acknowledge it in the VMS, where the operator already works. How an incident opens and closes is described in from checks to incidents.
When the feed goes silent
Camly has no connection to your gateway, only the pictures it sends. A pushed camera is marked offline, with a camera.offline event, after three times its monitor’s longest interval without a picture. Set max_interval_seconds to what your sender really does, or a healthy camera will look silent.
Whether your cameras can be read at all, and over which protocol, is a separate question that we covered for the Bridge in are your cameras compatible?.
Sources
- Camly API, all guides as plain text: From a VMS, without a Bridge; Connect your own gateway; Bridges. platform.camly.ai
- Camly API contract (OpenAPI). api.camly.ai