回應格式
JSON 回應包含 code(整數,與 HTTP 狀態碼一致)、msg(字串)及 data(成功結果)。失敗時回傳 4xx 或 5xx,data 為 null,msg 說明原因。編碼轉換與中文處理介面皆以表單提交。
{"code":400,"msg":"请输入二维码内容","data":null}
編碼轉換
HEX
POST/api/hex/encode文字 → 十六進位
POST/api/hex/decode十六進位 → 文字
請求參數
| 轉換方向 | 參數 | 必填 | 類型 | 說明 |
| 文字 → 十六進位 | str | 否 | string | 要編碼的文字,省略或留空時輸出空字串。 |
| 十六進位 → 文字 | hex | 是 | string | 十六進位位元組,每個位元組兩位。可含空格、定位字元或換行,移除後必須非空。 |
成功回應
| 轉換方向 | 參數 | 類型 | 說明 |
| 文字 → 十六進位 | data.str | string | 請求中的原始文字。 |
| 文字 → 十六進位 | data.hex | string | 將原文的 UTF-8 位元組編碼為小寫十六進位字串。 |
| 十六進位 → 文字 | data.str | string | 將十六進位位元組解碼後的文字。 |
| 十六進位 → 文字 | data.hex | string | 輸入的十六進位字串,已移除空格、定位字元與換行。 |
呼叫範例
curl -X POST 'https://zxso.net/api/hex/encode' --data-urlencode 'str=AB'
{"code":200,"msg":"success","data":{"str":"AB","hex":"4142"}}
curl -X POST 'https://zxso.net/api/hex/decode' --data-urlencode 'hex=4142'
{"code":200,"msg":"success","data":{"str":"AB","hex":"4142"}}
Unicode
POST/api/unicode/encode中文 → Unicode
POST/api/unicode/decodeUnicode → 中文
請求參數
| 轉換方向 | 參數 | 必填 | 類型 | 說明 |
| 中文 → Unicode | text | 是 | string | 待跳脫文字。僅轉換 U+4E01 至 U+9FA4 範圍內的字元,其餘字元保留原樣。 |
| Unicode → 中文 | text | 是 | string | 含反斜線、u 與四位十六進位數字的文字,例如 \u98ce。 |
成功回應
| 轉換方向 | 參數 | 類型 | 說明 |
| 中文 → Unicode | data.text | string | 跳脫後的文字,例如「風」變為 \u98a8。 |
| Unicode → 中文 | data.text | string | 將 Unicode 跳脫序列還原後的文字。 |
呼叫範例
curl -X POST 'https://zxso.net/api/unicode/encode' --data-urlencode 'text=风'
{"code":200,"msg":"success","data":{"text":"\\u98ce"}}
curl -X POST 'https://zxso.net/api/unicode/decode' --data-urlencode 'text=\u98ce'
{"code":200,"msg":"success","data":{"text":"风"}}
Punycode
POST/api/punycode/encode網域 → Punycode
POST/api/punycode/decodePunycode → 網域
請求參數
| 轉換方向 | 參數 | 必填 | 類型 | 說明 |
| 網域 → Punycode | domain | 是 | string | 待編碼的網域,例如 例子.cn。 |
| Punycode → 網域 | domain | 是 | string | 待解碼的 ASCII 網域,例如 xn--fsqu00a.cn。 |
成功回應
| 轉換方向 | 參數 | 類型 | 說明 |
| 網域 → Punycode | data.domain | string | 編碼後的 ASCII 網域,例如 xn--fsqu00a.cn。 |
| Punycode → 網域 | data.domain | string | 解碼後的 Unicode 網域,例如 例子.cn。 |
呼叫範例
curl -X POST 'https://zxso.net/api/punycode/encode' --data-urlencode 'domain=例子.cn'
{"code":200,"msg":"success","data":{"domain":"xn--fsqu00a.cn"}}
curl -X POST 'https://zxso.net/api/punycode/decode' --data-urlencode 'domain=xn--fsqu00a.cn'
{"code":200,"msg":"success","data":{"domain":"例子.cn"}}
中文處理
漢字 → 拼音
POST/api/pinyin
請求參數
| 參數 | 必填 | 類型 | 說明 |
text | 是 | string | 要轉換的內容,每次最多 20000 字 |
mode | 否 | string | tone 帶聲調(預設),plain 不帶聲調,first 僅首字母。 |
sep | 否 | string | space 以空格分隔音節(預設),none 連寫。 |
成功回應
| 參數 | 類型 | 說明 |
data.text | string | 依 mode 與 sep 產生的拼音文字。 |
data.count | integer | 已轉換的漢字音節數。英文、數字與標點不列入。 |
呼叫範例
curl -X POST 'https://zxso.net/api/pinyin' --data-urlencode 'text=你好' --data-urlencode 'mode=tone' --data-urlencode 'sep=space'
{"code":200,"msg":"success","data":{"text":"nǐ hǎo","count":2}}
簡 ⇄ 繁
POST/api/zhconvert
請求參數
| 參數 | 必填 | 類型 | 說明 |
text | 是 | string | 要轉換的內容,每次最多 20000 字 |
direction | 否 | string | s2t 簡體轉繁體(預設),t2s 繁體轉簡體。 |
成功回應
| 參數 | 類型 | 說明 |
data.text | string | 依 direction 轉換後的文字。 |
呼叫範例
curl -X POST 'https://zxso.net/api/zhconvert' --data-urlencode 'text=汉字' --data-urlencode 'direction=s2t'
{"code":200,"msg":"success","data":{"text":"漢字"}}
曆法
農曆與公曆換算
POST/api/chinesecalendar
請求參數
| 參數 | 必填 | 類型 | 說明 |
type | 否 | solar/lunar | 輸入日期的曆法。solar(預設)將公曆轉為農曆,lunar 將農曆轉為公曆。 |
year | 是 | integer | 輸入年份,1900 至 2100(含)。 |
month | 是 | integer | 月份,1 至 12。閏月也使用相同月號。 |
day | 是 | integer | 該月的有效日期。公曆最多 31 天,農曆為 29 或 30 天。 |
leap | 否 | 0/1 | 僅適用於農曆輸入。一般月份填 0(預設),閏月填 1。 |
成功回應
| 參數 | 類型 | 說明 |
data.solar | string | 公曆日期,格式為 YYYY-MM-DD。 |
data.lunar | string | 中文農曆日期,包含年、月、日。 |
data.ganzhi | string | 農曆年的天干地支,例如甲辰。 |
data.animal | string | 農曆年的生肖,以簡體中文傳回。 |
data.term | string | 當日節氣的中文名稱。沒有節氣時傳回「无」。 |
呼叫範例
curl -X POST 'https://zxso.net/api/chinesecalendar' -d 'type=solar&year=2024&month=2&day=10'
{"code":200,"msg":"success","data":{"solar":"2024-02-10","lunar":"二〇二四年正月初一","ganzhi":"甲辰","animal":"龙","term":"无"}}
curl -X POST 'https://zxso.net/api/chinesecalendar' -d 'type=lunar&year=2023&month=2&day=1&leap=1'
{"code":200,"msg":"success","data":{"solar":"2023-03-22","lunar":"二〇二三年闰二月初一","ganzhi":"癸卯","animal":"兔","term":"无"}}