-
Notifications
You must be signed in to change notification settings - Fork 28
Available Methods
The central entry point to work with the API methods shown below is a SteemJ
instance.
You can simply configure and create an instance like this.
SteemJConfig myConfig = SteemJConfig.getInstance();
myConfig.setDefaultAccount(new AccountName("steemj"));
try {
// SteemJ will automatically pick up the configuration made above.
SteemJ steemJ = new SteemJ();
[...]
Please notice that a person running a node can activate or deactive specific plugins depending on hardware resources or personal needs. All API methods shown in this article are supported by SteemJ, but will only work if the plugins are enabled for the node you are connected to.
You can check which plugins are enabled by a node by connected SteemJ
against it and executing the getApiByName
method.
Integer apiNumber = steemJ.getApiByName("follow_api");
The code above will try to get the API id for the follow_api. If the follow_plugin
is disabled, the apiNumber
object will be null
, otherwise the API id is returned.
TOC
The APIs shown in the chapters below are currently offered and supported by the official Steem-Endpoint (https://api.steemit.com).
Will be documented soon ...
Back to Database-API TOC | Back to TOC
The market_history_api covers all api calls related to the internal Steem market.
Market-History-API TOC
- getTicker
- getVolume
- getOrderBook
- getTradeHistory
- getRecentTrades
- getMarketHistory
- getMarketHistoryBuckets
Use this method to receive statistic values of the internal SBD:STEEM market for the last 24 hours.
As this method does not require parameters, the call is quite simply.
MarketTicker marketTicker = steemJ.getTicker();
The call above returns a MarketTicker
object providing information about the:
- Latest price
- Highest price
- Lowest price
- Steem volume,
- SBD volume,
- Change in percent
For the last 24 hours.
Back to Market-History-API TOC | Back to TOC
Use this method to get the SBD and Steem volume that has been traded in the past 24 hours at the internal SBD:STEEM market
MarketVolume marketVolume = steemJ.getVolume();
As shown above the method has no parameter too and also the returned volumes are equal to the one returned by the getTicker method. The only difference is that the getTicker method returns price information in addition.
Back to Market-History-API TOC | Back to TOC
Use this method to receive the current order book of the internal SBD:STEEM market.
The method has one parameter (the limit
) which is used to define the maximum number of asks and bids that should be returned. Please notice that the maximum number of asks/bids is 500
- If you define a limit greater this value an Exception will be thrown.
OrderBook orderBook = steemJ.getOrderBook((short) 50);
The call above will return the next 50
active asks and bids.
Back to Market-History-API TOC | Back to TOC
Use this method to get the trade history of the internal SBD:STEEM market between the defined start
and end
time.
The method requires three parameters in total: The start
date, the end
date and the maximum number of trades to be returned. Please notice that the maximum number of entries is limitted to 1000
entries. If more values requested an exception will be thrown.
List<MarketTrade> marketTrades = steemJ.getTradeHistory(new TimePointSec("2016-08-08T12:24:17"), new TimePointSec(System.currentTimeMillis()), (short) 10);
The call above will return the 10
latest trades fulfilled between the 2016-08-08T12:24:17
and now
.
Back to Market-History-API TOC | Back to TOC
Use this method to request the most recent trades for the internal SBD:STEEM market. The number of results is limited by the limit
parameter. Please notice that the maximum number of recent trades is 500
- If a limit greater than this value is used, an Exception will be thrown.
List<MarketTrade> marketTrades = steemJ.getRecentTrades((short) 10);
The call above will return the latest '10' fulfilled transactions.
Back to Market-History-API TOC | Back to TOC
Use this method to receive the market history for the internal SBD:STEEM market.
List<Bucket> marketHistory = MarketHistoryApi.getMarketHistory(3600, new TimePointSec("2017-08-08T12:24:17"), new TimePointSec(System.currentTimeMillis()));
The method above will request the market history between the 2017-08-08T12:24:17
and now
while the result is splitted into buckets. Each bucket represents a timespan of 3600
.
Please notice that the node needs to support the requested bucket timespan. It is possible to request the available timespans using the getMarketHistoryBuckets method.
Each bucket entry provides detailed information about the market situation for the timespan tracked by this bucket. A bucket consists of the:
- Bucket size,
- Bucket id,
- SBD close value,
- STEEM close value,
- SBD open value,
- STEEM open value,
- SBD volume,
- STEEM volume,
- SBD high,
- STEEM high,
- SBD low,
- STEEM low
While those values are associated with the timespan tracked by the bucket.
Back to Market-History-API TOC | Back to TOC
Use this method to receive the bucket seconds being tracked by the node.
List<Integer> marketHistoryBuckets = steemJ.getMarketHistoryBuckets();
The result of this method is a list of available timespans tracked by the node. An example response could be {15,60,300,3600,86400}
which means the node tracks buckets for a 15, 60, 300, 3600 and 86400 second timespan.
Back to Market-History-API TOC | Back to TOC
The follow_api covers all api calls related to blogs, feeds, and followers.
Follow-API TOC
- getFollowers
- getFollowing
- getFollowCount
- getBlogEntries
- getBlog
- getFeedEntries
- getFeed
- getAccountReputations
- getRebloggedBy
- getBlogAuthors
Use this method to get a list of account names which the following
account is followed by.
Steem offers some filter creteria for this method. As usual, Steem allows to limit the number of results using the limit
parameter. Beside that it is also possible to differ between mutes and follows using the type
parameter. The last filter option is the startFollower
parameter which can be used to only receive accounts that the following
account followed or muted after he or she followed or muted the startFollower
account.
List<FollowApiObject> followers = steemJ.getFollowers(new AccountName("dez1337"),
new AccountName("good-karma"), FollowType.BLOG, (short) 10);
The sample above will return up to 10 account names dez1337 is followed by (FollowType.Blog
) since good-karma has followed dez1337.
List<FollowApiObject> followers = steemJ.getFollowers(new AccountName("dez1337"),
new AccountName(""), FollowType.BLOG, (short) 10);
The sample above will return up to 10 account names dez1337 is followed by.
Back to Follow-API TOC | Back to TOC
Use this method to get a list of account names which the follower
account follows.
Steem offers some filter creteria for this method. As usual, Steem allows to limit the number of results using the limit
parameter. Beside that it is also possible to differ between mutes and follows using the type
parameter. The last filter option is the startFollowing
parameter which can be used to only receive accounts that the follower
account followed or muted after he or she followed or muted the startFollowing
account.
List<FollowApiObject> following = steemJ.getFollowing(new AccountName("dez1337"),
new AccountName("good-karma"), FollowType.BLOG, (short) 10);
The sample above will return up to 10 account names dez1337 has followed (FollowType.Blog
) after he followed good-karma.
List<FollowApiObject> following = steemJ.getFollowing(new AccountName("dez1337"),
new AccountName(""), FollowType.BLOG, (short) 10);
The sample above will return up to 10 account names dez1337 is following.
Back to Follow-API TOC | Back to TOC
Use this method to get the amount of accounts following the given account
and the number of accounts this account
follows.
FollowCountApiObject followCount = steemJ.getFollowCount(new AccountName("dez1337"));
The sample call above will return the number of accounts following dez1337 and the number of accounts dez1337 is following.
Back to Follow-API TOC | Back to TOC
Use this method to get the blog entries of the given author
based on the given coniditions.
Each blog entry of an author
(resteemed or posted on his/her own) has an entryId
, while the entryId
starts with 0 for the first blog entry and is increment by 1 for each resteem or post of the author
.
Steem allows to use the entryId
as a search criteria: The first entry of the returned list is the blog entry with the given entryId
. Beside that, the limit
can be used to limit the number of results.
List<BlogEntry> blogEntries = steemJ.getBlogEntries(new AccountName("dez1337"), 5, (short) 2);
So if the method is called with entryId
set to 5 and the limit
is set to 2, the returned list will contain 2 entries: The first one is the blog entry with entryId
of 5, the second one has the entryId
4.
If the entryId
is set to 0, the first returned item will be the latest blog entry of the given author
.
List<BlogEntry> blogEntries = steemJ.getBlogEntries(new AccountName("dez1337"), 0, (short) 2);
So if a user has 50 blog entries and this method is called with an entryId
set to 0 and a limit
of 2, the returned list will contain the blog entries with the entryId
s 50 and 49.
Back to Follow-API TOC | Back to TOC
This method is like the getBlogEntries method, but instead of the author
and the permlink
, it contains the whole content of the post.
List<CommentBlogEntry> blog = steemJ.getBlog(new AccountName("dez1337"), 0, (short) 10);
The sample above returns the last 10 blog entries of dez1337 blog.
Back to Follow-API TOC | Back to TOC
This method is like the getBlogEntries method, but instead of returning blog entries, the getFeedEntries
method returns the feed of the given account
.
List<FeedEntry> feedEntries = steemJ.getFeedEntries(new AccountName("dez1337"), 0, (short) 100);
So that the sample above returns the latest 100 posts of dez1337s feed.
Back to Follow-API TOC | Back to TOC
This method is like the getBlog method, but instead of returning a blog, the method will return the feed of the given account
.
List<CommentFeedEntry> feed = steemJ.getFeed(new AccountName("dez1337"), 0, (short) 100);
So that the sample above returns the latest 100 posts of dez1337s feed including the whole content of each post.
Back to Follow-API TOC | Back to TOC
This next method can be used to get the reputation for one or more accounts.
The method requires an account name pattern and the number of results Steem should return.
List<AccountReputation> accountReputations = steemJ
.getAccountReputations(new AccountName("dez1337"), 0);
The method returns an account name that matches the most with the given account name pattern and the reputation of this account. The sample above would return the reputation from dez1337, because this account has a 100% match with the given account name pattern "dez1337".
List<AccountReputation> accountReputations = steemJ
.getAccountReputations(new AccountName("dez1337"), 1);
This sample would return the reputation for dez1337, but also add a second account dez243 to the result, because dez243 is the account that has the second most accordance with the given account name pattern.
Back to Follow-API TOC | Back to TOC
Use this method to find out, which user have resteemed a specific post.
The method requires the author of the post and its permanent link, so a method call could look like this:
List<AccountName> accountNames = steemJ.getRebloggedBy(new AccountName("dez1337"),
"steemj-v0-2-6-has-been-released-update-11");
The result of this call is a list of account names which have resteemed the given post.
Back to Follow-API TOC | Back to TOC
Use this method to find out, how many blog entries of which authors have been published by an account.
The method only requires an account name of the blog owner to analzse, so a method call could look like this.
List<PostsPerAuthorPair> blogAuthors = steemJ.getBlogAuthors(new AccountName("dez1337"));
And would return a list of pairs, while earch pair consists of an author name and the number of blog entries that dez1337 has resteemed from this author.
ausbitbank: 1
good-karma: 3
...
In this case two pairs have been returned, providing the information that dez1337 has currently resteemed one post from ausbitsbank in his blog history, and three posts from good-karma.
Back to Follow-API TOC | Back to TOC
The network_broadcast_api is used to broadcast transactions and blocks to the Steem Blockchain.
Network-Broadcast-API TOC
Broadcast a transaction on the Steem blockchain. This method will validate the transaction and return immediately. Please notice that this does not mean that the operation has been accepted and has been processed. If you want to make sure that this is the case use the broadcastTransactionSynchronous method.
ArrayList<AccountName> requiredPostingAuths = new ArrayList<>();
requiredPostingAuths.add(BaseTransactionalIT.STEEMJ_ACCOUNT_NAME);
String id = "follow";
String json = (new FollowOperation(BaseTransactionalIT.STEEMJ_ACCOUNT_NAME,
BaseTransactionalIT.DEZ_ACCOUNT_NAME, Arrays.asList(FollowType.BLOG))).toJson();
CustomJsonOperation customJsonOperation = new CustomJsonOperation(null, requiredPostingAuths, id, json);
ArrayList<Operation> operations = new ArrayList<>();
operations.add(customJsonOperation);
DynamicGlobalProperty globalProperties = steemJ.getDynamicGlobalProperties();
signedTransaction = new SignedTransaction(globalProperties.getHeadBlockId(), operations, null);
signedTransaction.sign();
steemJ.broadcastTransaction(signedTransaction);
The sample above creates a follow operation and broadcasts this operation to the Blockchain.
Back to Network-Broadcast-API TOC | Back to TOC
Use this method to authenticate to the RPC server by providing a username
and a password
.
When setting up a Steem Node the operator has the possibility to protect specific APIs with a user name and a password. Requests to secured API-Endpoints require a login before being accessed. This can be achieved by using this method.
[...]
CustomJsonOperation customJsonOperation = new CustomJsonOperation(null, requiredPostingAuths, id, json);
[...]
BroadcastTransactionSynchronousReturn result = steemJ.broadcastTransactionSynchronous(signedTransaction);
The sample above creates the same follow operation as the broadcastTransaction sample, but this time we receive a result
. The result provides the following information:
- id
- blockNum
- trxNum
- expired
Back to Network-Broadcast-API TOC | Back to TOC
Use this method to broadcast a whole block.
Will be documented soon...
Back to Network-Broadcast-API TOC | Back to TOC
The APIs shown in the chapters below are not offered by default - There may be chance that the node you are connected to still offers those methods.
The login_api provides a small collection of methods to authenticate against a node and to get some information about the node configuration.
Login-API TOC
Use this method to authenticate to the RPC server by providing a username
and a password
.
When setting up a Steem Node the operator has the possibility to protect specific APIs with a user name and a password. Requests to secured API-Endpoints require a login before being accessed. This can be achieved by using this method.
steemJ.login(new AccountName("gilligan"), "s.s.minnow");
The sample shown above will return true
if node is not protected at all or if the user gilligan
with the password s.s.minnow
has been added in the node configuration. If the node is protected, but gilligan
used the wrong password the method will return false.
Back to Login-API TOC | Back to TOC
Use this method to receive the ID of an API or null
if an API with the apiName
does not exist or is disabled.
steemJ.getApiByName("database_api")
The sample above would return 1 as the database_api
exists, is enabled and has the ID 1.
steemJ.getApiByName("steemj-super-api");
The second sample will return null, as the steemj-super-api
does not exist.
Back to Login-API TOC | Back to TOC
Use this method to get detailed information about the Steem version of the node SteemJ is connected to.
SteemVersionInfo version = steemJ.getVersion();
The version
object now contains the following information:
- blockchainVersion
- steemRevision
- fcRevision
The blockchainVersion
shows which Steem Version is currently running (e.g. HF 19), while the both other values are the latest GIT commit the Steem version is based on. The steemRevision
shows the GIT Commit ID for the Steem project, the fcRevision
shows the latest commit of the FC project.
This project is developed by dez1337