浏览开发者文档

REST API

可用权限范围:uploads:write、files:read、shares:write 和 shares:read。

仅创建所需的最小权限密钥。轮换时先创建并部署新密钥,再撤销旧密钥。付费资格结束后密钥会保留但调用暂停;重新购买符合条件的套餐即可恢复。

上传和共享文件

每个请求都需要使用以下凭据进行身份验证: Authorization: Bearer <YOUR_API_KEY>. 在开发者控制台中创建带权限范围的密钥,并在显示时立即保存。Pro、Business 和 $399 Lifetime 均包含 API 访问权限。

上传流程

创建预签名上传,传输原始文件,完成它,然后读取其状态。

  1. POST /api/v1/uploadsfilename, mimeType, sizeBytes
  2. PUT使用返回的内容类型,将原始文件上传到上传前生成的预签名 URL。content-type
  3. POST /api/v1/uploads/{uploadId}/complete.
  4. GET /api/v1/uploads/{uploadId}
curl
curl -X POST https://video2url.com/api/v1/uploads \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"filename":"demo.mp4","mimeType":"video/mp4","sizeBytes":1048576}'
curl -X PUT "$UPLOAD_URL" -H "Content-Type: video/mp4" --data-binary @demo.mp4
curl -X POST https://video2url.com/api/v1/uploads/$UPLOAD_ID/complete -H "Authorization: Bearer <YOUR_API_KEY>"
curl -X POST https://video2url.com/api/v1/shares -H "Authorization: Bearer <YOUR_API_KEY>" -H "Content-Type: application/json" -d '{"fileId":"<FILE_ID>"}'
JavaScript
const response = await fetch('https://video2url.com/api/v1/uploads', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <YOUR_API_KEY>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ filename: 'demo.mp4', mimeType: 'video/mp4', sizeBytes: 1048576 }),
});
const created = await response.json();
await fetch(created.data.upload.url, { method: 'PUT', headers: created.data.upload.headers, body: file });
const completed = await fetch('https://video2url.com/api/v1/uploads/' + created.data.uploadId + '/complete', { method: 'POST', headers: { Authorization: 'Bearer <YOUR_API_KEY>' } }).then(r => r.json());
await fetch('https://video2url.com/api/v1/shares', { method: 'POST', headers: { Authorization: 'Bearer <YOUR_API_KEY>', 'Content-Type': 'application/json' }, body: JSON.stringify({ fileId: completed.data.file.fileId }) });
Python
import requests

created = requests.post(
    "https://video2url.com/api/v1/uploads",
    headers={"Authorization": "Bearer <YOUR_API_KEY>"},
    json={"filename": "demo.mp4", "mimeType": "video/mp4", "sizeBytes": 1048576},
).json()
with open("demo.mp4", "rb") as video:
    requests.put(created["data"]["upload"]["url"], headers=created["data"]["upload"]["headers"], data=video).raise_for_status()
completed = requests.post("https://video2url.com/api/v1/uploads/" + created["data"]["uploadId"] + "/complete", headers={"Authorization": "Bearer <YOUR_API_KEY>"}).json()
requests.post("https://video2url.com/api/v1/shares", headers={"Authorization": "Bearer <YOUR_API_KEY>"}, json={"fileId": completed["data"]["file"]["fileId"]}).raise_for_status()

分享链接

创建、检查或撤销经过身份验证的用户拥有的链接。

  • 标题是可选的。
  • 密码是可选的。
  • 可见性是可选的。
  • 可见性默认为“不公开列出”:可通过链接访问,但不会出现在公开列表中。
  • POST /api/v1/sharesfileId, title, visibility, password
  • GET /api/v1/shares/{shareId}
  • DELETE /api/v1/shares/{shareId}

密码可见性需要 8–128 个字符。支持的可见性值是 public, unlisted, password.