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

in #utopian-io7 years ago

SteemJ v0.4.3 adds additional simplified operations, is now based on the Google-HTTP-Client and adds a bunch of further improvements.


SteemJV2Logo


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

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


Hello Steemians!

I hope you all head a nice first advent =) As a small present on top I am proud to share the latest SteemJ version with you which is shipped with a bunch of improvements.

The first thing I would like to point out is that version 0.4.3 changes the HTTP-Client used for the new Steem HTTP Endpoint. The feature has been introduced with v0.4.2 and the implementation was based on the Apache-HTTP-Client. After the release I was informed that this library does not work on Android. As I do not want SteemJ to be incompatible with Android again, I had to change the HTTP-Client to the Google-HTTP-Java-Client. At this point a big thank you to @filippkowalski for pointing this out and also for testing the new version.

Beside @filippkowalski I also need to say thanks to @philip-healy, who added several useful simplified operations to SteemJ which I will show in detail later on.

I am really happy to see more and more people using SteemJ and also contributing to it, but so far, contributors had a really tough life when they wanted to test their implementations, because SteemJ was still requiring my private keys to run the Integration Tests and as you can imagine, I do not share my private keys. Some weeks ago I've discovered the TestNet provided by @almost-digital and immediatly thought about running the Integration Tests against it. This change required a huge adoption of the test cases, but from now on, every activity which would require a private key will be using the TestNet.

In addition, I've started to review the existing Api-Calls. The target is to refactor and document all available Api-Methods and, on top, implement the missing ones. This work is still in progress, but SteemJ v0.4.3 already comes with a first bunch of new or reviewed methods (e.g. the network_broadcast_api has been fully implemented or the operation of the witness_plugin which has been added).

Full ChangeLog

  • #145 Simplified Operations for Transfers
  • #149 Claim rewards simplified operation
  • #151 Refactor the login api
  • #43 Run all integration tests against the TestNet provided by @almost-digital
  • #146 No static field INSTANCE error on Android
  • #153 Add an Integer value to the Operation enum so entries can be switched
  • #155 Remove the sign(skipValidation) method and use the SteemJConfig validation parameter instead enhancement
  • #152 Implement a helper method to handle null checks
  • #148 Implement a simplified delegation operation
  • #134 Make it possible to define the expected asset symbol types in the SteemJConfig
  • #140 Fully implement the witness_api
  • #159 Change the loglevel of the API check from WARN to DEBUG
  • #158 Document default benificiary in the JavaDoc too
  • #76 Fully implement the network_broadcast_api and move it to a separate package
  • #131 Use boolean instead of Boolean as it is not nullable
  • #164 Asset precision is null if the symbol has not been set
  • #163 Create a double constructor for the Asset object
  • #147 Adjust the Wiki for 0.4.3

Changes in Detail

This section provides snippets for new features and also points out changes.

145 - Simplified Operations for Transfers

The method shown below allows you to transfer the Token of your choice (STEEM, SBD, VESTS/SteemPower) to another account by providing the following parameters:

  • The target account (e.g. dez1337)
  • The amount and Token type to transfer (e.g. 1.0 STEEM)
  • A message (e.g. Hello @dez1337 - I've send you one STEEM.)
steemJ.transfer(new AccountName("dez1337"), new Asset(1.0, AssetSymbolType.STEEM), "Hello @dez1337 - I've send you one STEEM.");

149 - Claim rewards simplified operation

This method allows you to claim the rewards of an account.

steemJ.claimRewards();

The method has the same functionallity as the "Redeem Rewards" button in your Steemit.com Wallet.


SteemitScreenshot

148 - Implement a simplified delegation operation

Use this method to delegate your SteemPower to another account.

When SteemPower is delegated it is basically added to the SteemPower of the target account while the target account is not able to transfer or withdraw this SteemPower. The main usage of this functionallity is to support other users or innitiatives.

Delegating SteemPower with SteemJ can be done by providing the following twi parameters to the delegateVestingShares method:

  • The target account
  • The amount to send (Make sure that VESTS is used as the Symbol)
steemJ.delegateVestingShares(new AccountName("dez1337"), new Asset(10L, AssetSymbolType.VESTS));

The sample above would delegate 0.00010 VESTS to dez1337.

134 - Make it possible to define the expected asset symbol types in the SteemJConfig

SteemJ 0.4.0 added a build in validation to a lot of methods and objects, but was hardcoded to use the normal Steem Token Types (SBD, STEEM, VESTS). As you may want to work against other chains or a TestNet where other Symbol Types are used, SteemJ now allows to define the expected token types.

myConfig.setDollarSymbol(AssetSymbolType.SBD);
myConfig.setTokenSymbol(AssetSymbolType.TEST);
myConfig.setVestsSymbol(AssetSymbolType.VESTS);

164 - Asset precision is null if the symbol has not been set

The old implementation of the Asset object had an empty constructor:

Asset asset = new Asset();
asset.setAmount(200L);
[...]

This can cause NullPointerExceptions if not used correctly. To avoid this situation the default constructor has been removed.

163 - Create a double constructor for the Asset object

The old implementation of the Asset object only accepted a long value as an amount. This requires that you, as a user, know how many positions after the decimal point every Symbol has (e.g. STEEM has 3, VESTS has 6, ..).

To improve the situation SteemJ v0.4.3 adds a Double constructor to the Asset object:

// Asset Object for 200 Steem:
Asset asset = new Asset(200.0, AssetSymbolType.STEEM);
[...]

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.3</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 upvote and resteem this post =).

Thanks for reading and best regards,
@dez1337



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

It is me who should thank you for creating this library. It made creating Android client for Steem much easier.

I hope to release Android app this month. Will post updates on my profile.

Cheers!

Hehe 😊 Good to see you here :) Keep me updated about your app 😊👍

Thanks @dez1337 for this post! For me as a beginner it is useful and helpful!

beautiful post, thanks @dez1337 for this post.

Thank you for the feedback 👌🤗

you are welcome visit @eliashossain cooperate by voting @dez1337

Thank you for the contribution @dez1337. It has been approved on Utopian.
You can contact us on Discord.
[utopian-moderator]

Thanks :)

you are welcome ;)

thank you for nice post

Hey @dez1337 I am @utopian-io. I have just upvoted you!

Achievements

  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Can I integrate with my android app?