Chilkat Online Tools

TCL / Binance spot API / Create a ListenKey (USER_STREAM)

Back to Collection Items

load ./chilkat.dll

# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

set http [new_CkHttp]

CkHttp_SetRequestHeader $http "Content-Type" "application/json"
CkHttp_SetRequestHeader $http "X-MBX-APIKEY" "{{binance-api-key}}"

# resp is a CkHttpResponse
set resp [CkHttp_QuickRequest $http "POST" "https://domain.com/api/v3/userDataStream"]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    exit
}

puts [CkHttpResponse_get_StatusCode $resp]
puts [CkHttpResponse_bodyStr $resp]
delete_CkHttpResponse $resp


delete_CkHttp $http

Curl Command

curl -X POST
	-H "Content-Type: application/json"
	-H "X-MBX-APIKEY: {{binance-api-key}}"
https://domain.com/api/v3/userDataStream

Postman Collection Item JSON

{
  "name": "Create a ListenKey (USER_STREAM)",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "type": "text",
        "value": "application/json"
      },
      {
        "key": "X-MBX-APIKEY",
        "value": "{{binance-api-key}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "{{url}}/api/v3/userDataStream",
      "host": [
        "{{url}}"
      ],
      "path": [
        "api",
        "v3",
        "userDataStream"
      ]
    },
    "description": "Start a new user data stream.\nThe stream will close after 60 minutes unless a keepalive is sent. If the account has an active `listenKey`, that `listenKey` will be returned and its validity will be extended for 60 minutes.\n\nWeight: 1"
  },
  "response": [
  ]
}