SteemJ v0.4.2pr1 is a pre release that comes with a HTTP Client and supports a mixed mode of protocols.
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.
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> endpoints = new ArrayList<>();
ImmutablePair 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> endpoints = new ArrayList<>();
ImmutablePair 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> endpoints = new ArrayList<>();
ImmutablePair webSocketEndpoint;
webSocketEndpoint = new ImmutablePair<>(new URI("wss://steemd.steemit.com"), true);
endpoints.add(webSocketEndpoint);
ImmutablePair 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'
eu.bittrade.libs
steemj-core
0.4.2pr1
Start posting
SteemJConfig myConfig = SteemJConfig.getInstance();
myConfig.setDefaultAccount(new AccountName("YOUR-ACCOUNT"));
List> 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