The Crypto.com API method: private/get-transactions is not working

I am trying to automate extracting from the Crypto.com exchange API, but I’m stuck on the Order, Trade, and Transaction History API. The connection works, but my dataset is empty. I emailed crypto.com support, but I could not get it resolved. I have a list of transactions in my history, but I am not able to retrieve them with my code below. I can get the methods for account balances to work, but not for transaction and order history.

Can anyone please suggests what I may be missing or what is wrong with my codes?

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#order-trade-transaction-history-api

    import requests
    import time
    import hmac
    import hashlib
    import json
    import datetime
    import time
    from datetime import datetime
    
    def load_api_credentials(file_path):
    #"""Load API credentials from a JSON file."""
        with open(file_path, 'r') as file:
            credentials = json.load(file)
        return credentials['API_KEY'], credentials['SECRET_KEY']
    
    def get_subaccount_balances(api_key, secret_key):
    #"""Retrieve the get-order-history from Crypto.com Exchange API."""
        url = 'https://api.crypto.com/exchange/v1/private/get-order-history'
        nonce = str(int(time.time() * 1000))
        fromDate = int(datetime.strptime('2023-11-15', '%Y-%m-%d').timestamp() * 1000)
        toDate = int(datetime.strptime('2024-07-08', '%Y-%m-%d').timestamp() * 1000)
        print(fromDate)
        print(toDate)
        req = {
            'id': 1,
            'method': 'private/get-order-history',
            'api_key': api_key,
            'params': { "instrument_name": "BTCUSD-PERP",
                        "start_time": fromDate,
                        "end_time": toDate,
                        "limit": 20},
            'nonce': nonce
        }
        print(nonce)
    
        param_str = ""
        MAX_LEVEL = 3
    
        def params_to_str(obj, level):
            if level >= MAX_LEVEL:
                return str(obj)
            return_str = ""
            for key in sorted(obj):
                return_str += key
                if obj[key] is None:
                    return_str += 'null'
                elif isinstance(obj[key], list):
                    return_str += ''.join([params_to_str(subObj, level + 1) for subObj in obj[key]])
                else:
                    return_str += str(obj[key])
            return return_str
    
        if "params" in req:
            param_str = params_to_str(req['params'], 0)
            payload_str = req['method'] + str(req['id']) + req['api_key'] + param_str +    str(req['nonce'])
        req['sig'] = hmac.new(bytes(str(secret_key), 'utf-8'), msg=bytes(payload_str, 'utf-8'), digestmod=hashlib.sha256).hexdigest()
    
        headers = {'Content-Type': 'application/json'}
        response = requests.post(url, headers=headers, json=req)
        return response.json()
    
    # Load API credentials from JSON file
    API_KEY, SECRET_KEY = load_api_credentials('config.json')
    
    # Get the Order Trade History
    balances = get_subaccount_balances(API_KEY, SECRET_KEY)
    if balances:
        print(json.dumps(balances, indent=4))

Can you please review my codes, and if there’s anyone who has a working Python program to connect to the crypto.com API, your help is greatly appreciated to help me overcome this issue.

New contributor

Taroun Napaul is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật