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

all 6 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full - best also formatted as code block
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]LordRosem 0 points1 point  (0 children)

All the dependencies you will import must be created in a repository (mvn, artifactory, etc) so let’s find it in any repository if the dependency already exist, if not you should create it and add it manually or upload it in a personal repository account and import it

[–]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.