Show / Hide View Count — Frontend Integration
This feature lets a video opt out of having its view count displayed. The backend
exposes a per-video setting, settings.showViews, and accepts it on the create/update
flows. The view count value is still returned — the flag only tells the client
whether to render it.
Summary for the frontend
| Read | settings.showViews (boolean) on the video object |
| Write | showViews (boolean) in the create/update request body |
| Default | true (views shown) — backward compatible for existing videos |
When false |
Hide the views UI; the count is still present in the payload |
1. Reading the flag (display side)
Every video-returning response now includes a settings object:
{
"id": "abc123",
"name": "My video",
"views": 1234,
"metrics": {
"views": 1234,
"likes": 10,
"comments": 3
// ...
},
"settings": {
"showViews": true
}
}
Render the view count only when showViews is true:
const showViews = video.settings?.showViews ?? true;
if (showViews) {
renderViews(video.metrics.views);
}
Always fall back to
true(?? true) whensettingsorshowViewsis missing. Older cached payloads or other edge cases may omit it, and the intended default is "views visible".
Endpoints that return settings.showViews
- Single video:
GET /client/v1/videos/{id},/mobile/...,/tv/... - Video details:
GET /{id}/details(client, mobile, TV) - Listings & search:
/all,/vod,/live,/premium,/search, related, shorts - Studio:
GET /studio/v1/videos/{id}(VOD), studio live video - Admin:
GET /admin/v1/videos/{id}, admin live video
The plain listing grids (
AdminListVideoDto,AdminListLiveVideoDto) do not include view counts, so they do not carrysettings. If you need the flag there, ask the backend to add it.
2. Writing the flag (create / edit side)
showViews is a top-level boolean in the request body (note: it is nested under
settings in responses, but flat in requests).
Create a video — POST /studio/v1/videos
{
"title": "My video",
"description": { /* ... */ },
"type": 0,
"isShort": false,
"isPremium": false,
"showViews": true
}
Update a video — PUT /studio/v1/videos/{id}
{
"name": "My video",
"visibility": 1,
"isPremium": false,
"showViews": false // hide the view count
}
Admin update — PUT /admin/v1/videos/{id}
Same showViews field, alongside the other admin fields (displayScore, etc.).
Send
showViewson every update. The update handlers set the value from the request each time, so omitting it lets the JSON binder fall back to the command default (true). To preserve a previously-disabled state, always include the current value — initialize your form control fromsettings.showViewswhen loading the edit screen.
3. Suggested UI
A simple toggle on the video create/edit form, e.g.:
Show view count
[ ✓ ]When off, viewers won't see how many times this video has been watched.
- Initialize the control from
video.settings.showViews(defaulttrue). - Submit its boolean value as
showViewsin the request body.
Notes / FAQ
- The count is never hidden server-side. When
showViewsisfalse,viewsandmetrics.viewsare still returned with real numbers — only the client decides not to render them. Do not rely on this for privacy of the raw number; it is a display preference, not access control. - Existing videos created before this feature have no stored setting and resolve to
showViews: true. - Extensible:
settingsis a general per-video settings object. Future display toggles (e.g.showLikes,showComments) would be added as additional fields on the same object, so read it defensively (settings?.<field> ?? <default>).