SteemJ v0.4.2pr1 is available now ~ Use the Steem API in your Java Project

in #utopian-io7 years ago (edited)

SteemJ v0.4.2pr1 is a pre release that comes with a HTTP Client and supports a mixed mode of protocols.


SteemJV2Logo


Previous 0.4.x releases: v0.4.1 v0.4.0

SteemJ v0.4.2pr1 is available now ~ Use the Steem API in your Java Project

Hello Steemians!

I don't know if you also follow the @steemdev blog, but if you do, you may have seen their post "Update your STEEM apps! Big changes coming for 3rd party developers" which announces that Steem deprecates the usage of WebSocket-Connections and that HTTP connections are now the way to go.

As you may also know, SteemJ was totally focused on WebSocket connections so far and had no support for HTTP at all. That means it would become unusable sooner or later or force me to do quick hacks if I would wait too long to implement the required changes.

To avoid this pain and, even more important, to collect some user feedback, I've decided to spend my free Halloween days on adding this feature to SteemJ.

As I made more progress than I've expected I also used the chance to refactor some "skeletons I had in the closet". The outcome of the last days is SteemJ v0.4.2pr1 which can:

  • Connect to HTTPS api endpoints (The official Steem-HTTP-Api endpoint is the default now)
  • Still connect to WebSocket-Endpoints
  • Allows to use both protocols in a mixed mode

Which you hopefully find as a awesome as I do :)

Why is this a pre-release?

As stated at the beginning this release comes with a lot of refactoring and contains a lot of changes and expaccially the connection part is hard to test as everything has to be done manually. Therefore I expect that this version has some potential connection issues and I would like the chance to collect this feedback from users who are interesting in supporting and helping me by testing the new version.


Attention
Source – cr4.globalspec.com

In case you have some time to test the new release I would really appreciate it if you could provide me your feedback in the comments or create a GitHub Issue in case you find a problem. Thank you very much <3

Beside that the work is not totally done. I still need todo a JavaDoc makeover and have some open TODOs in the code, so stay tuned for some more days to get the final version.

HTTP Only

By default SteemJ is now using the official Steem API endpoint 'https://api.steemit.com'. If you want to connect to a different one or to add additional ones to use the SteemJ failover feature you can do as shown in the snippet below.

        ArrayList<Pair<URI, Boolean>> endpoints = new ArrayList<>();

        ImmutablePair<URI, Boolean> httpEndpoint;
        httpEndpoint = new ImmutablePair<>(new URI("https://api.steemit.com"), true);

        endpoints.add(httpEndpoint);
        CONFIG.setEndpointURIs(endpoints);

WebSocket Only

If you want to use a WebSocket connection as SteemJ was doing it before you can use the exact same methods to override the default HTTP Api endpoint and to use a WebSocket endpoint.

        ArrayList<Pair<URI, Boolean>> endpoints = new ArrayList<>();

        ImmutablePair<URI, Boolean> webSocketEndpoint;
        webSocketEndpoint = new ImmutablePair<>(new URI("wss://steemd.steemit.com"), true);

        endpoints.add(webSocketEndpoint);
        CONFIG.setEndpointURIs(endpoints);

Mixed Mode

The failure mechanism introduced in the last SteemJ release was a good base to implement a mixed mode. With v0.4.2pr1 you can simply add both endpoint types. In case of a failure, SteemJ will swith to the next endpoint in the list and switch the protocol too if needed.

        ArrayList<Pair<URI, Boolean>> endpoints = new ArrayList<>();

        ImmutablePair<URI, Boolean> webSocketEndpoint;
        webSocketEndpoint = new ImmutablePair<>(new URI("wss://steemd.steemit.com"), true);
        
        endpoints.add(webSocketEndpoint);
        
        ImmutablePair<URI, Boolean> httpEndpoint;
        httpEndpoint = new ImmutablePair<>(new URI("https://api.steemit.com"), true);
        
        endpoints.add(httpEndpoint);
        
        CONFIG.setEndpointURIs(endpoints);

General information

What is SteemJ?

SteemJ is a project that allows you to communicate with a Steem node using Java. So far, the project supports most of the API calls and is also able to broadcast most of the common operation types. Further information can be found on GitHub.

https://github.com/marvin-we/steem-java-api-wrapper

Quick Start Guide

Add SteemJ to your project

SteemJ binaries are pushed into the maven central repository and can be integrated with a bunch of build management tools like Maven. The Wiki provides a lot of examples for the most common build tools. If you do not use a build management tool you can download the binaries as described here.

To add this release to your project paste the following snippet into your 'pom.xml'

<dependency>
    <groupId>eu.bittrade.libs</groupId>
    <artifactId>steemj-core</artifactId>
    <version>0.4.2pr1</version>
</dependency>

Start posting

SteemJConfig myConfig = SteemJConfig.getInstance();

myConfig.setDefaultAccount(new AccountName("YOUR-ACCOUNT"));

List<ImmutablePair<PrivateKeyType, String>> privateKeys = new ArrayList<>();
privateKeys.add(new ImmutablePair<>(PrivateKeyType.POSTING, "YOUR-PRIVATE-POSTING-KEY"));

myConfig.getPrivateKeyStorage().addAccount(myConfig.getDefaultAccount(), privateKeys);

steemJ.createComment(new AccountName("steemj"), new Permlink("testofsteemj040"), "Example comment without no link but with a @user .", new String[] { "test" });

Further information

The sample module of the SteemJ project provides showcases for the most common acitivies and operations users want to perform.

Beside that you can find a lot of snippets and examples in the different Wiki sections.

Contribute

The project became quite big and there is still a lot to do. If you want to support the project simply clone the git repository and submit a pull request. I would really appreciate it =).

git clone https://github.com/marvin-we/steem-java-api-wrapper.git

Get in touch!

Most of my projects are pretty time consuming and I always try to provide some useful stuff to the community. What keeps me going for that is your feedback and your support. For that reason I would love to get some Feedback from you <3. Just contact me here on Steemit or ping me on GitHub.


If you want to stay up to date or just like the stuff I am doing it would be great if you could leave me a vote and follow me =).

Thanks for reading and best regards,
@dez1337


Open Source Contribution posted via Utopian.io

Sort:  

Nice, thanks for keeping us updated! Looks like I'm also going to have to switch to HTTP myself as well as follow @steemitdev more closely.

Hay @samrg472,

Yeah they start to communicate quite well so I guess following them is worth it for sure 👌

@dez1337 Please remove your greetings.

Hay @ruah - Could you be more specific? Which greetings do you want me to remove?

@dez1337 maybe we can wait for the Moderator that handling you post to come. you can remove your greetings now and the banner. @elear implement a new rule and a post should not contain a greetings, mentioning steem, steemians or utopians because that contribution will go to github.

I removed the part about utopian.io while I still do not understand why it is a problem to say thanks to someone who supported this project for month. Beside that you may should update the rules page as I can't find a single word about this new rule :(

you can remove your greetings now and the banner

Which banner do you exactly mean? =)

I could clarify it with a mod in steemit.chat and now it makes sense - The banner has been removed

Hope you see that I'm just trying to help :) I'm sure your post are going to be approved by mods.

Sure - Please do not take it personal.

The thing is that a lot of things were not clear to me .. I told a mod about and hope that it will be improved as communication is everything =)

Congratulations @dez1337! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of posts published

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Thank you @dez1337. Approved on Utopian

[utopian-moderator]

Thanks 👌🤗

Hey @dez1337 I am @utopian-io. I have just super-voted you at 58% Power!

Suggestions https://utopian.io/rules

-Utopian has detected 2 bot votes. I am the only bot you should love!!

Achievements

-I am a bot...I love developers... <3
-Good amount of information. Thank you!
-A very informative contribution. Good job!
-This is your first accepted contribution here in Utopian. Welcome!
Up-vote this comment to grow my power and help Open Source contributions like this one.