How to get a transaction record within a day? I am new to Stellar so how do I do this in Java? Is there any way?

  • Are you asking how to get all transaction records for a specific day?
    – Synesso
    Commented Apr 23, 2018 at 23:20

2 Answers 2


This working, untested Java code will print all transaction hashes from the preceding 24 hours:

long ONE_DAY_IN_SECONDS = 60 * 60 * 24;

DateTimeFormatter dateParser = DateTimeFormatter
long now = ZonedDateTime.now().toEpochSecond();

Server server = new Server("https://horizon-testnet.stellar.org");
TransactionsRequestBuilder txnRequests = server.transactions().limit(200)

List<TransactionResponse> responses = new ArrayList<>();
Page<TransactionResponse> page = txnRequests.execute();

boolean limitHit = false;
while (!limitHit) {
    page.getRecords().removeIf(txn -> {
        ZonedDateTime txnDateTime = 
            ZonedDateTime.parse(txn.getCreatedAt(), dateParser);
        return now - txnDateTime.toEpochSecond() > ONE_DAY_IN_SECONDS;

    if (page.getRecords().isEmpty()) {
        limitHit = true;
    } else {
        String pagingToken = responses.get(responses.size() - 1).getPagingToken();
        page = server.transactions().limit(200).order(RequestBuilder.Order.DESC)

responses.forEach(txn -> {
    System.out.println("txn = " + txn.getHash());
  • is there a way to do this for specific account id
    – srbyk1990
    Commented Apr 24, 2018 at 15:47
  • 1
    @srbyk1990 Yes there is. Just add .forAccount(KeyPair) onto the transaction lookup chain. e.g. server.transactions().forAccount(myAccn).limit(200)...
    – Synesso
    Commented Apr 24, 2018 at 22:33

If you want just today's tx, just curl the Horizon "transaction" endpoint is ok. Example with testnet: https://horizon-testnet.stellar.org/transactions?order=desc

Crawl the "next" page recursively to check if there are still tx created today.


By default, only 10 tx are listed in every page. You may increase it, for example, to 150: https://horizon-testnet.stellar.org/transactions?limit=150&order=desc (Note: largest possible return limit is 200)

The "cursor" parameter can be helpful, but it is DB stuff and unlikely you will use it. If you wish to find all tx of a certain day, you need to build your own Horizon and query the DB yourself. There is a transaction_history table containing tx timestamps.

Note: Timestamps are of UTC.

Better have quick check at Laboratory to see if this suits what you want..

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.