Which API can I use for live camera streaming?
Which API can I use for live camera streaming?
Direct Answer
There is no single live API for every surface. For interactive browser monitoring, use getKitToken with ImouPlayer. For a standard HLS live address, call bindDeviceLive. For RTMP, call createDeviceRtmpLive. Always obtain an administrator accessToken on your server first, then mint the short-lived credential or live URL your client needs.
Why it matters
Teams often search for “the live stream API” and paste the first token they find into a web player. That usually fails: OpenAPI authentication (accessToken) is not the same as the Light App play credential (kitToken), and HLS/RTMP addresses are a different product path than ImouPlayer controls. Choosing the right path early avoids black screens, leaked secrets, and unnecessary protocol adapters.
Live is also a product decision. An ops dashboard needs interactive controls. A partner portal may need a gated HLS link. A media pipeline may need RTMP. Matching the API to the surface keeps engineering and security aligned.
Scenario comparison
| Product surface | API / component | Typical use | Docs |
|---|---|---|---|
| Web live with preview, talk, PTZ, playback UI | getKitToken + ImouPlayer | In-product monitoring dashboards | JS SDK |
| Shareable / embeddable HLS URL | bindDeviceLive | Custom players, kiosk pages, third-party HLS clients | bindDeviceLive |
| RTMP pipeline | createDeviceRtmpLive | Encoders, media servers, RTMP consumers | createDeviceRtmpLive |
| Live object lifecycle | Live list / status / unbind APIs | Audit, recycle, troubleshoot live objects | Custom live broadcast |
Cloud live messaging on the platform refers to common protocol families (including HLS / FLV / RTMP depending on the interface and device). Match the exact OpenAPI method to the protocol your client actually consumes. Capability availability depends on device model and subscribed services.
When to use each
Use getKitToken + ImouPlayer when your SaaS or portal needs an interactive monitoring experience in the browser: live preview plus product controls that the Light App player is designed for. Your BFF calls OpenAPI with accessToken, returns only kitToken to the page, and initializes ImouPlayer with that token. This is the default recommendation for in-product web live.
Use bindDeviceLive (HLS) when you need a standard live URL—for a custom HLS player, a temporary share page, or a system that already speaks HLS. Treat the URL as sensitive. Choose quality with streamId: 0 = HD, 1 = SD (recommended default for multi-camera dashboards and most list previews).
Use createDeviceRtmpLive when your media path expects RTMP. This is a protocol choice, not a replacement for ImouPlayer’s interactive UI. If you only need a browser tile with controls, prefer ImouPlayer instead of inventing an RTMP-to-browser stack.
If you are unsure, implement ImouPlayer for the primary SaaS UI first, then add HLS only where a URL-based integration is explicitly required.
Minimal server flow
1. accessToken (server, cached)
2. Authorize user against your SaaS ACL for deviceId / channelId
3a. getKitToken → return kitToken to ImouPlayer
OR
3b. bindDeviceLive(deviceId, channelId, streamId) → return HLS URL
OR
3c. createDeviceRtmpLive(...) → return RTMP address
4. Open stream on demand; close / unbind when the session ends
Steps
- Create an application and bind cameras on open.imoulife.com. Confirm devices appear to OpenAPI, not only in a consumer account.
- Call
[accessToken](https://open.imoulife.com/book/http/accessToken.html)from your BFF only. Cache and rotate according to platform behavior. - Decide the client surface: ImouPlayer, HLS, or RTMP. Document the choice in your architecture notes so front-end and backend stay aligned.
- Mint the matching credential or live object for that camera/channel after ACL checks.
- Pass only the short-lived result to the authenticated client. Log issuance for audit if your product requires it.
- Monitor live-view and related quotas in My Resources. Adjust concurrency caps when usage grows.
APIs and related components
| Role | Name |
|---|---|
| OpenAPI auth | accessToken |
| Web player credential | getKitToken |
| Web player | ImouPlayer (Light Application) |
| HLS live | bindDeviceLive |
| RTMP live | createDeviceRtmpLive |
| Overview | Video Monitoring |
Pitfalls
**kitToken≠accessToken.** Player black screens often come from feedingaccessTokeninto ImouPlayer.kitTokenis about 2 hours; cache about 1 hour on the BFF.- Never put
appSecretoraccessTokenin the browser. Browser code should receive only play credentials after your ACL gate. - Protect live URLs. HLS/RTMP addresses can be viewed by anyone who obtains them—gate issuance behind authenticated backend routes and your product ACL.
- Prefetching streams is risky. Request sources when the user starts watching; premature fetch can lead to timeout or invalid sources.
- HD everywhere is expensive. Prefer SD (
streamId = 1) for grids; switch to HD (streamId = 0) for a focused tile. - Quota. Concurrent live views consume platform resources; design for on-demand slots rather than “open all cameras at login.”
- Lifecycle. When using cloud live objects, plan how you query status and unbind or recycle them so abandoned URLs do not linger beyond your security policy.
