Skip to content

Instantly share code, notes, and snippets.

@tonytonyjan
Last active March 25, 2025 04:33
Show Gist options
  • Save tonytonyjan/fe0848997a038ca84081d4664a1f519f to your computer and use it in GitHub Desktop.
Save tonytonyjan/fe0848997a038ca84081d4664a1f519f to your computer and use it in GitHub Desktop.
中華郵政包裹查詢 API
#!/bin/sh
test $# != 1 && cat <<USAGE && exit 1
Usage: $0 MAIL_ID
== Output Example ==
[
{
"datime": "20190520195647",
"status": "運輸途中           ",
"station": "台北中心掛號函件股 "
},
{
"datime": "20190520172500",
"status": "交寄郵件           ",
"station": "臺北螢橋郵局    "
}
]
USAGE
jq -n -c --arg mailNO "$1" '{
header: {
InputVOClass: "com.systex.jbranch.app.server.post.vo.EB500100InputVO",
TxnCode: "EB500100",
BizCode: "query2",
StampTime: true,
SupvPwd: "",
TXN_DATA: {},
SupvID: "",
CustID: "",
REQUEST_ID: "",
ClientTransaction: true,
DevMode: false,
SectionID: "esoaf"
},
body: { MAILNO: $mailNO, pageCount: 10 }
}' |
curl -sSL 'https://postserv.post.gov.tw/pstmail/EsoafDispatcher' --data @- |
jq '.[0].body.host_rs.ITEM | map({datetime: .DATIME, status: .STATUS, station: .BRHNC})'
@tzuChueh
Copy link

非常感謝大大的方法! 非常有用
另外想問不知道有沒有API能夠建立i郵箱託運單

@tonytonyjan
Copy link
Author

@tzuChueh
抱歉你說的建立i郵箱託運單 API 我並沒有研究

另外感謝使用,我沒想到 2019 的腳本到今天還可以運作哈哈

@TimChiang0106
Copy link

非常感謝大大,就算2024年也是可以運作。

@jackey0117
Copy link

jackey0117 commented Dec 9, 2024

@tonytonyjan tonytonyjan不好意思,請問這個指令要怎麼使用呢? 要安裝什麼套件嗎? 謝謝

@TimChiang0106
Copy link

TimChiang0106 commented Dec 10, 2024

@josephmisiti 這是 shell script,不用安裝套件,你直接複製貼上到 .sh 檔案內後執行就可以了

Screenshot 2024-12-10 at 10 17 21 AM

@laetitiahuang530
Copy link

中華郵政「國際及大陸各類郵件查詢」API你有研究嗎?如果有,能不能也分享一下程式碼?

@tonytonyjan
Copy link
Author

中華郵政「國際及大陸各類郵件查詢」API你有研究嗎?如果有,能不能也分享一下程式碼?

@laetitiahuang530 沒有喔,我當時只有研究我自己需要用到的部分,並沒有涵蓋到所有中華郵政的 API。

@tonytonyjan
Copy link
Author

非常感謝大大,就算2024年也是可以運作。

感謝,能棒上忙真是太好了 🥰

希望 2025 一樣能繼續運作 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment