November 16, 2023

Crypto Wallet History API – Get Users’ Wallet Transaction History

Table of Contents
Crypto Wallet History API - Get Users’ Wallet Transaction History

Are you building a decentralized exchange (DEX), crypto wallet, or any other Web3 platform and need an easy way to query a wallet’s history? If so, you’re precisely where you need to be. In today’s guide, we’ll show you how to seamlessly fetch a wallet’s history in a human-readable format using the best crypto wallet history API – Moralis’ Wallet API. With this premier tool, you only need a single endpoint to get the data you need!

Say goodbye to countless API calls and the headache of stitching together internal transfers, ERC-20 transactions, and other events. With just one call, our Wallet History endpoint allows you to construct a comprehensive timeline of a wallet’s history. If you’re eager to jump straight into the code, check out the endpoint in action below: 

import fetch from 'node-fetch';

const options = {
 method: 'GET',
 headers: {
   accept: 'application/json',
   'X-API-Key': 'YOUR_API_KEY'
 },
};

fetch(
 'https://deep-index.moralis.io/api/v2.2/wallets/0xda74Ac6b69Ff4f1B6796cdDf61fBDd4A5f68525f/history?chain=eth&order=DESC',
 options
)
 .then((response) => response.json())
 .then((response) => console.log(response))
 .catch((err) => console.error(err));

In return for running the script above, you get the complete human-readable history of the wallet specified in the query parameters, including address labels, transaction categories, summaries, and much more. Here’s an example of what it might look like:

{
  //...
  "result": [
    {
      "hash": "0xc565260238f59fc3f35b74f3011375c7d637db9b075f77d342c30d19f946272e",
      "nonce": "14",
      "transaction_index": "75",
      "from_address": "0xda74ac6b69ff4f1b6796cddf61fbdd4a5f68525f",
      "from_address_label": null,
      "to_address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
      "to_address_label": "Tether USD (USDT)",
      "value": "0",
      "gas": "55331",
      "gas_price": "13623172301",
      "receipt_cumulative_gas_used": "13917979",
      "receipt_gas_used": "41309",
      "receipt_status": "1",
      "block_timestamp": "2024-05-14T14:00:23.000Z",
      "block_number": "19868695",
      "block_hash": "0x660274d577cd20b0b82c1bff5f3c5641ba6027544e005f9256d5add9c7447920",
      "transaction_fee": "0.000562759624582009",
      "nft_transfers": [],
      "erc20_transfers": [
        {
          "token_name": "Tether USD",
          "token_symbol": "USDT",
          "token_logo": "https://logo.moralis.io/0x1_0xdac17f958d2ee523a2206206994597c13d831ec7_0b0d126af6c744c185e112a2c8dc1495",
          "token_decimals": "6",
          "from_address": "0xda74ac6b69ff4f1b6796cddf61fbdd4a5f68525f",
          "from_address_label": null,
          "to_address": "0x28c6c06298d514db089934071355e5743bf21d60",
          "to_address_label": "Binance 14",
          "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
          "log_index": 338,
          "value": "50000000000",
          "possible_spam": false,
          "verified_contract": true,
          "direction": "send",
          "value_formatted": "50000"
        }
      ],
      "method_label": null,
      "native_transfers": [],
      "summary": "Sent 50,000 USDT to Binance 14",
      "possible_spam": false,
      "category": "token send"
    },
    //...
  ]
}

If you want a more detailed explanation of how this works, check out the official Wallet History documentation page, watch the video below, or join us in this guide! 

Also, if you wish to follow along in this tutorial, don’t forget to sign up with Moralis. You can create an account for free, and you’ll gain immediate access to our suite of industry-leading Web3 APIs! 

Overview 

In today’s article, we’ll start by exploring the ins and outs of crypto wallet history APIs. From there, we’ll introduce you to Moralis’ Wallet API – a premier tool that not only provides the functionalities of a crypto wallet history API but also goes beyond that feature. In doing so, we’ll, among other things, introduce you to the Wallet History endpoint, which is the easiest way to get the human-readable history of a wallet. After this, we’ll dive into our main tutorial and show you how to get a user’s wallet transaction history in three steps: 

  1. Get a Moralis API Key
  2. Write a Script Calling the Wallet History Endpoint
  3. Run the Code

Lastly, to top things off, we’ll explore Moralis further and examine additional tools you can combine with the Wallet API to build sophisticated Web3 projects!

So, if you’re looking to integrate human-readable wallet history data into your dapps, this read is for you. Join us as we kickstart things by diving into the intricacies of crypto wallet history APIs. Let’s go!

What is a Crypto Wallet History API?

Whether you’re building a decentralized exchange (DEX), portfolio tracker, Web3 wallet, or any other decentralized application (dapp), you’ll likely realize you need access to your users’ wallet histories. This includes everything from past balances to a complete record of all transactions! 

But why exactly do you need this data? 

To answer the query above, let’s use Web3 wallets as an example. Access to an address’ history is essential when building a Web3 wallet for numerous reasons. For one, it allows you to seamlessly display a user’s past transactions, which is a fundamental aspect of most crypto wallets. However, it additionally unlocks the potential for other prominent features, such as historical data analysis, transaction tracking, tax reports, etc. 

Example of data an application can get with a crypto wallet history API.

So, how can you get this data? 

From a conventional perspective, querying a blockchain network for this information has been quite a challenge, which is precisely why Web3 developers leverage crypto wallet history APIs to simplify the workflow.

But what is a crypto wallet history API? 

A crypto wallet history API (application programming interface) is a set of methods, rules, and protocols allowing you to seamlessly interact with a blockchain network to integrate wallet functionality and historical data into your dapps. Essentially, a crypto wallet history API makes the process of fetching historical wallet data from a blockchain network easy. And with these interfaces, you can leverage premade protocols and methods, meaning you don’t have to reinvent the wheel. In return, you can save lots of development time and resources when building dapps! 

So, which is the best crypto wallet history API? 

For the answer to this question, join us in the next section as we introduce you to Moralis’ industry-leading Wallet API! 

Introducing Moralis’ Wallet API – The Easiest Way to Get the History of a Crypto Wallet 

Moralis’ Web3 Wallet API is the ultimate tool for building wallets and integrating wallet functionality into your dapps. The Wallet API boasts an extensive array of features, unparalleled scalability, and exceptional flexibility, allowing you to build Web3 projects that will blow the competition out of the water!

Our Wallet API supports over 500 million addresses and all major blockchain networks, including Ethereum, Polygon, Optimism, Arbitrum, BNB Smart Chain (BSC), and many others. Consequently, building cross-chain-compatible dapps has never been easier than when working with Moralis.

Graphic art illustration - Moralis Wallet API title with code examples in the background

The Wallet API is equipped with a bunch of prominent features, and below, you’ll find a few examples: 

  • Token Balances: With a single line of code, you can get the token balances of any wallet, including ERC-20s, NFTs, native tokens, stablecoins, and much more. 
  • Wallet History: Get the entire transaction history of any wallet with a single endpoint. 
  • Net Worth: Avoid manual data aggregation and get the net worth of any ERC-20 wallet with just one API call.
  • Profitability: Query the profitability of a wallet, along with the loss/profit status for each token, without breaking a sweat.
  • Transaction Decodings: Access decoded transactions so you can seamlessly connect the dots and understand what’s happening on the blockchain. 
  • Address Labels: All transfer and transaction endpoints are equipped with fully enriched address labels for public addresses, including Coninbase, Uniswap, 1inch, and many more. 
  • ERC-4337 Compatibility: The Wallet API is ERC-4337 compatible. As such, it works perfectly with account abstraction, allowing you to effortlessly fetch token balances, transaction data, and transfers for any smart contract account. 

With an overview of Moralis’ Wallet API, let’s now explore our Wallet History endpoint – the ultimate solution for getting the history of a crypto wallet! 

Moralis’ Wallet History Endpoint 

Moralis’ Wallet History endpoint is the easiest way for you to get the human-readable transaction history of a crypto address. In fact, with this powerful feature, you only need one single API call to get all the data you need! 

Calling the Wallet History endpoint will return the entire history of a wallet across all events in a human-readable format and chronological order. In addition, each event is fully enriched with summaries and categories for 15+ transaction types, meaning the wallet activity is decoded out of the box. 

To highlight the power of this feature, let’s show you what the Wallet History endpoint looks like in action with a simple script: 

import fetch from 'node-fetch';

const options = {
 method: 'GET',
 headers: {
   accept: 'application/json',
   'X-API-Key': 'YOUR_API_KEY'
 },
};

fetch(
 'https://deep-index.moralis.io/api/v2.2/wallets/0xda74Ac6b69Ff4f1B6796cdDf61fBDd4A5f68525f/history?chain=eth&order=DESC',
 options
)
 .then((response) => response.json())
 .then((response) => console.log(response))
 .catch((err) => console.error(err));

Before calling the code above, you simply need to add your Moralis API key by replacing YOUR_API_KEY and configure the query parameters. In return, you’ll get a response that looks something like this: 

{
  //...
  "result": [
    {
      "hash": "0xc565260238f59fc3f35b74f3011375c7d637db9b075f77d342c30d19f946272e",
      "nonce": "14",
      "transaction_index": "75",
      "from_address": "0xda74ac6b69ff4f1b6796cddf61fbdd4a5f68525f",
      "from_address_label": null,
      "to_address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
      "to_address_label": "Tether USD (USDT)",
      "value": "0",
      "gas": "55331",
      "gas_price": "13623172301",
      "receipt_cumulative_gas_used": "13917979",
      "receipt_gas_used": "41309",
      "receipt_status": "1",
      "block_timestamp": "2024-05-14T14:00:23.000Z",
      "block_number": "19868695",
      "block_hash": "0x660274d577cd20b0b82c1bff5f3c5641ba6027544e005f9256d5add9c7447920",
      "transaction_fee": "0.000562759624582009",
      "nft_transfers": [],
      "erc20_transfers": [
        {
          "token_name": "Tether USD",
          "token_symbol": "USDT",
          "token_logo": "https://logo.moralis.io/0x1_0xdac17f958d2ee523a2206206994597c13d831ec7_0b0d126af6c744c185e112a2c8dc1495",
          "token_decimals": "6",
          "from_address": "0xda74ac6b69ff4f1b6796cddf61fbdd4a5f68525f",
          "from_address_label": null,
          "to_address": "0x28c6c06298d514db089934071355e5743bf21d60",
          "to_address_label": "Binance 14",
          "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
          "log_index": 338,
          "value": "50000000000",
          "possible_spam": false,
          "verified_contract": true,
          "direction": "send",
          "value_formatted": "50000"
        }
      ],
      "method_label": null,
      "native_transfers": [],
      "summary": "Sent 50,000 USDT to Binance 14",
      "possible_spam": false,
      "category": "token send"
    },
    //...
  ]
}

The response above contains a bunch of useful information, including a transaction hash, address labels, a category, a summary, and much more. The category and summary parameters are especially interesting, as you get decoded data directly without having to deal with any interpretation logic yourself: 

      //...
      "summary": "Sent 50,000 USDT to Binance 14",
      "possible_spam": false,
      "category": "token send"
       //...

Benefits of the Wallet History Endpoint 

Now that you have familiarized yourself with the Wallet History endpoint, let’s dive into some benefits of this feature: 

  • Reduced Complexity: Avoid the unnecessary complexities of stitching together data from multiple APIs and endpoints. Get the history of any wallet with a single endpoint and dramatically reduce the number of API calls required. 
  • Complete Wallet Insight: With the Wallet History endpoint, you get the entire history of a wallet, including all native transactions, ERC-20 swaps, NFT transfers, and contract interactions, without breaking a sweat. This gives you in-depth, human-readable insight into any wallet’s activity. 
  • Automatic Categories and Summaries: The Wallet API provides fully decoded data, mapping each transaction and transfer to one of 15+ categories. What’s more, each transaction has a ready-to-use summary parameter, providing a brief explanation of the event. 
Crypto wallets with their transaction fetched by an API - Graphic art illustration

3-Step Tutorial: How to Get the Transaction History of a Crypto Address Using Moralis’ Wallet API 

In this brief tutorial, we’ll demo the Wallet History endpoint by showing you how to get the human-readable history of a crypto address in three steps: 

  1. Get a Moralis API Key
  2. Write a Script Calling the Wallet History Endpoint
  3. Run the Code

However, you must deal with a few prerequisites before you can continue! 

Prerequisites 

The Wallet API works with multiple programming languages, including Python, TypeScript, etc. However, for this tutorial, we’ll be using JavaScript. As such, make sure you have the following ready before you move on: 

  • Node.js v.14+
  • Npm/Yarn

Step 1: Get a Moralis API Key 

To call the Wallet API, you need to have an API key. And to get one, you need a Moralis account. Therefore, start by signing up with Moralis and set up your first project! 

Next, go to the ”Settings” tab, scroll down until you find the ”API Keys” section, and copy your Moralis API key: 

Showing how to copy the crypto wallet history API key on the Moralis dashboard

Keep the key for now, as you’ll need it in the next step to initialize Moralis! 

Step 2: Write a Script Calling the Wallet History Endpoint 

Open your preferred IDE, set up a folder, and initialize a new project by running the following command in a new terminal: 

npm init

You can then run the terminal commands below in the root folder to install the required dependencies: 

npm install node-fetch --save
npm install moralis @moralisweb3/common-evm-utils

Next, open your ”package.json” file and add ”type”: ”module”

Opening the ”package.json” file adding ”type”: ”module”: 

From here, create a new ”index.js” file and add the following code: 

import fetch from 'node-fetch';

const options = {
 method: 'GET',
 headers: {
   accept: 'application/json',
   'X-API-Key': 'YOUR_API_KEY'
 },
};

fetch(
 'https://deep-index.moralis.io/api/v2.2/wallets/0xda74Ac6b69Ff4f1B6796cdDf61fBDd4A5f68525f/history?chain=eth&order=DESC',
 options
)
 .then((response) => response.json())
 .then((response) => console.log(response))
 .catch((err) => console.error(err));

Next, you need to make some minor configurations to the code. Start by replacing YOUR_API_KEY with the key you copied during the previous step. Next, configure the parameters to fit your query. 

That’s it; all you need to do from here is run the code!

Step 3: Run the Code 

For the final step, open a terminal and run this command in your project’s root folder to execute the script: 

node index.js

In return for running the code, you’ll get the entire history of the wallet in question in a human-readable format. This will include all transactions, transfers, contract interactions, etc., along with out-of-the-box categories, summaries, and much more. Here’s an example of what it might look like: 

{
  //...
  "result": [
    {
      "hash": "0xc565260238f59fc3f35b74f3011375c7d637db9b075f77d342c30d19f946272e",
      "nonce": "14",
      "transaction_index": "75",
      "from_address": "0xda74ac6b69ff4f1b6796cddf61fbdd4a5f68525f",
      "from_address_label": null,
      "to_address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
      "to_address_label": "Tether USD (USDT)",
      "value": "0",
      "gas": "55331",
      "gas_price": "13623172301",
      "receipt_cumulative_gas_used": "13917979",
      "receipt_gas_used": "41309",
      "receipt_status": "1",
      "block_timestamp": "2024-05-14T14:00:23.000Z",
      "block_number": "19868695",
      "block_hash": "0x660274d577cd20b0b82c1bff5f3c5641ba6027544e005f9256d5add9c7447920",
      "transaction_fee": "0.000562759624582009",
      "nft_transfers": [],
      "erc20_transfers": [
        {
          "token_name": "Tether USD",
          "token_symbol": "USDT",
          "token_logo": "https://logo.moralis.io/0x1_0xdac17f958d2ee523a2206206994597c13d831ec7_0b0d126af6c744c185e112a2c8dc1495",
          "token_decimals": "6",
          "from_address": "0xda74ac6b69ff4f1b6796cddf61fbdd4a5f68525f",
          "from_address_label": null,
          "to_address": "0x28c6c06298d514db089934071355e5743bf21d60",
          "to_address_label": "Binance 14",
          "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
          "log_index": 338,
          "value": "50000000000",
          "possible_spam": false,
          "verified_contract": true,
          "direction": "send",
          "value_formatted": "50000"
        }
      ],
      "method_label": null,
      "native_transfers": [],
      "summary": "Sent 50,000 USDT to Binance 14",
      "possible_spam": false,
      "category": "token send"
    },
    //...
  ]
}

Congratulations; you now know how to use Moralis’ Wallet API to get the history of any crypto address! 

Use Cases for the Wallet History Endpoint

It doesn’t really matter what Web3 platform you’re building; odds are you’ll benefit significantly from our Wallet History endpoint. However, to give you a few examples, we’ll explore three prominent use cases down below: 

  • Cryptocurrency Wallets: Cryptocurrency wallets are websites and applications for storing and managing digital assets. These platforms typically feature an activity tab, giving users deep insight into past transfers. With the Wallet API, you can seamlessly build a timeline for any address with just one endpoint. 
  • Tax Tools: Tax tools are platforms that help users navigate the complicated world of cryptocurrency taxes. And to automate tax reporting, these dapps need access to past trading activities, which is where the Wallet History endpoint enters the equation. 
  • Decentralized Exchanges (DEXs): DEXs are peer-to-peer marketplaces for trading cryptocurrencies. In addition to swap functionality, most DEXs also give users an overview of their past transactions and transfers. And the easiest way to add a feature like this to your platform is to leverage the Wallet History endpoint.

Beyond the Wallet API – Exploring Moralis’ Web3 APIs Further 

Moralis is the industry’s premier Web3 API provider, and our suite of enterprise-grade development tools makes Web3 development a breeze. In addition to the Wallet API, we offer other tools that can aid you when building crypto projects. Below, you’ll find three examples:

  • NFT API: The NFT API is the industry’s leading tool for NFT data. With only single lines of code, you can effortlessly fetch NFT balances, metadata, real-time transfers, on-chain pricing data, etc. 
  • Token API: The Token API allows you to seamlessly get and integrate token data into your dapps. This includes real-time token prices, wallet balances, transfers, and much more. 
  • Streams API: The Streams API is the ultimate tool for monitoring on-chain events and setting up real-time alerts. With this interface, you can set up customized streams to get on-chain events sent directly to your project’s backend via Web3 webhooks. 
Graphic art image - showing the Moralis "M" Logo and a white title stating "Build Web3 Projects with Moralis' Crypto Wallet History API"

All of Moralis’ Web3 APIs are fully cross-chain compatible, meaning you can use our tools to build dapps on multiple blockchain networks, including Ethereum, Polygon, BSC, etc. 

Also, the interfaces mentioned above are only a few examples of our prominent APIs. If you want to explore all our tools, check out our official Web3 API page! 

Summary: Exploring the #1 Crypto Wallet History API

If you aren’t equipped with the proper tools, querying a wallet’s history can be tedious and time-consuming. Fortunately, tools like crypto wallet history APIs can help. But which is the best crypto wallet history API? 

Moralis’ Wallet API is the industry’s #1 tool for wallet data. With this premier interface, you only need our Wallet History endpoint to fetch the entire transaction history of a wallet in a human-readable format. So, whether you’re building a cryptocurrency wallet, portfolio tracker, or any other platform, then your best option for wallet data is to check out Moralis’ Wallet API! 

If you found this crypto wallet history API tutorial interesting, check out other guides here at Moralis. For instance, read about our Gnosis API or learn how to get all owners of an ERC-20 token. Also, if you want to use the Wallet API in your development endeavors, don’t forget to sign up with Moralis!

Market Data API
Build amazing trading and portfolio dapps with this Market Data API. Keep users engaged with up-to-date data!
Market Data API
Related Articles
September 25, 2022

Full Guide: How to Build an Ethereum Dapp in 5 Steps

September 27, 2022

Web3 Template – Build a Dapp Using a Web3 Website Template

December 26, 2023

ETH Gas Tracker – Full Ethereum Gas Tracker Guide

January 14, 2023

ENS Resolver – How to Resolve any ENS Domain

January 21, 2023

How to Create a Twitter Bot for Crypto

March 13, 2023

Buy ENS Domain – Where to Buy ETH Domains

October 4, 2023

Polygon Node Guide: How to Run a Polygon RPC Node

October 13, 2022

Cronos Boilerplate – How to Create Cronos Dapps