Getting user data from Websocket

Hey guys,

I have issues getting user event data from the API. I tried the examples in the com.binance.client.examples library

public class SubscribeUserData {

public static void main(String[] args) {

    RequestOptions options = new RequestOptions();
    SyncRequestClient syncRequestClient = SyncRequestClient.create(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY,

    // Start user data stream
    String listenKey = syncRequestClient.startUserDataStream();
    System.out.println("listenKey: " + listenKey);

    // Keep user data stream

    // Close user data stream

    SubscriptionClient client = SubscriptionClient.create(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY);

    client.subscribeUserDataEvent(listenKey, ((event) -> {
    }), null);



and also

public class UserDataStreamExample {

public static void main(String args) {
BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance("", “”);
BinanceApiRestClient client = factory.newRestClient();

// First, we obtain a listenKey which is required to interact with the user data stream
String listenKey = client.startUserDataStream();

// Then, we open a new web socket client, and provide a callback that is called on every update
BinanceApiWebSocketClient webSocketClient = factory.newWebSocketClient();

// Listen for changes in the account
webSocketClient.onUserDataUpdateEvent(listenKey, response -> {
  if (response.getEventType() == UserDataUpdateEventType.ACCOUNT_UPDATE) {
    AccountUpdateEvent accountUpdateEvent = response.getAccountUpdateEvent();
    // Print new balances of every available asset
  } else {
    OrderTradeUpdateEvent orderTradeUpdateEvent = response.getOrderTradeUpdateEvent();
    // Print details about an order/trade

    // Print original quantity

    // Or price
System.out.println("Waiting for events...");

// We can keep alive the user data stream
// client.keepAliveUserDataStream(listenKey);

// Or we can invalidate it, whenever it is no longer needed
// client.closeUserDataStream(listenKey);


None of these deliver any event data when I do something in the binacne account, like opening positions.

Any ideas what could be wrong here?

Many thanks :slight_smile:

Hi. This might be a programming issue which is not supposed to discuss here. But please also share more info about your case, such as if there is any error message shown to you, and the library name or link (since the package name you provided in not unique).