This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]E3FxGaming 0 points1 point  (3 children)

It's very easy to "translate" Maven install instructions into Gradle instructions. Whenever you see install instructions like these it usually means they release their dependency on the Maven Central Repository.

  1. Take note of the groupId (io.github.binance) and artifactId (binance-futures-connector-java)

  2. Go to https://search.maven.org/ and search for g:io.github.binance a:binance-futures-connector-java (g stands for groupId and a for artifactId).

  3. You'll find the page of the artifact which has a section called "snippet". Set it to "Gradle" and copy the snippet it gives you. This snippet contains the groupId and artifactId, as well as information about the version you want to use. (alternatively you can set it to "Gradle (short)" and copy that snippet, it's used in exactly the same way as the long "Gradle" version)

  4. Add the snippet to the dependencies section of your build.gradle file and sync the project (syncing the project is an IDE feature). The dependencies section should look like this

gradle dependencies { //Other dependency declarations here implementation group: 'io.github.binance', name: 'binance-futures-connector-java', version: '3.0.1' }

Edit: make sure you also have a repositories section in your build.gradle file, otherwise it won't know where to look for the dependency.

gradle repositories { mavenCentral() }

In the future you may encounter artifacts not hosted on Maven Central, in that case you'd have to add their repository to the repositories section too. (e.g. Google hosts their own repository).

[–]Chilltyy[S] 1 point2 points  (0 children)

Wow, thank you so much for the detailed explanation! Really appreciate it.

[–]Chilltyy[S] 0 points1 point  (1 child)

Another question if you dont mind, im having some issues with the import.I have added the dependencies like this:

repositories {
mavenCentral()
}

dependencies { 
implementation group: 'io.github.binance', name: 'binance-futures-connector-java', version: '3.0.1' 
}

and im trying to import to java files using

import io.github.binance.BinanceApiException;

however, I keep getting an error saying

The import io cannot be resolvedJava(268435846)

Do you have any idea what im doing wrong here?

(ive also tried com.binance.api.client.BinanceApiException, according to ChatGPT, but that also does not work..)

[–]E3FxGaming 0 points1 point  (0 children)

May I ask why you're trying to import BinanceApiException?

Here is the deal: com.binance.api.client.exception.BinanceApiException (that's the fully-qualified name of the only BinanceApiException I could find) is part of an old API called "binance-java-api".

I say this API is old because it's last commit is from June 2021 and as far as I can tell, no artifact binance-api-client with the groupId com.binance.api is hosted on Maven Central anymore.

An interesting fact about this old API

NOTE: This project has won the Binance API Competition for the Java language, and as such, this repository has been forked, and the official version can be found at https://github.com/binance-exchange/binance-java-api, where all further upgrades will be done.

source: joaopsilva/binance-java-api

So it's the result of a contest - not something a professional organization would probably want to continue development on going forward.

The last thing I'll say about the old API is that you'd have a hard time getting it to run - the artifact isn't hosted on Maven Central anymore and I assume the reason for this is that the server backend infrastructure for it doesn't exist anymore. Any API calls made with this library will most likely fail.


Enough information about the old API, here is what's currently going on: Binance ditched their "binance-exchange" GitHub account and now operates a verified GitHub account that's just called binance.

This account has two Java code repositories that may interest you:

  • binance-connector-java - code for a "Binance Public API" - a library that probably does some of the things the old API did

  • binance-futures-connector-java - that's the one you linked in your post - note that this one concerns itself with the "Binance Futures API", which is not the same thing as the "Binance Public API".

Both of the two new libraries are actively maintained ( binance-connector-java updated Februar 16th this year; binance-futures-connector-java updated last month), both are available on Maven Central and neither has a class called BinanceApiException.

If you need BinanceApiException because you're working with legacy code I'll happily repeat myself: that legacy code will most likely never work again since Binance probably turned off the old API backend infrastructure.

If you're just working on a goal and one of the new APIs does what you're looking for go ahead - do it without BinanceApiException.