[Python] Kucoin Universal SDK : Invalid status code 400

Discussão em 'Python' iniciado por Stack, Fevereiro 18, 2025.

  1. Stack

    Stack Membro Participativo

    I am new to algo trading and trying to get account information using the Kucoin account Api. When I run the code I am getting following issue:

    /myenv/lib/python3.11/site-packages/kucoin_universal_sdk/internal/infra/default_transport.py", line 184, in process_response
    raise RestError(None, f"Invalid status code: {resp.status_code}, msg: {resp_body.decode('utf-8')}")
    kucoin_universal_sdk.model.common.RestError: request error, context msg: Invalid status code: 400, msg: {"code":"400001","msg":"Please check the header of your request for KC-API-KEY, KC-API-SIGN, KC-API-TIMESTAMP, KC-API-PASSPHRASE"}


    My code is as follows:

    k_api_key = os.getenv('KUCOIN_API_KEY')
    k_api_secret = os.getenv('KUCOIN_SECRET_KEY')
    k_api_passphrase = os.getenv('PASS_PHRASE')

    # Initialize KuCoin client
    # Set specific options, others will fall back to default values
    http_transport_option = (
    TransportOptionBuilder()
    .set_keep_alive(True)
    .set_max_pool_size(10)
    .set_max_connection_per_pool(10)
    .build()
    )

    # Create a client using the specified options
    client_option = (
    ClientOptionBuilder()
    .set_key(k_api_key)
    .set_secret(k_api_secret)
    .set_passphrase(k_api_passphrase)
    .set_spot_endpoint(GLOBAL_API_ENDPOINT)
    .set_transport_option(http_transport_option)
    .build()
    )
    client = DefaultClient(client_option)

    account_api = client.rest_service().get_account_service().get_account_api()

    getacctinfo = account_api.get_account_info()

    print(getacctinfo.to_dict().values())


    Any guidance to resolve this issue will be very helpful.

    I tried setting up the api key, secret and pass phrase but no change.

    Continue reading...

Compartilhe esta Página