1. 透過 ID 查詢 Query by ID
網頁版 HTML version:
GET https://cbdb.fas.harvard.edu/cbdbapi/person?id=21246
JSON 版 JSON version:
GET https://cbdb.fas.harvard.edu/cbdbapi/person?id=21246&mode=json
HTML
JSON
2. 透過姓名查詢 Query by Name
網頁版 HTML version:
GET https://cbdb.fas.harvard.edu/cbdbapi/person?name=蘇軾
JSON 版 JSON version:
GET https://cbdb.fas.harvard.edu/cbdbapi/person?name=蘇軾&mode=json
HTML
JSON
注意 Note:
• 網頁版輸出:找到多個匹配結果時,會顯示最多 50 個候選人列表供您選擇
• JSON 版輸出:使用 ?name= 查詢時僅返回第一個匹配結果
• HTML output: When multiple matches are found, displays up to 50 candidates for selection
• JSON output: When using ?name= query, only returns the first matching result
3. cURL 範例 cURL Example
curl -X GET "https://cbdb.fas.harvard.edu/cbdbapi/person?id=21246&mode=json" \
-H "Accept: application/json"
4. Python 範例 Python Example
import requests
# 查詢蘇軾的資料
response = requests.get(
'https://cbdb.fas.harvard.edu/cbdbapi/person',
params={'id': 21246, 'mode': 'json'}
)
if response.status_code == 200:
data = response.json()
person = data['Package']['PersonAuthority']['PersonInfo']['Person']
print(f"姓名: {person['BasicInfo']['ChName']}")
print(f"ID: {person['BasicInfo']['PersonId']}")
else:
print(f"錯誤: {response.status_code}")
5. JavaScript 範例 JavaScript Example
// 使用 Fetch API 查詢
fetch('https://cbdb.fas.harvard.edu/cbdbapi/person?id=21246&mode=json')
.then(response => response.json())
.then(data => {
const person = data.Package.PersonAuthority.PersonInfo.Person;
console.log('姓名:', person.BasicInfo.ChName);
console.log('ID:', person.BasicInfo.PersonId);
})
.catch(error => console.error('錯誤:', error));