跳至主要内容

數據導出

HTTP 請求

POST /fht/compliance/tax/v3/private/url

請求參數

參數是否必需類型說明
queryIdtruestring報告請求 ID

響應參數

參數類型說明
urlstring文件的URL網址 (Basepath+Files)。為了縮短生成報告所需的時間,它可以生成多個文件。請注意這一點,並在請求數據導出時使用相同的基本路徑組合多個文件
信息

使用python將S3文件轉換為 CSV的示例

Python腳本


import pandas as pd
import os

class Bases(object):
@staticmethod
def path_list(path):
"""
:param path:
:return: list of file paths
"""
file_list = []
if os.path.isdir(path):
print("it's a directory")
for root, dirs, files in os.walk(path):
for f in files:
file = os.path.join(root, f)
file_list.append(file)
return file_list
elif os.path.isfile(path):
print("it's a normal file")
return [path]

class pd_service(Bases):
def get_data(self, file_path):
"""
Read s3 files, merge forms
:param file_path:
:return:
"""
df_all = pd.DataFrame()
for paths in self.path_list(path=file_path):
df_all = pd.concat([df_all, pd.read_orc(paths)], axis=0)
print('Row number of tables:', df_all[df_all.columns[1]].count())
print(df_all.columns.values)
df_all.sort_values("TradeTime", inplace=True)
df_all.to_csv("test_data_s3.csv", header=True, index=False)
print(df_all)
return df_all

if __name__ == '__main__':
# file path
path = 'XXXX'
test = pd_service()
test.get_data(file_path=path)

請求示例

POST /fht/compliance/tax/v3/private/url HTTP/1.1
Host: api.bybit.com
X-BAPI-SIGN-TYPE: 2
X-BAPI-SIGN: xxxxxxxxxxxxxx
X-BAPI-API-KEY: xxxxxxxxxxxxxx
X-BAPI-TIMESTAMP: 1671184057480
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json
{"queryId":"12312312415325325"}

響應示例

{
"retCode": 0,
"retMsg": "OK",
"result": {
"url": "{\"Files\":[\"20221216/adfsf34234-8e87-4c72-bc70-dsa234234daf/_SUCCESS\",\"20221216/dafasdf34243-8e87-4c72-bc70-dafsd34234/part-00000-adfsd34-00bd-4fe9-9591-adfasr343-c000\"],\"Basepath\":\"https://prod-bybit-tax-api-1705-rz.s3.ap-southeast-1.amazonaws.com/\"}"
},
"retExtInfo": {},
"time": 1671184057646
}