Retrieve Data Export
Retrieve data export
HTTP Request
POST /fht/compliance/tax/v3/private/url
Request Parameters
Parameter | Required | Type | Comments |
---|---|---|---|
queryId | true | string | Report Request ID |
Response Parameters
Parameter | Type | Comments |
---|---|---|
url | string | URL of files (Basepath + Files). To shorten the time it takes to generate the report, it could generate multiple files. Do take note of this and combine the several files using the same base path when requesting the data export |
info
Convert S3 Files To CSV using python script
Sample Python Script
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)
Request Example
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"}
Response Example
{
"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
}