拆解 URL 与移除追踪参数

POST/url/parse
公开访问curl裸值兼容

按 WHATWG URL 规则解析,保留查询参数的出现顺序和重复键。开启 stripTracking 可移除 utm_*、fbclid、gclid、spm 等参数。 访问类别:匿名 API,可携带 Token 使用独立额度

请求参数

_formatquery
响应格式为 json 或 text;_format=svg 返回 JSON。plain 是 text 的别名。未识别的值继续按 Accept 协商。
string · 可选:json、text
_colorquery
控制 text 响应的 ANSI 颜色。0、false、off、no 关闭;省略或其他值保留。
string · 可选:0、false、off、no

请求体

application/json
url必填
string · 最短:1 字符 · 最长:65536 字符
stripTracking
boolean · 默认值:false

裸值请求体

可直接发送 url 的 JSON 值。需要传入可选字段时,使用 JSON 对象。

响应

application/json

{
  "type": "object",
  "properties": {
    "url": {
      "type": "string"
    },
    "scheme": {
      "type": "string"
    },
    "host": {
      "type": "string"
    },
    "hostname": {
      "type": "string"
    },
    "port": {
      "type": "string"
    },
    "path": {
      "type": "string"
    },
    "hash": {
      "type": "string"
    },
    "origin": {
      "type": "string"
    },
    "query": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "value": {
            "type": "string"
          }
        },
        "required": [
          "name",
          "value"
        ]
      }
    },
    "removed": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "url",
    "scheme",
    "host",
    "hostname",
    "port",
    "path",
    "hash",
    "origin",
    "query",
    "removed"
  ]
}

响应示例

成功响应

curl -sS --json '"https://example.com/path?a=1&a=2&utm_source=feed#section"' https://oit.sh/url/parse
HTTP 200
content-type: application/json
content-encoding: gzip
cache-control: no-store

{
  "url": "https://example.com/path?a=1&a=2&utm_source=feed#section",
  "scheme": "https",
  "host": "example.com",
  "hostname": "example.com",
  "port": "",
  "path": "/path",
  "hash": "section",
  "origin": "https://example.com",
  "query": [
    {
      "name": "a",
      "value": "1"
    },
    {
      "name": "a",
      "value": "2"
    },
    {
      "name": "utm_source",
      "value": "feed"
    }
  ],
  "removed": []
}

错误示例

curl -sS --json '{}' https://oit.sh/url/parse
HTTP 400
content-type: application/json
content-encoding: gzip
cache-control: no-store

{
  "error": {
    "code": "INVALID_INPUT",
    "message": "参数无效",
    "issues": [
      {
        "location": "body",
        "field": "url",
        "code": "invalid_type",
        "message": "需要 字符串 类型"
      }
    ]
  }
}

curl 访问示例

curl、wget、HTTPie 默认得到 text/plain。示例展示纯文本输出。

命令与输出

curl -sS --json '"https://example.com/path?a=1&a=2&utm_source=feed#section"' 'https://oit.sh/url/parse?_color=0&_format=text'
HTTP 200
content-type: text/plain; charset=utf-8
content-encoding: gzip
cache-control: no-store

url: https://example.com/path?a=1&a=2&utm_source=feed#section
scheme: https
host: example.com
hostname: example.com
port: 
path: /path
hash: section
origin: https://example.com
query:
  - 
    name: a
    value: 1
  - 
    name: a
    value: 2
  - 
    name: utm_source
    value: feed
removed: 

在线调试

必填
Ctrl / ⌘ + Enter
curl -X POST 'https://oit.sh/url/parse' \
  -H 'Content-Type: application/json' \
  --data-raw '{"url":"https://example.com/path?a=1&a=2&utm_source=feed#section","stripTracking":true}'

响应

等待请求

等待发送请求