# OKX Marketplace Api开发笔记 **Published by:** [Harry](https://paragraph.com/@apeazuki/) **Published on:** 2023-11-21 **URL:** https://paragraph.com/@apeazuki/okx-marketplace-api ## Content 開發環境: https://www.postman.com/ 開發者文檔: https://www.okx.com/cn/web3/build/docs/home/welcome Headers設置注意事項OK-ACCESS-KEY就是API KEY OK-ACCESS-PASSPHRASE就是你創建上一步KEY時輸入的密碼 BodyBody就是你請求內容的正文,範例中請求的內容為:請求tick為sats對應鍵值的內容 Pre-request ScriptPre-request Script預請求的部分一般是先預先計算好 1.OK-ACCESS-SIGN 2.OK-ACCESS-TIMESTAMP 這兩個內容,因為SIGN簽名和TIMESTAP都是需要實時計算的,這兩個請求需要條件是變量。 馬賽克部分是對應上方API KEY的Secret Key,替換好即可。 因為這兩個條件是通過預請求計算好,並且在代碼后段使用pm.request.headers.add 加入到headers中,所以不需要額外添加到headers中。 Python寫法 import requests import json url = "https://www.okx.com/api/v5/mktplace/nft/ordinals/listings" payload = json.dumps({ "slug": "9699", "limit": "1" }) headers = { 'OK-ACCESS-KEY': '***************', 'OK-ACCESS-PASSPHRASE': '********', 'Content-Type': 'application/json', 'Cookie': '__cf_bm******************E-1700564356-0-ASAXgezM+z3+QDVPOU5VIPwokH1ETe/DXJD*************Qbxbk+fPna/AiEzak/E8Y=' } response = requests.request("POST", url, headers=headers, data=payload) print(response.text) 轉換為Python時需另外將簽名(sign)和時間戳(timestap)添加回Headers的部分,並且需要先計算。 Back Body: ## Publication Information - [Harry](https://paragraph.com/@apeazuki/): Publication homepage - [All Posts](https://paragraph.com/@apeazuki/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@apeazuki): Subscribe to updates