AIOZ Stream Operations
Interact with AIOZ Stream API quickly with API key authentication. A suite of integrated bash scripts is provided to automatically call REST APIs.
When to use this skill
- - User wants to upload or create a video on AIOZ Stream
- User mentions "upload video", "create video", "aioz stream video"
- User wants to query analytics, livestream keys, or account balances
- User wants to get an HLS/MP4 streaming link for their video
- User wants to search/list media or find a video by name
Authentication
This skill uses API key authentication via environment variables:
- -
STREAM_PUBLIC_KEY: Your AIOZ Stream public key (provided by the platform) - INLINECODE1 : Your AIOZ Stream secret key (provided by the platform)
Credential-safe policy:
- - Prefer credentials from secure environment injection.
- If missing, ask the user for credentials and set them as temporary environment variables.
- Never hardcode keys in command examples, logs, or responses.
- Avoid inline one-off commands that contain raw secrets.
If credentials are not present in the shell session, set them once before running scripts:
CODEBLOCK0
Header mapping used by scripts:
- -
STREAM_PUBLIC_KEY -> stream-public-key header - INLINECODE4 ->
stream-secret-key header
This keeps credentials out of repeated command history and avoids accidental exposure.
Usage Options (Available Scripts)
When the user asks for a feature, use one of the bash scripts located in the scripts/ directory.
Script Routing Map (for Clawbot)
- - Upload local file to video: INLINECODE7
- Get media list (GET with optional query params): INLINECODE8
- Get media list via POST body (search/page): INLINECODE9
- Get all media via POST
{}: INLINECODE11 - Search media by name via POST body: INLINECODE12
- Create livestream key: INLINECODE13
- Get account/user info and balance: INLINECODE14
- Get usage data (fixed interval=hour): INLINECODE15
- Get aggregate analytics (watchtime + viewcount): INLINECODE16
- Get breakdown analytics (device/os/country/browser): INLINECODE17
- Combined aggregate + breakdown report: INLINECODE18
1. Upload Video (Credential-Safe Default Flow)
Use this script to automatically create a video object, upload the file, and complete the flow:
CODEBLOCK1
Actual behavior in script:
- - Accepts local file path only.
- Validates video by extension (and by MIME where possible).
- File must exist on the local system.
2. Analytics & Usage
To get metrics or account usage:
- - Usage Data: INLINECODE19
- Calls
GET /analytics/data?from=...&to=...&interval=hour
-
FROM/
TO must be
dd/mm/yyyy format (scripts convert to Unix timestamp)
- - Aggregate Metrics: INLINECODE24
- Returns: Watch time sum + View count for selected media type
-
TYPE must be
video or
audio
- - Breakdown Metrics: INLINECODE28
- Returns: Device type, Operating system, Country, Browser breakdowns (with total count and data array)
-
TYPE must be
video or
audio
- - All-in-one Analytics: INLINECODE32
- Returns: Combined aggregate metrics + all breakdown metrics in one call
-
TYPE must be
video or INLINECODE35
Date format notes:
- -
FROM and TO must be dd/mm/yyyy (scripts convert to Unix timestamp internally)
3. Media & Livestream Management
To search existing media, get balance, or create keys:
- - List Media: INLINECODE39
- Total Media: INLINECODE40
- Video List: INLINECODE41
- Search Video URL: INLINECODE42
- Livestream Key: INLINECODE43
- Balance: INLINECODE44
Notes:
- -
get_video_list.sh currently returns all media (POST /media with empty body), not strictly video-only filtering. - INLINECODE47 currently returns search results JSON; it does not extract one URL field automatically.
Full Upload Flow (Common Operational Path)
For a typical upload lifecycle, use this sequence:
- 1. Create media object
- Upload media part
- Complete upload
- Fetch media detail
- Print status and URLs (
hls_player_url, hls_url, mp4_url)
If using manual curl, the core upload flow is the first 3 steps below.
Step 1: Create Video Object
CODEBLOCK2
Response: extract data.id as VIDEO_ID for the next steps.
Step 2: Upload File Part
Upload the actual video file binary to the created video object.
First, get the file size and compute the MD5 hash:
CODEBLOCK3
Then upload via multipart form-data with the Content-Range header:
CODEBLOCK4
Important: The Content-Range header is required for the upload to succeed. Format: bytes {start}-{end}/{total_size}.
Form-data fields:
- -
file: the video file binary (use @/path/to/video.mp4) - INLINECODE58 : 0 (for single-part upload)
- INLINECODE59 : MD5 hash of the file part
Step 3: Complete Upload
After the file part is uploaded, call the complete endpoint to finalize:
CODEBLOCK5
This triggers transcoding. The upload is now considered successful.
After Upload — Get Video Link
After completing the upload, fetch the video detail to get the streaming URL:
CODEBLOCK6
Parse the response to find the HLS or MP4 URL from the assets field and return it to the user.
Custom Upload Config Reference
(Applicable if implementing custom logic via API directly)
Quality Presets (resolution field):
- -
standard — Standard quality - INLINECODE63 — Good quality
- INLINECODE64 — Highest quality
- INLINECODE65 — Lossless quality
Streaming Formats (type field):
- -
hls — HTTP Live Streaming (container: mpegts or mp4) - INLINECODE70 — Dynamic Adaptive Streaming (container:
fmp4)
Response Handling
- 1. Run the appropriate script from the
scripts/ directory. - Media/Search scripts return raw JSON:
get_video_list, get_video_url_by_name, get_total_media, INLINECODE76 - Metrics scripts return structured output:
-
get_aggregate_metric.sh: Two labeled outputs (Watch Time Sum, View Count)
-
get_breakdown_metric.sh: Four labeled JSON blocks (=== device
type ===, === operatorsystem ===, === country ===, === browser ===)
-
analytic_data.sh: Combined aggregate + breakdown output
-
get_usage_data.sh: Raw JSON response with pretty-printed format
- 4. Upload/Management scripts:
upload_video_file.sh prints step-by-step status with final URLs - Return useful fields explicitly (IDs, status, URLs, totals). If upload status is
transcoding or URLs are empty, inform the user to check again later.
Error Handling
- - 401: Invalid API keys. Ask user to verify
STREAM_PUBLIC_KEY and STREAM_SECRET_KEY. - Missing Parameters: Scripts validate arguments; pass exactly what they require.
- 404: Resource not found (invalid media ID or livestream ID).
- 500: Server error; suggest retrying.
- Connection timeout/refused: API endpoint may be unavailable; retry and verify
https://api.aiozstream.network/api/ accessibility.
Example Interaction Flow
- 1. User: "Upload my video to AIOZ Stream"
- Ensure
STREAM_PUBLIC_KEY and STREAM_SECRET_KEY exist in environment (ask user only if missing) - Ask for the video file path and title
- Execute: INLINECODE88
- Extract the outputted HLS/MP4 link
- Return the video link to the user
AIOZ 流媒体操作
通过 API 密钥认证快速与 AIOZ Stream API 进行交互。提供了一套集成的 bash 脚本,用于自动调用 REST API。
何时使用此技能
- - 用户想要在 AIOZ Stream 上上传或创建视频
- 用户提及上传视频、创建视频、aioz stream video
- 用户想要查询分析数据、直播密钥或账户余额
- 用户想要获取其视频的 HLS/MP4 流媒体链接
- 用户想要搜索/列出媒体或按名称查找视频
认证方式
此技能通过环境变量使用 API 密钥认证:
- - STREAMPUBLICKEY:您的 AIOZ Stream 公钥(由平台提供)
- STREAMSECRETKEY:您的 AIOZ Stream 密钥(由平台提供)
凭据安全策略:
- - 优先从安全环境注入获取凭据。
- 如果缺失,向用户询问凭据并将其设置为临时环境变量。
- 切勿在命令示例、日志或响应中硬编码密钥。
- 避免包含原始密钥的内联一次性命令。
如果 shell 会话中不存在凭据,请在运行脚本前设置一次:
bash
export STREAMPUBLICKEY=YOURSTREAMPUBLIC_KEY
export STREAMSECRETKEY=YOURSTREAMSECRET_KEY
脚本使用的标头映射:
- - STREAMPUBLICKEY -> stream-public-key 标头
- STREAMSECRETKEY -> stream-secret-key 标头
这样可以将凭据排除在重复的命令历史之外,避免意外泄露。
使用选项(可用脚本)
当用户请求某项功能时,使用 scripts/ 目录中的某个 bash 脚本。
脚本路由映射(适用于 Clawbot)
- - 上传本地文件到视频:./scripts/uploadvideofile.sh FILEPATH TITLE
- 获取媒体列表(GET,带可选查询参数):./scripts/getmedialist.sh [SEARCH] [PAGE]
- 通过 POST 请求体获取媒体列表(搜索/分页):./scripts/gettotalmedia.sh [SEARCH] [PAGE]
- 通过 POST {} 获取所有媒体:./scripts/getvideolist.sh
- 通过 POST 请求体按名称搜索媒体:./scripts/getvideourlbyname.sh VIDEONAME
- 创建直播密钥:./scripts/createlivestreamkey.sh KEYNAME
- 获取账户/用户信息和余额:./scripts/getbalance.sh
- 获取使用数据(固定间隔=小时):./scripts/getusagedata.sh FROM(dd/mm/yyyy) TO(dd/mm/yyyy)
- 获取聚合分析数据(观看时长 + 观看次数):./scripts/getaggregatemetric.sh TYPE FROM(dd/mm/yyyy) TO(dd/mm/yyyy)
- 获取细分分析数据(设备/操作系统/国家/浏览器):./scripts/getbreakdownmetric.sh TYPE FROM(dd/mm/yyyy) TO(dd/mm/yyyy)
- 组合聚合 + 细分报告:./scripts/analytic_data.sh TYPE FROM(dd/mm/yyyy) TO(dd/mm/yyyy)
1. 上传视频(凭据安全的默认流程)
使用此脚本自动创建视频对象、上传文件并完成流程:
bash
./scripts/uploadvideofile.sh /path/to/video.mp4 Video Title
脚本中的实际行为:
- - 仅接受本地文件路径。
- 通过扩展名(以及可能的 MIME 类型)验证视频。
- 文件必须存在于本地系统。
2. 分析与使用数据
获取指标或账户使用情况:
- - 使用数据: ./scripts/getusagedata.sh FROM(dd/mm/yyyy) TO(dd/mm/yyyy)
- 调用 GET /analytics/data?from=...&to=...&interval=hour
- FROM/TO 必须为 dd/mm/yyyy 格式(脚本会转换为 Unix 时间戳)
- - 聚合指标: ./scripts/getaggregatemetric.sh TYPE FROM(dd/mm/yyyy) TO(dd/mm/yyyy)
- 返回:所选媒体类型的观看时长总和 + 观看次数
- TYPE 必须为 video 或 audio
- - 细分指标: ./scripts/getbreakdownmetric.sh TYPE FROM(dd/mm/yyyy) TO(dd/mm/yyyy)
- 返回:设备类型、操作系统、国家、浏览器细分(包含总数和数据数组)
- TYPE 必须为 video 或 audio
- - 一体化分析: ./scripts/analytic_data.sh TYPE FROM(dd/mm/yyyy) TO(dd/mm/yyyy)
- 返回:一次调用中组合的聚合指标 + 所有细分指标
- TYPE 必须为 video 或 audio
日期格式说明:
- - FROM 和 TO 必须为 dd/mm/yyyy 格式(脚本内部会转换为 Unix 时间戳)
3. 媒体与直播管理
搜索现有媒体、获取余额或创建密钥:
- - 列出媒体: ./scripts/getmedialist.sh [SEARCH] [PAGE]
- 总媒体数: ./scripts/gettotalmedia.sh [SEARCH] [PAGE]
- 视频列表: ./scripts/getvideolist.sh
- 搜索视频 URL: ./scripts/getvideourlbyname.sh Video Name
- 直播密钥: ./scripts/createlivestreamkey.sh Key Name
- 余额: ./scripts/get_balance.sh
说明:
- - getvideolist.sh 当前返回所有媒体(POST /media,请求体为空),并非严格仅视频过滤。
- getvideourlbyname.sh 当前返回搜索结果 JSON;不会自动提取单个 URL 字段。
完整上传流程(常见操作路径)
对于典型的上传生命周期,请使用以下顺序:
- 1. 创建媒体对象
- 上传媒体部分
- 完成上传
- 获取媒体详情
- 打印状态和 URL(hlsplayerurl、hlsurl、mp4url)
如果使用手动 curl,核心上传流程为以下前 3 个步骤。
步骤 1:创建视频对象
bash
curl -s -X POST https://api.aiozstream.network/api/media/create \
-H stream-public-key: $STREAMPUBLICKEY \
-H stream-secret-key: $STREAMSECRETKEY \
-H Content-Type: application/json \
-d {
title: VIDEO_TITLE,
type: video
}
响应:提取 data.id 作为后续步骤的 VIDEO_ID。
步骤 2:上传文件部分
将实际视频文件二进制数据上传到已创建的视频对象。
首先,获取文件大小并计算 MD5 哈希值:
bash
获取文件大小(跨平台兼容)
FILE_SIZE=$(stat -f%z /path/to/video.mp4 2>/dev/null || stat -c%s /path/to/video.mp4)
END
POS=$((FILESIZE - 1))
计算 MD5 哈希值
HASH=$(md5sum /path/to/video.mp4 | awk {print $1})
然后通过多部分表单数据上传,并附带 Content-Range 标头:
bash
curl -s -X POST https://api.aiozstream.network/api/media/VIDEO_ID/part \
-H stream-public-key: $STREAMPUBLICKEY \
-H stream-secret-key: $STREAMSECRETKEY \
-H Content-Range: bytes 0-$ENDPOS/$FILESIZE \
-F file=@/path/to/video.mp4 \
-F index=0 \
-F hash=$HASH
重要提示: Content-Range 标头是上传成功所必需的。格式:bytes {start}-{end}/{total_size}。
表单数据字段:
- - file:视频文件二进制数据(使用 @/path/to/video.mp4)
- index:0(用于单部分上传)
- hash:文件部分的 MD5 哈希值
步骤 3:完成上传
文件部分上传后,调用完成端点以最终确定:
bash
curl -s -X GET https://api.aiozstream.network/api/media/VIDEO_ID/complete \
-H accept: application/json \
-H stream-public-key: $STREAMPUBLICKEY \
-H stream-secret-key: $STREAMSECRETKEY
这将触发转码。上传现在被视为成功。
上传后 — 获取视频链接
完成上传后,获取视频详情