跳到主要内容

菜单

  • 媒体
  • 定价
  • 文档
  • 语言:简体中文

    此页面不提供灰色显示的语言版本。

    • English
    • Español
    • Português
    • Français
    • Deutsch
    • Italiano
    • Nederlands
    • Polski
    • 日本語
    • 한국어
    • Bahasa Indonesia
    • Tiếng Việt
    • Türkçe
    • العربية
    • ไทย
    • Български
    • Català
    • Hrvatski
    • Eesti
    • Magyar
    • Latviešu
    • Lietuvių
    • Srpski
    • Slovenčina
    • Slovenščina
    • Українська
    • Čeština
    • Română
    • Svenska
    • Dansk
    • Norsk bokmål
    • Suomi
    • עברית
    • हिन्दी
    • Tagalog
    • Bahasa Melayu
    • Ελληνικά
    • 简体中文
    • 繁體中文

热门工具

操作

API 可以对文件做哪些处理,以及每个操作接受的设置。两个端点都无需 API 密钥。

本页内容

列出操作

GET/v1/operations无需 API 密钥

列出所有操作,不含设置 Schema。无需密钥,且对所有人都相同。

查询参数

  • categorystring

    仅返回该类别的操作,例如 video。

    最多 64 个字符

  • qstring

    仅返回 ID、名称或描述中包含这些词语的操作。

    最多 200 个字符

返回

  • 200操作列表。
12 个字段
  • operationsobject[]必填
  • operations[].idstring必填

    操作的 ID,例如 video.compress。

  • operations[].categorystring必填
  • operations[].namestring必填
  • operations[].descriptionstring必填
  • operations[].groupingstring必填

    separate:每个输入文件一个任务。together:所有输入文件共用一个任务。

    可选值:separate或together

  • operations[].outputstring必填

    每个任务的产出类型,例如 file。

  • operations[].max_filesinteger必填

    单个作业最多接受的输入文件数。

    最小值:1

  • operations[].input_formatsstring[]必填

    接受的文件扩展名。

  • operations[].limitsobject必填
  • operations[].limits.max_file_bytesinteger必填

    输入文件的最大大小,以字节为单位。

  • operations[].settings_schemaobject

    settings 所遵循的 JSON Schema。仅在 GET /v1/operations/{id} 中返回。

示例

curl https://api.filesokay.com/v1/operations
const res = await fetch("https://api.filesokay.com/v1/operations");
const list = await res.json();
import requests

res = requests.get(
    "https://api.filesokay.com/v1/operations",
)
list = res.json()
响应
{
  "operations": [
    {
      "id": "video.compress",
      "category": "video",
      "name": "Video Compressor",
      "description": "Makes videos smaller. Choose a quality level, or a target size in MB or as a percentage of each file's size.",
      "grouping": "separate",
      "output": "file",
      "max_files": 50,
      "input_formats": [
        "mp4",
        "m4v",
        "mpg4",
        "mpeg4",
        "f4v",
        "mov",
        "qt",
        "3gp",
        "…"
      ],
      "limits": {
        "max_file_bytes": 53687091200
      }
    }
  ]
}

获取操作

GET/v1/operations/{id}无需 API 密钥

返回单个操作,以及其 settings 所遵循的 JSON Schema。无需密钥。

路径参数

  • idstring必填

    操作的 ID,例如 video.compress。

返回

  • 200该操作。
11 个字段
  • idstring必填

    操作的 ID,例如 video.compress。

  • categorystring必填
  • namestring必填
  • descriptionstring必填
  • groupingstring必填

    separate:每个输入文件一个任务。together:所有输入文件共用一个任务。

    可选值:separate或together

  • outputstring必填

    每个任务的产出类型,例如 file。

  • max_filesinteger必填

    单个作业最多接受的输入文件数。

    最小值:1

  • input_formatsstring[]必填

    接受的文件扩展名。

  • limitsobject必填
  • limits.max_file_bytesinteger必填

    输入文件的最大大小,以字节为单位。

  • settings_schemaobject必填

    settings 所遵循的 JSON Schema。仅在 GET /v1/operations/{id} 中返回。

错误

示例

curl https://api.filesokay.com/v1/operations/video.compress
const res = await fetch("https://api.filesokay.com/v1/operations/video.compress");
const operation = await res.json();
import requests

res = requests.get(
    "https://api.filesokay.com/v1/operations/video.compress",
)
operation = res.json()
响应
{
  "id": "video.compress",
  "category": "video",
  "name": "Video Compressor",
  "description": "Makes videos smaller. Choose a quality level, or a target size in MB or as a percentage of each file's size.",
  "grouping": "separate",
  "output": "file",
  "max_files": 50,
  "input_formats": [
    "mp4",
    "m4v",
    "mpg4",
    "mpeg4",
    "f4v",
    "mov",
    "qt",
    "3gp",
    "…"
  ],
  "limits": {
    "max_file_bytes": 53687091200
  },
  "settings_schema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "title": "Video Compressor settings",
    "description": "Video Compressor's settings. A setting left out takes its default, and a job shows every setting with its default filled in. One set of settings covers every file in a job.",
    "type": "object",
    "additionalProperties": false,
    "properties": {
      "method": {
        "description": "quality: choose a level, and each file's size follows from its video. target_size: choose the size to reach.",
        "enum": [
          "quality",
          "target_size"
        ],
        "default": "quality"
      },
      "level": {
        "description": "With the quality method only: smaller for a smaller file, balanced, or higher for higher quality.",
        "enum": [
          "smaller",
          "balanced",
          "higher"
        ],
        "default": "balanced"
      },
      "target": {
        "description": "With the target_size method only: the size to reach, for each file. In MB, where 1 MB is 1,000,000 bytes, from 0.1 up to the file's own size; or as a percentage of the file's own size, from 1 to 99.",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "unit",
          "value"
        ],
        "properties": {
          "unit": {
            "enum": [
              "mb",
              "percent"
            ]
          },
          "value": {
            "type": "number"
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "unit": {
                  "const": "mb"
                }
              }
            },
            "then": {
              "properties": {
                "value": {
                  "minimum": 0.1
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "unit": {
                  "const": "percent"
                }
              }
            },
            "then": {
              "properties": {
                "value": {
                  "minimum": 1,
                  "maximum": 99
                }
              }
            }
          }
        ],
        "default": {
          "unit": "percent",
          "value": 60
        }
      },
      "resolution": {
        "description": "original keeps each video's size. auto, allowed only with the target_size method and its default there, lowers the size when that helps reach the target. A height lowers the video's shorter side to it, keeping the aspect ratio; a video already at or below it keeps its own size. original is the default with the quality method.",
        "enum": [
          "original",
          "auto",
          "2160",
          "1440",
          "1080",
          "720",
          "480",
          "360",
          "240"
        ]
      },
      "codec": {
        "description": "same keeps each video's codec when its output format can hold it, and otherwise uses that format's usual codec. A chosen codec the output format can't hold falls back to the same rule.",
        "enum": [
          "same",
          "h264",
          "hevc",
          "av1",
          "vp9",
          "mpeg4"
        ],
        "default": "same"
      },
      "frame_rate": {
        "description": "original keeps each video's frame rate. A number lowers it to that rate; a video already at or below it keeps its own.",
        "enum": [
          "original",
          "60",
          "30",
          "24"
        ],
        "default": "original"
      },
      "audio": {
        "description": "keep keeps the sound; remove takes it out.",
        "enum": [
          "keep",
          "remove"
        ],
        "default": "keep"
      },
      "output_format": {
        "description": "same keeps each file's own format, or gives MP4 where that format can't be written.",
        "enum": [
          "same",
          "mp4",
          "mov",
          "mkv",
          "webm"
        ],
        "default": "same"
      }
    },
    "allOf": [
      {
        "if": {
          "required": [
            "method"
          ],
          "properties": {
            "method": {
              "const": "target_size"
            }
          }
        },
        "then": {
          "not": {
            "required": [
              "level"
            ]
          }
        },
        "else": {
          "not": {
            "anyOf": [
              {
                "required": [
                  "target"
                ]
              },
              {
                "required": [
                  "resolution"
                ],
                "properties": {
                  "resolution": {
                    "const": "auto"
                  }
                }
              }
            ]
          }
        }
      }
    ]
  }
}