Codefi Data - Fundamental API (1.5.6)

Download OpenAPI specification:Download

Introduction

Blockchains store data in ways most apps find difficult to access. Codefi's Fundamental API (formerly called the Alethio API) gives you a robust and reliable way to query synthesized, indexed Ethereum data in real-time via a JSON:API compliant REST interface.

We designed the endpoints around the frequent needs and pain points of building an Ethereum-powered project. We give you access to the data you need, exactly how you need it - through a comprehensive, general-purpose data model based on EthOn with meaningful aggregation and filtering capabilities exposed via query parameters.

Here are only a few examples that illustrate the power of the API - these use cases are typically not supported by the standard Ethereum json-rpc interface:

  • Retrieve the transaction history of any Ethereum account

  • Retrieve a complete list of incoming and outgoing Ether transfers for any account - including transfers sent by smart contracts

  • Retrieve the token transfer history for any account

  • Retrieve a full map of contract messages (internal transactions) for any account and smart contract

  • Efficiently filter through the entire history of event logs emmitted by any smart contract

Networks

The API is currently live on the following networks:

Network Base URL
Ethereum Mainnet https://api.aleth.io/v1

Authentication

The API can be tested without authentication on low volumes. Unauthenticated access is throttled at ~60 req/min per IP address with a HTTP 429 response code.

For higher throughput and volumes, please register an account with the Developer Portal and use the provided API Key in one of the following supported authentication mechanisms:

  • Bearer Token via an Authorization: Bearer API_KEY header
$ curl https://api.aleth.io/v1/blocks/latest \
  -H "Authorization: Bearer sk_main_0123456789abcdef"
$ curl https://api.aleth.io/v1/blocks/latest \
  -u sk_main_0123456789abcdef:
# The colon prevents curl from asking for a password

Response format

All API responses are serialized as JSON objects and follow the conventions of the JSON:API specificaton:

  • If the response object has a data property, the request was successful and the value of the data property can be either a single object (representing a Resource) or an array of objects (representing a Collection).

  • Otherwise, the response object will have a single errors property, whose value is an array of Error objects.

The meta object

All succesful responses include a meta property along with the data property in the response object. The meta object includes helper information that can vary depending on the type of request and will be described along with the relevant functionality (e.g. the sections on Pagination and Reorg Handling).

For all API responses, however, the meta object includes a few details about the latest block of the canonical chain, as it is seen by the API at the time of the request. This can serve as an anchor for queries that ask for the most recent items of a collection (e.g. latest transactions for an account), as it defines what 'most recent' means to the API at the time of the request:

{
  "meta": {
    "latestBlock": {
      "number": 4242424,
      "blockCreationTime": 1504648858,
      "blockHash": "0x30b65c7412e887eb888abadb230171e7dc09da7bbe0f2a475c0feeed6950dc3b"
    }
  }
}

Resources

The API is organized around the concepts of Resources and Collections.

A Resource typically represents a single blockchain-related concept (e.g. Block, Transaction, Account, etc.) whereas a Collection is a group (array) of resources sharing the same type.

Each resource is uniquely dentified by its type and id. We will refer to this as the resource identifier data.

Let's take Ethereum's genesis block as an example:

curl "https://api.aleth.io/v1/blocks/genesis"

You will find the identifier data as part of the resource payload:

{
  "type": "Block",
  "id": "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"
  // ...
}

Along with the identifier data, all resources have two other types of properties:

  • attributes are static values specific to the resource

  • relationships are pointers to other (related) resources or collections

For example, the genesis block has:

{
  "attributes": {
    "number": 0,
    "blockCreationTime": 1438226773
    // ... other attibutes
  },
  "relationships": {
    "hasBeneficiary": {
      // pointer to the miner's Account
    },
    "transactions": {
      // pointer to the collection of Transactions
    }
  }
}

Multi-Resource Queries

Sometimes it's helpful to fetch a bundle of related resources with a single API request. The API enables you to do this via the include URL parameter. You can choose to include any subset of to-one relationships by providing a comma-separated list of the relationship names in the request.

Let's explore the first Ethereum transaction, along with the details of its from and to Accounts:

curl "https://api.aleth.io/v1/transactions/0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060?include=from,to"

Note the trailing include=from,to argument in the URL. This asks the API to append the related resources to the response, grouped under the included key:

{
  "data": {
    "type": "Transaction",
    "id": "0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060",
    "relationships": {
      "from": {
        "data": {"type": "Account", "id": "0xa1e4380a3b1f749673e270229993ee55f35663b4"}
        // "links" not relevant for this example
      },
      "to": {
        "data": {"type": "Account", "id": "0x5df9b87991262f6ba471f09758cde1c0fc1de734"}
        // "links" not relevant for this example
      }
    }
    // ... other Transaction details
  },
  "included": [
    {
      "type": "Account",
      "id": "0xa1e4380a3b1f749673e270229993ee55f35663b4",
      // ... other Account details
    },
    {
      "type": "Account",
      "id": "0x5df9b87991262f6ba471f09758cde1c0fc1de734",
      // ... other Account details
    }
  ]
}

An included resource will be appended to the included array one time, even if it's referenced by more than one relationship (e.g. if the from and the to Accounts would have been identical in the example above, that Account wouldn't be included twice in the array).

Note: Only the to-one relationships can be multiplexed in a single request. All to-many relationships need to be queried explicitly in separate requests. We chose this approach so we could simplify the API query logic for collection pagination and filtering.

Collection ordering

The default sorting order for all resources that directly relate to activity on a timeline (e.g. Blocks, Transactions, ContractMessages, LogEntries) is reverse chronological (most recent entries are first on the list). We chose this approach as most often than not, users are interested primarily in events or transactions that happened recently, rather than the ones that happened a long time ago.

The globalRank attribute, where present, serves as an aid to this ordering criteria, as it aggregates a hierarchy of indexes into a single composite value:

  • The block number

  • The index of a message (transaction or contract message) in the context of a block

  • The index of an event in the context of a transaction

This value allows you to sort heterogeneous collections of items chronologically, according to the relative order in which they were executed.

Filters

Filters can assist you in refining your queries and distilling the data sets down to resources that have certain properties (attributes or relationships). As a general rule, the filters are applied through the filter[NAME] URL argument. Multiple filters can be chained within a single request, as long as they're targeting different properties.

Example: Let's query the list of transactions between two specific accounts:

curl "https://api.aleth.io/v1/transactions?filter[from]=0x5A0b54D5dc17e0AadC383d2db43B0a0D3E029c4c&filter[to]=0x962f7a7146ca5527fb9bf92491da675f3d2de0d8"

Note: All collections of the same resource type have support for the same filtering parameters.

You will find a full list of supported filters for each collection type in the endpoint reference below. Please note that all filters are only listed once for each collection type, although they can be applied on related collections as well.

Examples:

  1. filter[token] is documented for the root collection /token-transfers, but can be applied to an Account's token transfers as well, for retrieving the list of TokenTransfers related to that Account, in a given Token:

    curl "https://api.aleth.io/v1/accounts/0xd6f480e6e7d75346e254db5d99efa2561d3f3288/tokenTransfers?filter[token]=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
  2. Here's how you can apply the LogEntry topic filter filter[hasLogTopics.0] to retrieve all ERC20 Approve events triggered a given block:

    curl "https://api.aleth.io/v1/blocks/8048150/logEntries?filter[hasLogTopics.0]=0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925"

Pagination

All resource collections that are exported by the API share a uniform pagination strategy.

  • The maximum number of items on a page is controlled by the page[limit] URL argument. The default value is 10 and the maximum allowed value is 100.

  • The beginning or end of the requested page is controlled by a cursor value assigned to either the page[next] or page[prev] URL arguments. Each resource has an immutable cursor attribute that can be used for this purpose.

Note: All the resources that are subject to pagination have a reverse chronological default ordering. This can make the pagination language counter-intuitive, unless you think of the items as being part of an 'activity feed' (with the most recent activity shown on the top of the list). Thus, the first (default) page will always start with the most recent items and progress towards older items. The next page will display older items than the current page, whereas the prev page will display more recent items.

  • The page[next]=cursor argument requests the next page starting immediately after cursor

  • The page[prev]=cursor argument requests the previous page ending immediately before cursor

Pages relative to a cursor

The API automatically creates links for the next and prev pages relative to the set of items included in the active (current) page, and appends these links to the response under the links property.

Let's look into the transactions of Block number 4242424:

curl "https://api.aleth.io/v1/blocks/4242424/transactions?page[limit]=2"
{
  "data": [
    // List of 2 Transaction resources:
    // - first with cursor 0x0040bbf800a60000100030b65c7412e8
    // - second with cursor 0x0040bbf800a50000100030b65c7412e8
  ],
  "links": {
    "prev": "(...) transactions?page[limit]=2&page[prev]=0x0040bbf800a60000100030b65c7412e8",
    "next": "(...) transactions?page[limit]=2&page[next]=0x0040bbf800a50000100030b65c7412e8"
  }
}

Notice how links.prev and links.next were generated to include the cursors of the first and the last items in the current page.

Note: The values set for page[limit] (along with any other filter[] applied to the current page) will be preserved in the pagination links for the next and prev pages.

For all paginated collections, the meta object assigned to the response will include a page object that provides information about the items of the next and prev pages:

  • meta.page.hasNext is a boolean value that indicates whether the next page (starting immediately after the cursor of the last item in the current page) has at least one item.

  • meta.page.hasPrev is a boolean value that indicates whether the previous page (ending immediately before the cursor of the first item in the current page) has at least one item.

Reorg Handling

Data Latency

Our data pipeline keeps track of the blockchain growth in real-time, so you get access to the most recent activity as soon as it takes place. We don't require you to wait for an arbitrary number of confirmations until you get access to the data, so you can build applications that react as quickly as possible to the on-chain events, with minimal delays for your users.

This is a powerful feature that introduces a subtle layer of complexity due to how distributed consensus works: the miners are competing for producing new blocks and sometimes the latest section of the chain becomes a stale branch because a better branch was produced by other nodes. This is also known as a "chain reorg".

Chain reorg

In the image above, the block segment P1-P2 (that was part of the canonical chain) becomes a stale branch because a better chain was created via M1-M2-M3. After the reorg took place, any transaction that was included in P1 or P2 is no longer part of the main chain (hence no longer confirmed), unless it is mined again in one of the blocks that are now part of the main chain.

Rollbacks

We designed the API to handle these situations with minimal overhead for you. The pagination cursors are reorg-safe, so you can surf through resource collections or poll for updates without worrying about data inconsistencies related to reorgs. If we detect that a subset of the items that we've given you have become stale (because the chain reorganized in between requests), we'll simply append a list of rollback items to the next response, to notify you that the status of those items is no longer valid.

In other words, if the pagination cursor that you've just sent is pointing to an item that's no longer part of the main chain, the API will do the heavy lifting by shifting the cursor back into the main chain and returning a list of rollback items whose status you might want to update.

Under the Hood

Here is a step-by-step explanation of how our data pipeline handles a pagination cursor that's pointing to a reorged block (Pc). This is purely informative and you don't need to understand it to successfully use the API, as most of this logic takes place in our backend.

Rollbacks based on a cursor

  • The API will determine A, the most recent common ancestor of Pc and the current tip of the main chain

  • Create a meta.rollback collection that includes all the relevant items on the stale branch (according to the active filters)

  • For page[next]: create a data collection that returns all the relevant items on the main chain (according to the active filters), whose block number is less than or equal to A

  • For page[prev]: same as above, but the block number needs to be strictly greater than A

Let's take a more granular example:

Paginating reorged items

Assume the active query asks for all transactions of a given account X.

The transactions matching the active query are highlighted in the image as lines inside blocks. Note that some blocks might not have any transactions related to the account X, so they are shown empty (no lines) in the image.

The cursor C points to a transaction that’s outside the main chain (block Pc).

The API will send a meta.rollback collection that includes all the transactions of X in the orange blocks.

Important: The rollback dataset won't include all transactions from all the orange blocks, but only the ones that match the active filters (in this example, only the transactions associated with the account X).

Note: The rollback dataset is not paginated, it will include all the relevant items in a single list of resource identifier objects (only the type and id is provided for each rollback item).

  • For page[next]=C, the API will send a data collection that includes the next page[limit] transactions matching the active filters, starting with (and including) block A (note that some blocks might not have any transactions for account X, in this example A and M3 don’t have matching transactions).

  • The same applies for page[prev], but with blocks higher than (and not including) A.

Here is an abstracted example for the query /accounts/X/transactions?page[limit]=3&page[next]=C in the context of the diagram above:

{
  "data": [
    {
      "type": "Transaction",
      "id": "M5-tx1",
      // ... more Transaction details
    },
    {
      "type": "Transaction",
      "id": "M4-tx1",
      // ... more Transaction details
    },
    {
      "type": "Transaction",
      "id": "M2-tx1",
      // ... more Transaction details
    }
  ],
  "meta": {
    "rollback": [
      // only the resource identifiers, no other details
      { "type": "Transaction", "id": "P6-tx1" },
      { "type": "Transaction", "id": "P6-tx2" },
      { "type": "Transaction", "id": "P4-tx1" },
      { "type": "Transaction", "id": "R1-tx1" },
      { "type": "Transaction", "id": "Pc-tx1" },
      { "type": "Transaction", "id": "Pc-tx2" },
      { "type": "Transaction", "id": "Pc-tx3" },
      { "type": "Transaction", "id": "P1-tx1" },
      { "type": "Transaction", "id": "P1-tx2" }
      // always includes the full list, no pagination
    ]
  }
}

Webhooks

Webhooks allow users to monitor any given query for updates and receive real-time notifications when new resources that satisfy the query criteria become part of the blockchain.

Motivation

Let's take the example of monitoring inbound and outbound DAI transfers for the 0x0 account.

We can use the account and token filters on the token transfers endpoint to retrieve a list of transfers, then periodically poll the links.prev link to retrieve fresh updates (the prev link asks for the previous page, which consists of more recent items than the first item in the current list).

$ curl "https://api.aleth.io/v1/token-transfers?filter[account]=0x0000000000000000000000000000000000000000&filter[token]=0x6b175474e89094c44da98b954eedeac495271d0f"
{
  "data": [
    {
      "type": "EtherTransfer",
      "id": "0x008b40460130000041007687f464fcf6",
      "attributes": {
        "transferType": "TransactionTransfer",
        "value": "0",
        "fee": "261479290958400",
        "total": "261479290958400",
        "blockCreationTime": 1576678602,
        ...
      }
    },
    ...
  ],
  "links": {
    "next": "https://api.aleth.io/v1/ether-transfers/0x0000000000000000000000000000000000000000/etherTransfers?filter%5Baccount%5D=0x0000000000000000000000000000000000000000\u0026page%5Blimit%5D=1\u0026page%5Bnext%5D=0x008b40460130000041007687f464fcf6",
    "prev": "https://api.aleth.io/v1/accounts/0x0000000000000000000000000000000000000000/etherTransfers?filter%5Baccount%5D=0x0000000000000000000000000000000000000000\u0026page%5Blimit%5D=1\u0026page%5Bprev%5D=0x008b40460130000041007687f464fcf6"
  }
}

This approach is inconvenient, as it adds a certain delay (the polling interval) and creates many requests that will result in empty responses.

With the new Webhooks system, users can register a Webhook instance that monitors a given query and sends a HTTP POST request to a configurable target URL as soon as new resources that match the query have been included in the chain.

Webhook Behavior

Each Webhook instance is associated with an underlying data query - expressed via the webhook's endpoint, filters and confirmations attributes. For the example above, the underlying query is

https://api.aleth.io/v1/token-transfers?filter[account]=0x0000000000000000000000000000000000000000&filter[token]=0x6b175474e89094c44da98b954eedeac495271d0f

and the corresponding webhook configuration is

{
  "endpoint": "/token-transfers",
  "filters": {
    "account": "0x0000000000000000000000000000000000000000",
    "token": "0x6b175474e89094c44da98b954eedeac495271d0f"
  }
}

The webhook will monitor the result set of this query and synchronize the results with the target (remote server) by keeping track of an internal cursor and pushing paginated results in two distinct stages:

  • The backfill stage: starting with the earliest (oldest) entry in the dataset, pages of maximum 100 items will be POSTed to the target URL.

  • The live stage: as soon as the entire history is synchronized, the webhook will hibernate until one (or potentially more) new items are included in the dataset as a result of a new block being appended to the chain. The webhook will then issue a POST request to the remote URL and send the new items in the body of the request.

The payload of each HTTP POST issued to the target URL will include a list of resources (under the data property) and meta information about the Webhook:

{
  "data": [
    {
      "type": "EtherTransfer",
      "id": "0x008b40460130000041007687f464fcf6",
      "attributes": {...},
      "relationships": {...}
    },
    ...
  ],
  "meta": {
    "webhook": {
      "type": "Webhook",
      "id": "006cfb85008d000010008ca21f438ee5",
      "links": {
        "self": "https://api.aleth.io/v1/webhooks/006cfb85008d000010008ca21f438ee5"
      }
    }
  }
}

Webhook Management

API users can manage their own decicated Webhooks programatically using a separate set of endpoints detailed in the Webhooks section below.

Data Model

The follwing section provides a comprehensive list of all the API endpoints and their associated responses.

The Resource data model borrows a lot from EthOn - the community-sourced Ethereum Ontology. You can use it as a secondary reference for the response schema.

Note: You can access a detailed view of each response (including descriptions of all the fields) by expanding the green pills underneath each endpoint (e.g. the expandable green area reading '200 Block').

Blocks

A Block is the basic element of a 'blockchain'. It functions as an entry in a distributed ledger, recording a series of transactions together with a reference to the previous block. A block is chained to its preceeding block by a cryptographic hash of its contents as a means of reference. Blocks contain an identifier for the final state after all transactions contained in it are validated. There is a consensus mechanism that provides incentives for nodes adding new blocks to the chain ("miners" in the Proof of Work protocol used by the main Ethereum network) that comply with the rules of Ethereum by issuing newly generated tokens ('Ether') to an account specified by the block's author.

All blocks

Returns the list of all Block resources that are currently part of the main (canonical) chain, in reverse chronological order (most recently mined first).

Responses

200

Block List

get/blocks
https://api.aleth.io/v1/blocks

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Block by hash

Returns the Block resource identified by a given block hash. The block can either be part of the current main (canonical) chain or part of a stale (reorged) branch, if the branch was visible to Codefi's network nodes at the time of the reorg.

path Parameters
blockHash
required
string <hex256>
Example: 0x40dd9a773b81b00aacdc81598d19a5beef3ab66d391cc1cea6fb083294e7a184

The block hash in hex format.

Responses

200

Block

get/blocks/{blockHash}
https://api.aleth.io/v1/blocks/{blockHash}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Block by number

Returns the Block resource for a given block number.

path Parameters
number
required
integer
Example: 4041179

The block number.

Responses

200

Block

get/blocks/{number}
https://api.aleth.io/v1/blocks/{number}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Block by label

Returns the Block resource for a given label (genesis or latest).

path Parameters
label
required
string
Enum: "genesis" "latest"
Example: latest

The block label.

Responses

200

Block

get/blocks/{label}
https://api.aleth.io/v1/blocks/{label}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Block parent

Returns the Block resource representing the parent of a given block.

path Parameters
blockHash
required
string <hex256>
Example: 0x40dd9a773b81b00aacdc81598d19a5beef3ab66d391cc1cea6fb083294e7a184

The block hash in hex format.

Responses

200

Block

get/blocks/{blockHash}/parentBlock
https://api.aleth.io/v1/blocks/{blockHash}/parentBlock

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Block beneficiary

Returns the Account resource representing the beneficiary of a given block. The beneficiary of a Block is the account to which fees or mining rewards from the successful mining are transferred.

path Parameters
blockHash
required
string <hex256>
Example: 0x40dd9a773b81b00aacdc81598d19a5beef3ab66d391cc1cea6fb083294e7a184

The block hash in hex format.

Responses

200

Account

get/blocks/{blockHash}/hasBeneficiary
https://api.aleth.io/v1/blocks/{blockHash}/hasBeneficiary

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Block transactions

Returns the list of Transaction resources included in a block, sorted in reverse chronological order (descending by their globalRank attribute).

path Parameters
blockHash
required
string <hex256>
Example: 0x40dd9a773b81b00aacdc81598d19a5beef3ab66d391cc1cea6fb083294e7a184

The block hash in hex format.

Responses

200

Transaction List

get/blocks/{blockHash}/transactions
https://api.aleth.io/v1/blocks/{blockHash}/transactions

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Block contract messages

Returns the list of ContractMessage resources included in a block, sorted in reverse chronological order (descending by their globalRank attribute).

path Parameters
blockHash
required
string <hex256>
Example: 0x40dd9a773b81b00aacdc81598d19a5beef3ab66d391cc1cea6fb083294e7a184

The block hash in hex format.

Responses

200

ContractMessage List

get/blocks/{blockHash}/contractMessages
https://api.aleth.io/v1/blocks/{blockHash}/contractMessages

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Block log entries

Returns the list of LogEntry resources included in a block, sorted in reverse chronological order (descending by their globalRank attribute).

path Parameters
blockHash
required
string <hex256>
Example: 0x40dd9a773b81b00aacdc81598d19a5beef3ab66d391cc1cea6fb083294e7a184

The block hash in hex format.

Responses

200

LogEntry List

get/blocks/{blockHash}/logEntries
https://api.aleth.io/v1/blocks/{blockHash}/logEntries

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Block Ether transfers

Returns the list of EtherTransfer resources included in a block, sorted in reverse chronological order (descending by their globalRank attribute).

path Parameters
blockHash
required
string <hex256>
Example: 0x40dd9a773b81b00aacdc81598d19a5beef3ab66d391cc1cea6fb083294e7a184

The block hash in hex format.

Responses

200

EtherTransfer List

get/blocks/{blockHash}/etherTransfers
https://api.aleth.io/v1/blocks/{blockHash}/etherTransfers

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Block token transfers

Returns the list of TokenTransfer resources included in a block, sorted in reverse chronological order (descending by their globalRank attribute).

path Parameters
blockHash
required
string <hex256>
Example: 0x40dd9a773b81b00aacdc81598d19a5beef3ab66d391cc1cea6fb083294e7a184

The block hash in hex format.

Responses

200

TokenTransfer List

get/blocks/{blockHash}/tokenTransfers
https://api.aleth.io/v1/blocks/{blockHash}/tokenTransfers

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by canonical status

Returns the list of Block resources filtered by their status of being included in the current canonical (main) chain produced by the consensus network. If this filter is not set explicitly set, its implicit value is true.

query Parameters
value
boolean

The boolean flag representing the canonical status to filter by.

Responses

200

Block List

get/blocks?filter[canonical]={value}
https://api.aleth.io/v1/blocks?filter[canonical]={value}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Accounts

An Account is the superclass of all account types in Ethereum. All accounts are identified by an address (which, however, is derived differently for external and contract accounts) and an account state that contains the contract's balance and total message count, which is called its nonce. Contract accounts also have an associated storage state and EVM code. The address of an external account is derived from the public key of a public and private keypair, while a contract account address is a concatenation of the creator account's address and its nonce.

Account details

Returns the details of a given Account address.

path Parameters
address
required
string <hex160>
Example: 0x50126e8fcb9be29f83c6bbd913cc85b40eaf86fc

Account hex address.

Responses

200

Account

get/accounts/{address}
https://api.aleth.io/v1/accounts/{address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Account contract

Returns the Contract resource associated with a given Account.

path Parameters
address
required
string <hex160>
Example: 0x50126e8fcb9be29f83c6bbd913cc85b40eaf86fc

Account hex address.

Responses

200

Contract

get/accounts/{address}/contract
https://api.aleth.io/v1/accounts/{address}/contract

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Account transactions

Returns the list of Transaction resources associated with a given Account, sorted in reverse chronological order (most recent first). Both the transactions originating from and sent to the account are included.

This collection supports the same filters as the Transactions collection.

path Parameters
address
required
string <hex160>
Example: 0x50126e8fcb9be29f83c6bbd913cc85b40eaf86fc

Account hex address.

Responses

200

Transaction List

get/accounts/{address}/transactions
https://api.aleth.io/v1/accounts/{address}/transactions

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Account contract messages

Returns the list of ContractMessage resources associated with a given Account, sorted in reverse chronological order (most recent first). Both the contract messages originating from and sent to the account are included.

This collection supports the same filters as the ContractMessages collection.

path Parameters
address
required
string <hex160>
Example: 0x50126e8fcb9be29f83c6bbd913cc85b40eaf86fc

Account hex address.

Responses

200

ContractMessage List

get/accounts/{address}/contractMessages
https://api.aleth.io/v1/accounts/{address}/contractMessages

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Account Ether transfers

Returns the list of EtherTransfer resources associated with a given Account, sorted in reverse chronological order (most recent first). Both the transfers that were sent to or received by the account are included.

This collection supports the same filters as the EtherTransfers collection.

path Parameters
address
required
string <hex160>
Example: 0x50126e8fcb9be29f83c6bbd913cc85b40eaf86fc

Account hex address.

Responses

200

EtherTransfer List

get/accounts/{address}/etherTransfers
https://api.aleth.io/v1/accounts/{address}/etherTransfers

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Account token transfers

Returns the list of TokenTransfer resources associated with a given Account, sorted in reverse chronological order (most recent first). Both the transfers that were sent to or received by the account are included.

This collection supports the same filters as the TokenTransfers collection.

path Parameters
address
required
string <hex160>
Example: 0x50126e8fcb9be29f83c6bbd913cc85b40eaf86fc

Account hex address.

Responses

200

TokenTransfer List

get/accounts/{address}/tokenTransfers
https://api.aleth.io/v1/accounts/{address}/tokenTransfers

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Account token balances

Returns the list of TokenBalance resources associated with a given Account, sorted in alphabetical order by Token address.

This collection supports the same filters as the TokenBalances collection.

path Parameters
address
required
string <hex160>
Example: 0x50126e8fcb9be29f83c6bbd913cc85b40eaf86fc

Account hex address.

Responses

200

TokenBalance List

get/accounts/{address}/tokenBalances
https://api.aleth.io/v1/accounts/{address}/tokenBalances

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Account activity

Consolidates the activity of a given Account in a unified list of entries.

Returns an aggregated list of Transaction, ContractMessage, EtherTransfer and TokenTransfer resources, sorted in reverse chronological order.

path Parameters
address
required
string <hex160>
Example: 0x50126e8fcb9be29f83c6bbd913cc85b40eaf86fc

Account hex address.

Responses

200

Account Activity List

get/accounts/{address}/activity
https://api.aleth.io/v1/accounts/{address}/activity

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Contracts

A Contract account is an account whose behaviour is controlled by a smart contract. Contract accounts are identified by their address which is derived from the creator account's address and nonce. A contract account has a non-empty associated EVM code. It's state data consists of the bytecode, the contract's balance and the storage state of the contract's code (for example the value of variables). A contract account can only act when it is triggered by a message. It may not create and sign transactions, but it can receive transactions from external accounts as well as send and receive contract messages, which may involve a transfer of Ether. Contract accounts can also contain events which create log entries when triggered.

Contract details

Returns the Contract resource linked to a given address.

path Parameters
address
required
string <hex160>
Example: 0x2af47a65da8CD66729b4209C22017d6A5C2d2400

Contract hex address.

Responses

200

Contract

get/contracts/{address}
https://api.aleth.io/v1/contracts/{address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Contract account

Returns the Account resource associated with a given Contract.

path Parameters
address
required
string <hex160>
Example: 0x2af47a65da8CD66729b4209C22017d6A5C2d2400

Contract hex address.

Responses

200

Account

get/contracts/{address}/account
https://api.aleth.io/v1/contracts/{address}/account

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Contract token

Returns the Token resource that encapsulates the details of a token (supply, symbol, etc.) managed by the given Contract, if the contract code is compatible with a supported token standard.

path Parameters
address
required
string <hex160>
Example: 0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359

Contract hex address.

Responses

200

Token

get/contracts/{address}/token
https://api.aleth.io/v1/contracts/{address}/token

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Contract creation block

Returns the Block resource associated with the block where the Contract was created.

path Parameters
address
required
string <hex160>
Example: 0x2af47a65da8CD66729b4209C22017d6A5C2d2400

Contract hex address.

Responses

200

Block

get/contracts/{address}/createdAtBlock
https://api.aleth.io/v1/contracts/{address}/createdAtBlock

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Contract creation transaction

Returns the Transaction resource associated with the Contract creation.

path Parameters
address
required
string <hex160>
Example: 0x2af47a65da8CD66729b4209C22017d6A5C2d2400

Contract hex address.

Responses

200

Transaction

get/contracts/{address}/createdAtTransaction
https://api.aleth.io/v1/contracts/{address}/createdAtTransaction

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Contract creation message

Returns the ContractMessage resource that triggered the Contract creation.

path Parameters
address
required
string <hex160>
Example: 0x2f6392a729b76a6a3056b44e262c70442d26d3c7

Contract hex address.

Responses

200

ContractMessage

get/contracts/{address}/createdAtContractMessage
https://api.aleth.io/v1/contracts/{address}/createdAtContractMessage

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Contract transactions

Returns the list of Transaction resources that were sent to a given Contract, sorted in reverse chronological order (most recent first).

path Parameters
address
required
string <hex160>
Example: 0x2af47a65da8CD66729b4209C22017d6A5C2d2400

Contract hex address.

Responses

200

Transaction List

get/contracts/{address}/transactions
https://api.aleth.io/v1/contracts/{address}/transactions

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Contract messages

Returns the list of ContractMessage resources associated with a given Contract, sorted in reverse chronological order (descending by their globalRank attribute). Both the contract messages originating from and sent to the contract are included.

path Parameters
address
required
string <hex160>
Example: 0x2af47a65da8CD66729b4209C22017d6A5C2d2400

Contract hex address.

Responses

200

ContractMessage List

get/contracts/{address}/contractMessages
https://api.aleth.io/v1/contracts/{address}/contractMessages

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Contract log entries

Returns the list of LogEntry resources that were logged by a given Contract, sorted in reverse chronological order (descending by their globalRank attribute).

path Parameters
address
required
string <hex160>
Example: 0x2af47a65da8CD66729b4209C22017d6A5C2d2400

Contract hex address.

Responses

200

LogEntry List

get/contracts/{address}/logEntries
https://api.aleth.io/v1/contracts/{address}/logEntries

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Transactions

A Transaction is a message between two accounts that may transfer Ether and may contain a payload. Transactions always originate from an external account that is controlled by an external actor by means of a private key. The execution of a transaction creates a 'transaction receipt'.

Transaction details

Returns the Transaction resource identified by the given hash.

path Parameters
txHash
required
string <hex256>
Example: 0x9ed4aff20ae7c029affc78c3467cc4950922bd3d0e925ea6e097cb2f7e8ccf85

Transaction hash.

Responses

200

Transaction

get/transactions/{txHash}
https://api.aleth.io/v1/transactions/{txHash}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Transaction sender

Returns the Account resource representing the sender (from field) of a given Transaction.

path Parameters
txHash
required
string <hex256>
Example: 0x9ed4aff20ae7c029affc78c3467cc4950922bd3d0e925ea6e097cb2f7e8ccf85

Transaction hash.

Responses

200

Account

get/transactions/{txHash}/from
https://api.aleth.io/v1/transactions/{txHash}/from

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Transaction destination

Returns the Account resource representing the destinaton (to field) of given Transaction.

path Parameters
txHash
required
string <hex256>
Example: 0x9ed4aff20ae7c029affc78c3467cc4950922bd3d0e925ea6e097cb2f7e8ccf85

Transaction hash.

Responses

200

Account

get/transactions/{txHash}/to
https://api.aleth.io/v1/transactions/{txHash}/to

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Transaction block

Returns the Block resource representing the canonical block where the Transaction was included.

path Parameters
txHash
required
string <hex256>
Example: 0x9ed4aff20ae7c029affc78c3467cc4950922bd3d0e925ea6e097cb2f7e8ccf85

Transaction hash.

Responses

200

Block

get/transactions/{txHash}/includedInBlock
https://api.aleth.io/v1/transactions/{txHash}/includedInBlock

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Transaction created contracts

Returns the list of Contract resources that were created as a result of executing the Transaction (and all its descendant ContractMessage resources).

path Parameters
txHash
required
string <hex256>
Example: 0x9ed4aff20ae7c029affc78c3467cc4950922bd3d0e925ea6e097cb2f7e8ccf85

Transaction hash.

Responses

200

Contract List

get/transactions/{txHash}/createsContracts
https://api.aleth.io/v1/transactions/{txHash}/createsContracts

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Transaction contract messages

Returns the list of all ContractMessage resources that were triggered as a result of executing the given Transaction.

path Parameters
txHash
required
string <hex256>
Example: 0x9ed4aff20ae7c029affc78c3467cc4950922bd3d0e925ea6e097cb2f7e8ccf85

Transaction hash.

Responses

200

ContractMessage List

get/transactions/{txHash}/contractMessages
https://api.aleth.io/v1/transactions/{txHash}/contractMessages

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Transaction log entries

Returns the list of all LogEntry resources that were created as a result of executing the given transaction.

path Parameters
txHash
required
string <hex256>
Example: 0x9ed4aff20ae7c029affc78c3467cc4950922bd3d0e925ea6e097cb2f7e8ccf85

Transaction hash.

Responses

200

LogEntry List

get/transactions/{txHash}/logEntries
https://api.aleth.io/v1/transactions/{txHash}/logEntries

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Transaction token transfers

Returns the list of all TokenTransfer resources that were created as a result of executing the given Transaction.

path Parameters
txHash
required
string <hex256>
Example: 0x9ed4aff20ae7c029affc78c3467cc4950922bd3d0e925ea6e097cb2f7e8ccf85

Transaction hash.

Responses

200

TokenTransfer List

get/transactions/{txHash}/tokenTransfers
https://api.aleth.io/v1/transactions/{txHash}/tokenTransfers

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by sender

Returns the list of Transaction resources that were sent by a given Account address, sorted in reverse chronological order (most recent first).

query Parameters
address
required
string <hex160>
Example: address=0x50126e8fcb9be29f83c6bbd913cc85b40eaf86fc

The hex address of the originator Account.

Responses

200

Transaction List

get/transactions?filter[from]={address}
https://api.aleth.io/v1/transactions?filter[from]={address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by destination

Returns the list of Transaction resources received by a given Account address, sorted in reverse chronological order (most recent first).

query Parameters
address
required
string <hex160>
Example: address=0x50126e8fcb9be29f83c6bbd913cc85b40eaf86fc

The hex address of the destination Account.

Responses

200

Transaction List

get/transactions?filter[to]={address}
https://api.aleth.io/v1/transactions?filter[to]={address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by account

Returns the list of Transaction resources that were either sent to or received by a given Account address, sorted in reverse chronological order (most recent first).

query Parameters
address
required
string <hex160>
Example: address=0x50126e8fcb9be29f83c6bbd913cc85b40eaf86fc

The hex address of the Account.

Responses

200

Transaction List

get/transactions?filter[account]={address}
https://api.aleth.io/v1/transactions?filter[account]={address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by type

Returns the list of Transaction resources filtered by their message type, sorted in reverse chronological order (most recent first).

query Parameters
type
required
string
Enum: "ValueTx" "CallTx" "CreateTx"
Example: type=ValueTx

The type of the Transaction.

Responses

200

Transaction List

get/transactions?filter[msgType]={type}
https://api.aleth.io/v1/transactions?filter[msgType]={type}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Contract-Messages

A Contract Message is passed between a contract account and any other account (external or contract). It is the result of an execution chain originally triggered by an external eccount.

ContractMessage details

Returns the ContractMessage resource identified by the given id.

path Parameters
id
required
string
Example: msg:0xb53fdc2d618b5c35da706b399f9201721a74082fdb46ee90e487c82e422a4c8c:4

The ContractMessage ID.

Responses

200

ContractMessage

get/contract-messages/{id}
https://api.aleth.io/v1/contract-messages/{id}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

ContractMessage sender

Returns the Account resource representing the sender of a given ContractMessage.

path Parameters
id
required
string
Example: msg:0xb53fdc2d618b5c35da706b399f9201721a74082fdb46ee90e487c82e422a4c8c:4

The ContractMessage ID.

Responses

200

Account

get/contract-messages/{id}/from
https://api.aleth.io/v1/contract-messages/{id}/from

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

ContractMessage destination

Returns the Account resource representing the destination of a given ContractMessage.

path Parameters
id
required
string
Example: msg:0xb53fdc2d618b5c35da706b399f9201721a74082fdb46ee90e487c82e422a4c8c:4

The ContractMessage ID.

Responses

200

Account

get/contract-messages/{id}/to
https://api.aleth.io/v1/contract-messages/{id}/to

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

ContractMessage originator

Returns the Account resource representing the sender of the Transaction that triggered a given ContractMessage.

path Parameters
id
required
string
Example: msg:0xb53fdc2d618b5c35da706b399f9201721a74082fdb46ee90e487c82e422a4c8c:4

The ContractMessage ID.

Responses

200

Account

get/contract-messages/{id}/originator
https://api.aleth.io/v1/contract-messages/{id}/originator

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

ContractMessage transaction

Returns the Transaction resource that triggered the execution of a given ContractMessage.

path Parameters
id
required
string
Example: msg:0xb53fdc2d618b5c35da706b399f9201721a74082fdb46ee90e487c82e422a4c8c:4

The ContractMessage ID.

Responses

200

Transaction

get/contract-messages/{id}/transaction
https://api.aleth.io/v1/contract-messages/{id}/transaction

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

ContractMessage block

Returns the Block resource related to the canonical block where the Transaction that triggered the given ContractMessage was included in.

path Parameters
id
required
string
Example: msg:0xb53fdc2d618b5c35da706b399f9201721a74082fdb46ee90e487c82e422a4c8c:4

The ContractMessage ID.

Responses

200

Block

get/contract-messages/{id}/includedInBlock
https://api.aleth.io/v1/contract-messages/{id}/includedInBlock

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

ContractMessage parent

Returns the ContractMessage resource representing the parent that triggered the given ContractMessage call. Can be null if the given ContractMessage was triggered by a transaction call directly.

path Parameters
id
required
string
Example: msg:0xb53fdc2d618b5c35da706b399f9201721a74082fdb46ee90e487c82e422a4c8c:4

The ContractMessage ID.

Responses

200

ContractMessage

get/contract-messages/{id}/parentContractMessage
https://api.aleth.io/v1/contract-messages/{id}/parentContractMessage

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

ContractMessage created contracts

Returns the list of Contract resources that were created as a result of executing the given ContractMessage (and all its descendant contract messages).

path Parameters
id
required
string
Example: msg:0xb53fdc2d618b5c35da706b399f9201721a74082fdb46ee90e487c82e422a4c8c:4

The ContractMessage ID.

Responses

200

Contract List

get/contract-messages/{id}/createsContracts
https://api.aleth.io/v1/contract-messages/{id}/createsContracts

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

ContractMessage log entries

Returns the list of all LogEntry resources that were created as a result of executing the given ContractMessage.

path Parameters
id
required
string
Example: msg:0xb53fdc2d618b5c35da706b399f9201721a74082fdb46ee90e487c82e422a4c8c:4

The ContractMessage ID.

Responses

200

LogEntry List

get/contract-messages/{id}/logEntries
https://api.aleth.io/v1/contract-messages/{id}/logEntries

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by sender

Returns the list of ContractMessage resources whose sender is a given Account address, sorted in reverse chronological order (most recent first).

query Parameters
address
required
string <hex256>
Example: address=0x50126e8fcb9be29f83c6bbd913cc85b40eaf86fc

The hex address of the originator Account.

Responses

200

ContractMessage List

get/contract-messages?filter[from]={address}
https://api.aleth.io/v1/contract-messages?filter[from]={address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by destination

Returns the list of ContractMessage resources received by a given Account address, sorted in reverse chronological order (most recent first).

query Parameters
address
required
string <hex256>
Example: address=0x50126e8fcb9be29f83c6bbd913cc85b40eaf86fc

The hex address of the destination Account.

Responses

200

ContractMessage List

get/contract-messages?filter[to]={address}
https://api.aleth.io/v1/contract-messages?filter[to]={address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by account

Returns the list of ContractMessage resources that were either sent to or received by a given Account address, sorted in reverse chronological order (most recent first).

query Parameters
address
required
string <hex256>
Example: address=0x50126e8fcb9be29f83c6bbd913cc85b40eaf86fc

The hex address of the Account.

Responses

200

ContractMessage List

get/contract-messages?filter[account]={address}
https://api.aleth.io/v1/contract-messages?filter[account]={address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by type

Returns the list of ContractMessage resources filtered by their message type, sorted in reverse chronological order (most recent first).

query Parameters
type
required
string
Enum: "ValueContractMsg" "CallContractMsg" "CreateContractMsg" "SelfdestructContractMsg"
Example: type=ValueContractMsg

The type of the ContractMessage.

Responses

200

ContractMessage List

get/contract-messages?filter[msgType]={type}
https://api.aleth.io/v1/contract-messages?filter[msgType]={type}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Log-Entries

A Log Entry is the result of an event in a smart contract, emitted during creation or execution of a contract account's code. It is related to the Tx it was created in, the contract account that had the event, a series of 32-bytes log topics and a number of bytes of data.

LogEntry details

Returns the LogEntry resource identified by the given id.

path Parameters
id
required
string
Example: log:0xd70ae3e306514044032fce92bd36a36b90aede20bb119b32672287d28debf5ef:0

The LogEntry ID.

Responses

200

LogEntry

get/log-entries/{id}
https://api.aleth.io/v1/log-entries/{id}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

LogEntry contract

Returns the Contract resource that logged the given LogEntry.

path Parameters
id
required
string
Example: log:0xd70ae3e306514044032fce92bd36a36b90aede20bb119b32672287d28debf5ef:0

The LogEntry ID.

Responses

200

Contract

get/log-entries/{id}/loggedBy
https://api.aleth.io/v1/log-entries/{id}/loggedBy

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

LogEntry block

Returns the Block resource representing the canonical block where the LogEntry was generated.

path Parameters
id
required
string
Example: log:0xd70ae3e306514044032fce92bd36a36b90aede20bb119b32672287d28debf5ef:0

The LogEntry ID.

Responses

200

Block

get/log-entries/{id}/block
https://api.aleth.io/v1/log-entries/{id}/block

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

LogEntry transaction

Returns the Transaction resource that triggered the creation of a given LogEntry.

path Parameters
id
required
string
Example: log:0xd70ae3e306514044032fce92bd36a36b90aede20bb119b32672287d28debf5ef:0

The ContractMessage ID.

Responses

200

Transaction

get/log-entries/{id}/transaction
https://api.aleth.io/v1/log-entries/{id}/transaction

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

LogEntry contract message

Returns the ContractMessage resource that triggered the creation of a given LogEntry. Can be null if the LogEntry was triggered by a transaction call directly.

path Parameters
id
required
string
Example: log:0xd70ae3e306514044032fce92bd36a36b90aede20bb119b32672287d28debf5ef:0

The LogEntry ID.

Responses

200

ContractMessage

get/log-entries/{id}/contractMessage
https://api.aleth.io/v1/log-entries/{id}/contractMessage

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by contract

Returns the LogEntry resources that were logged by the given Contract address.

query Parameters
address
required
string <hex160>
Example: address=0x174bfa6600bf90c885c7c01c7031389ed1461ab9

The hex address of the Contract.

Responses

200

LogEntry List

get/log-entries?filter[loggedBy]={address}
https://api.aleth.io/v1/log-entries?filter[loggedBy]={address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by topic[0]

Returns the LogEntry resources whose topic[0] have the given value.

query Parameters
value
required
string <hex256>
Example: value=0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

The 256-bit hex value of topic0.

Responses

200

LogEntry List

get/log-entries?filter[hasLogTopics.0]={value}
https://api.aleth.io/v1/log-entries?filter[hasLogTopics.0]={value}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by topic[1]

Returns the LogEntry resources whose topic[1] have the given value.

query Parameters
value
required
string <hex256>
Example: value=0x000000000000000000000000ed7fd84fb31577e59ce476f51754c3e2256c542c

The 256-bit hex value of topic[1].

Responses

200

LogEntry List

get/log-entries?filter[hasLogTopics.1]={value}
https://api.aleth.io/v1/log-entries?filter[hasLogTopics.1]={value}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by topic[2]

Returns the LogEntry resources whose topic[2] have the given value.

query Parameters
value
required
string <hex256>
Example: value=0x000000000000000000000000f802ccd600eeae4f6b3bd265525e80f50da8ba5b

The 256-bit hex value of topic[2].

Responses

200

LogEntry List

get/log-entries?filter[hasLogTopics.2]={value}
https://api.aleth.io/v1/log-entries?filter[hasLogTopics.2]={value}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by topic[3]

Returns the LogEntry resources whose topic[3] have the given value.

query Parameters
value
required
string <hex256>
Example: value=0x000000000000000000000000d91946e6b38c1b6404c5304eeee54bb191a662b6

The 256-bit hex value of topic[3].

Responses

200

LogEntry List

get/log-entries?filter[hasLogTopics.3]={value}
https://api.aleth.io/v1/log-entries?filter[hasLogTopics.3]={value}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by any topic

Returns the LogEntry resources that have at least one topic (topic[0], topic[1], topic[2], topic[3]) with the given value.

query Parameters
value
required
string <hex256>
Example: value=0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

The 256-bit hex lookup value.

Responses

200

LogEntry List

get/log-entries?filter[hasLogTopics]={value}
https://api.aleth.io/v1/log-entries?filter[hasLogTopics]={value}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Ether-Transfers

An Ether Transfer is the record of an amount of Ether units (wei) being transferred from one account to another account.

Ether can be moved around between accounts through a variety of factors, such as:

  • Transactions - transfers originating from an external account

  • Contract Messages (internal transactions) - transfers originating from a contract account

  • Block rewards

  • Uncle rewards

We'll call the underlying event that triggered the Ether movement the transfer's carrier.

It is usually difficult to get a complete picture of the Ether inflows for an arbitrary account using only the native Ethereum json-rpc interface. Cases susch as multi-sig withdrawals (e.g. withdrawing Ether from an exchange), receiving a prize from a bounty contract, or collecting a mining reward cannot be properly monitored only by looking at the transaction feed, and there is no built-in method to retrieve internal transfers (transfers initiated by a smart contract).

All these use cases are addressed by the EtherTransfer collection, which provides an aggregate, complete list of all inflows and outflows for any on-chain account, across all carrier types.

EtherTransfer details

Returns the EtherTransfer resource identified by the given id.

The id is a unique, immutable identifier for the transfer instance - it doesn't have a direct on-chain correspondence and for all practical purposes, you can think of it as a random value that’s useful for relating the transfer details with other linked data.

path Parameters
id
required
string
Example: 0x0079c69c004e00004200f7f0b0a20179

The EtherTransfer identifier.

Responses

200

EtherTransfer

get/ether-transfers/{id}
https://api.aleth.io/v1/ether-transfers/{id}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

EtherTransfer sender

Returns the Account resource related to the sender of the transfer.

path Parameters
id
required
string
Example: 0x0079c69c004e00004200f7f0b0a20179

The EtherTransfer identifier.

Responses

200

Account

get/ether-transfers/{id}/from
https://api.aleth.io/v1/ether-transfers/{id}/from

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

EtherTransfer receiver

Returns the Account resource related to the recipient of the transfer.

path Parameters
id
required
string
Example: 0x0079c69c004e00004200f7f0b0a20179

The EtherTransfer identifier.

Responses

200

Account

get/ether-transfers/{id}/to
https://api.aleth.io/v1/ether-transfers/{id}/to

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

EtherTransfer transaction

Returns the Transaction resource that acted as a carrier for a given EtherTransfer. Will be null for transfers whose carrier is a Block or an Uncle reward.

path Parameters
id
required
string
Example: 0x0079c69c004e00004200f7f0b0a20179

The EtherTransfer identifier.

Responses

200

Transaction

get/ether-transfers/{id}/transaction
https://api.aleth.io/v1/ether-transfers/{id}/transaction

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

EtherTransfer contract message

Returns the ContractMessage resource that acted as a carrier for a given EtherTransfer. Can be null if the EtherTransfer carrier is not a ContractMessage.

path Parameters
id
required
string
Example: 0x0079c69c004e00004200f7f0b0a20179

The EtherTransfer identifier.

Responses

200

ContractMessage

get/ether-transfers/{id}/contractMessage
https://api.aleth.io/v1/ether-transfers/{id}/contractMessage

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

EtherTransfer block

Returns the Block resource that corresponds to the block where the transfer was triggered.

path Parameters
id
required
string
Example: 0x0079c69c004e00004200f7f0b0a20179

The EtherTransfer identifier.

Responses

200

Block

get/ether-transfers/{id}/block
https://api.aleth.io/v1/ether-transfers/{id}/block

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

EtherTransfer fee recipient

Returns the Account resource that corresponds to the miner (beneficiary) of the Block where the transfer was triggered.

path Parameters
id
required
string
Example: 0x0079c69c004e00004200f7f0b0a20179

The EtherTransfer identifier.

Responses

200

Account

get/ether-transfers/{id}/feeRecipient
https://api.aleth.io/v1/ether-transfers/{id}/feeRecipient

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by account

Returns the list of EtherTransfer resources that were either sent to or received by a given Account address, sorted in reverse chronological order (most recent first).

query Parameters
address
required
string <hex160>
Example: address=0x50126e8fcb9be29f83c6bbd913cc85b40eaf86fc

The hex address of the Account.

Responses

200

EtherTransfer List

get/ether-transfers?filter[account]={address}
https://api.aleth.io/v1/ether-transfers?filter[account]={address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Tokens

A Token is a fungible virtual good that can be traded. ERC-20 Tokens comply to the standard described in the Ethereum ERC-20 proposal.

Token details

Returns the Token resource linked to a given token contract address.

path Parameters
address
required
string <hex160>
Example: 0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359

The hex address of the Token contract.

Responses

200

Token

get/tokens/{address}
https://api.aleth.io/v1/tokens/{address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Token contract

Returns the Contract resource associated with a given Token. This can be useful for retrieving lower-level activity or details related to the underlying token contract (creation details, message history, log entries, bytecode, etc.)

path Parameters
address
required
string <hex160>
Example: 0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359

The hex address of the Token contract.

Responses

200

Contract

get/tokens/{address}/contract
https://api.aleth.io/v1/tokens/{address}/contract

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Token transfers

Returns the list of TokenTransfer resources denominated in a given Token, sorted in reverse chronological order (most recent first).

path Parameters
address
required
string <hex160>
Example: 0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359

The hex address of the Token contract.

Responses

200

TokenTransfer List

get/tokens/{address}/tokenTransfers
https://api.aleth.io/v1/tokens/{address}/tokenTransfers

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Token reference metadata

Returns reference Token metadata sourced via TruSet.

path Parameters
address
required
string <hex160>
Example: 0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359

The hex address of the Token contract.

Responses

200

TrusetTag

get/tokens/{address}/tags/truset
https://api.aleth.io/v1/tokens/{address}/tags/truset

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Token-Transfers

A Token Transfer is the record of an amount of token units being transferred from one account to another account. If the token complies to ERC-20 the transfer is logged by a LogEntry.

TokenTransfer details

Returns the TokenTransfer resource identified by the given id.

path Parameters
id
required
string
Example: 0x0078afae00f600028101320161a91f42

The TokenTransfer identifier.

Responses

200

TokenTransfer

get/token-transfers/{id}
https://api.aleth.io/v1/token-transfers/{id}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

TokenTransfer token

Returns the details of the Token resource related to the transfer.

path Parameters
id
required
string
Example: 0x0078afae00f600028101320161a91f42

The TokenTransfer identifier.

Responses

200

Token

get/token-transfers/{id}/token
https://api.aleth.io/v1/token-transfers/{id}/token

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

TokenTransfer sender

Returns the Account resource related to the sender of the transfer.

path Parameters
id
required
string
Example: 0x0078afae00f600028101320161a91f42

The TokenTransfer identifier.

Responses

200

Account

get/token-transfers/{id}/from
https://api.aleth.io/v1/token-transfers/{id}/from

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

TokenTransfer receiver

Returns the Account resource related to the recipient of the transfer.

path Parameters
id
required
string
Example: 0x0078afae00f600028101320161a91f42

The TokenTransfer identifier.

Responses

200

Account

get/token-transfers/{id}/to
https://api.aleth.io/v1/token-transfers/{id}/to

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

TokenTransfer transaction

Returns the Transaction resource that triggered the creation of a given TokenTransfer.

path Parameters
id
required
string
Example: 0x0078afae00f600028101320161a91f42

The TokenTransfer identifier.

Responses

200

Transaction

get/token-transfers/{id}/transaction
https://api.aleth.io/v1/token-transfers/{id}/transaction

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

TokenTransfer contract message

Returns the ContractMessage resource that triggered the creation of a given TokenTransfer. Can be null if the TokenTransfer was created directly by a transaction call.

path Parameters
id
required
string
Example: 0x0078afae00f600028101320161a91f42

The TokenTransfer identifier.

Responses

200

ContractMessage

get/token-transfers/{id}/contractMessage
https://api.aleth.io/v1/token-transfers/{id}/contractMessage

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

TokenTransfer log entry

Returns the LogEntry resource that logged a given TokenTransfer.

path Parameters
id
required
string
Example: 0x0078afae00f600028101320161a91f42

The TokenTransfer identifier.

Responses

200

LogEntry

get/token-transfers/{id}/logEntry
https://api.aleth.io/v1/token-transfers/{id}/logEntry

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

TokenTransfer originator

Returns the Account resource representing the sender of the Transaction that triggered a given TokenTransfer. This can be different than the from (sender) of the TokenTransfer.

path Parameters
id
required
string
Example: 0x0078afae00f600028101320161a91f42

The TokenTransfer identifier.

Responses

200

Account

get/token-transfers/{id}/originator
https://api.aleth.io/v1/token-transfers/{id}/originator

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by sender

Returns the list of TokenTransfer resources that were sent by a given Account address, sorted in reverse chronological order (most recent first).

query Parameters
address
required
string <hex160>
Example: address=0x0000000000000000000000000000000000000000

The hex address of the sending Account.

Responses

200

TokenTransfer List

get/token-transfers?filter[from]={address}
https://api.aleth.io/v1/token-transfers?filter[from]={address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by destination

Returns the list of TokenTransfer resources received by a given Account address, sorted in reverse chronological order (most recent first).

query Parameters
address
required
string <hex160>
Example: address=0x0000000000000000000000000000000000000000

The hex address of the destination Account.

Responses

200

TokenTransfer List

get/token-transfers?filter[to]={address}
https://api.aleth.io/v1/token-transfers?filter[to]={address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by account

Returns the list of TokenTransfer resources that were either sent to or received by a given Account address, sorted in reverse chronological order (most recent first).

query Parameters
address
required
string <hex160>
Example: address=0x0000000000000000000000000000000000000000

The hex address of the Account.

Responses

200

TokenTransfer List

get/token-transfers?filter[account]={address}
https://api.aleth.io/v1/token-transfers?filter[account]={address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by token

Returns the list of TokenTransfer resources denominated in a given Token contract address, sorted in reverse chronological order (most recent first).

query Parameters
address
required
string <hex160>
Example: address=0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359

The hex address of the Token contract.

Responses

200

TokenTransfer List

get/token-transfers?filter[token]={address}
https://api.aleth.io/v1/token-transfers?filter[token]={address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Ether-Balances

An Ether Balance object describes the ether holdings of a given Account address, at a given block (latest by default). This value is equivalent to the result of an eth_getBalance RPC call on a network node, performed at the given block.

EtherBalance details

Returns the EtherBalance resource identified by the given id.

path Parameters
id
required
string
Example: 0x0000000000000000000000000000000000000000

The EtherBalance identifier.

Responses

200

EtherBalance

get/ether-balances/{address}
https://api.aleth.io/v1/ether-balances/{address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

EtherBalance account

Returns the Account resource related to the balance object.

path Parameters
id
required
string
Example: 0x0000000000000000000000000000000000000000

The EtherBalance identifier.

Responses

200

Account

get/ether-balances/{address}/account
https://api.aleth.io/v1/ether-balances/{address}/account

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by account

Returns a single-element list comprised of the EtherBalance resource that describes the ether holdings of a given Account address.

query Parameters
address
required
string <hex160>
Example: address=0x0000000000000000000000000000000000000000

The hex address of the token holder Account.

Responses

200

EtherBalance List

get/ether-balances?filter[account]={address}
https://api.aleth.io/v1/ether-balances?filter[account]={address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{
  • "data":
    [],
  • "links":
    {
    },
  • "meta":
    {
    }
}

Query at block

Defines the block number at which the balance queries are performed. By default (if unspecified), all queries are performed at the latest block. The possible values for the block parameter are:

  • latest: returns the token holdings at the latest block
  • NUMBER: returns the token holdings after the state transitions were completed at the given block number.
  • -CONFIRMATIONS: returns the token holdings with CONFIRMATIONS blocks behind the latest block. The block parameter can be added along with any filter or combination of filters on a EtherBalance query.
query Parameters
address
required
string <hex160>
Example: address=0x0000000000000000000000000000000000000000

The hex address of the token holder Account.

block
string
Example: block=-10

The block at which ether balances are queried.

Responses

200

EtherBalance List

get/ether-balances/{address}?block={block}
https://api.aleth.io/v1/ether-balances/{address}?block={block}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{
  • "data":
    [],
  • "links":
    {
    },
  • "meta":
    {
    }
}

Token-Balances

A Token Balance describes the holdings of a given Account address, for a given Token, at a given block (latest by default). This value is equivalent to the result of a balanceOf method call on the corresponding ERC-20 token contract, performed at the given block.

TokenBalance details

Returns the TokenBalance resource identified by the given id.

path Parameters
id
required
string
Example: 0x000000000000000000000000000000000000000057ab1e02fee23774580c119740129eac7081e9d3

The TokenBalance identifier.

Responses

200

TokenBalance

get/token-balances/{id}
https://api.aleth.io/v1/token-balances/{id}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

TokenBalance token

Returns the details of the Token resource related to the balance object.

path Parameters
id
required
string
Example: 0x000000000000000000000000000000000000000057ab1e02fee23774580c119740129eac7081e9d3

The TokenBalance identifier.

Responses

200

Token

get/token-balances/{id}/token
https://api.aleth.io/v1/token-balances/{id}/token

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

TokenBalance account

Returns the Account resource related to the balance object.

path Parameters
id
required
string
Example: 0x000000000000000000000000000000000000000057ab1e02fee23774580c119740129eac7081e9d3

The TokenBalance identifier.

Responses

200

Account

get/token-balances/{id}/account
https://api.aleth.io/v1/token-balances/{id}/account

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by account

Returns the list of TokenBalance resources that correspond to the token holdings of a given Account address, sorted in alphabetical order by the Token address.

query Parameters
address
required
string <hex160>
Example: address=0x0000000000000000000000000000000000000000

The hex address of the token holder Account.

Responses

200

TokenBalance List

get/token-balances?filter[account]={address}
https://api.aleth.io/v1/token-balances?filter[account]={address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Filter by account and token

Returns the TokenBalance resource that correspond to the token holdings of a given Account address for a given Token contract, formatted as a single-element list.

query Parameters
address
required
string <hex160>
Example: address=0x0000000000000000000000000000000000000000

The hex address of the token holder Account.

token
string <hex160>
Example: token=0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359

The hex address of the token contract.

Responses

200

TokenBalance List

get/token-balances?filter[account]={address}&filter[token]={token}
https://api.aleth.io/v1/token-balances?filter[account]={address}&filter[token]={token}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Query at block

Defines the block number at which the balance queries are performed. By default (if unspecified), all queries are performed at the latest block. The possible values for the block parameter are:

  • latest: returns the token holdings at the latest block
  • NUMBER: returns the token holdings after the state transitions were completed at the given block number.
  • -CONFIRMATIONS: returns the token holdings with CONFIRMATIONS blocks behind the latest block. The block parameter can be added along with any filter or combination of filters on a TokenBalance query.
query Parameters
address
required
string <hex160>
Example: address=0x0000000000000000000000000000000000000000

The hex address of the token holder Account.

block
string
Example: block=-10

The block at which token balances are queried.

Responses

200

TokenBalance List

get/token-balances?block={block}&filter[account]={address}
https://api.aleth.io/v1/token-balances?block={block}&filter[account]={address}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Webhooks

A Webhook encapsulates information about an API collection that will be automatically monitored for updates, so the user can receive real-time HTTP notifications when new resources that satisfy the query criteria become part of the blockchain.

All endpoints require user authentication.

For a detailed description of the Webhook data flow see the Webhook introductory section above.

Create new webhook

Creates a new Webhook with the given attributes.

The target URL will be pinged at the time of Webhook creation via a POST request with the following request body:

{
  "data": [],
  "meta": {
    "webhook": {
      "type": "Webhook",
      "id": "006cfb85008d000010008ca21f438ee5",
      "links": {
        "self": "https://api.aleth.io/v1/webhooks/006cfb85008d000010008ca21f438ee5"
      }
    }
  }
}

The webhook creation will only succeed if the response of the remote target has a 200 status. Otherwise, it will fail with a 424 (Failed Dependency) error.

header Parameters
Authorization
required
string
Example: Bearer sk_main_xxxxxxxxxxxxx

The Codefi Data API Key associated with the request

Request Body schema: application/vnd.api+json
data
object (WebhookCreateRequest)

Responses

200

Webhook Details

401

Unauthorized

424

Failed Dependency

post/webhooks
https://api.aleth.io/v1/webhooks

Request samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

List all webhooks

Returns a paginated list of all Webhook resources.

query Parameters
page[limit]
number [ 1 .. 100 ]
Default: 10

The maximum number of items to be included in a page.

page[next]
string
Example: page[next]=016cfb85008d000010008ca21f438ee5

Instructs the server to fetch the next page of items, starting immediately after the provided cursor value. Cannot be used together with page[prev] in the same request.

page[prev]
string
Example: page[prev]=016cfb85008d000010008ca21f438ee5

Instructs the server to fetch the previous page of items, starting immediately before the provided cursor value. Cannot be used together with page[next] in the same request.

header Parameters
Authorization
required
string
Example: Bearer sk_main_xxxxxxxxxxxxx

The Codefi Data API Key associated with the request

Responses

200

Webhook List

401

Unauthorized

get/webhooks
https://api.aleth.io/v1/webhooks

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{
  • "data":
    [],
  • "links":
    {
    },
  • "meta":
    {
    }
}

Get webhook details

Returns the details of a Webhook resource, identified by a given id.

header Parameters
Authorization
required
string
Example: Bearer sk_main_xxxxxxxxxxxxx

The Codefi Data API Key associated with the request

Responses

200

Webhook Details

401

Unauthorized

get/webhooks/{id}
https://api.aleth.io/v1/webhooks/{id}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Delete webhook

Deletes the webhook instance indentified by id.

Responses

200

Empty object

401

Unauthorized

403

Forbidden

delete/webhooks/{id}
https://api.aleth.io/v1/webhooks/{id}

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{ }

Pause webhook

Pauses the webhook identified by a given id. If the pause is successful, the webhook status should be changed to PAUSED_BY_USER.

header Parameters
Authorization
required
string
Example: Bearer sk_main_xxxxxxxxxxxxx

The Codefi Data API Key associated with the request

Responses

200

Webhook Details

401

Unauthorized

403

Forbidden

post/webhooks/{id}/pause
https://api.aleth.io/v1/webhooks/{id}/pause

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

Resume webhook

Resumes the webhook identified by a given id. If the resume is successful, the webhook status should be changed to RESUMED_BY_USER.

header Parameters
Authorization
required
string
Example: Bearer sk_main_xxxxxxxxxxxxx

The Codefi Data API Key associated with the request

Responses

200

Webhook Details

401

Unauthorized

403

Forbidden

post/webhooks/{id}/resume
https://api.aleth.io/v1/webhooks/{id}/resume

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{}

DeFi

The following endpoints provide current and historical analytics for the main DeFi lending protocols.

The datasets are only available for the Ethereum mainnet.

All DeFi endpoints require user authentication.

Historical metrics

Query historical protocol data for multiple protocols, metrics and assets.

The endpoint will create all possible triples (protocol, metric, asset) based on the supplied parameters. It will then exclude the triples for which there is no recorded/available data to export and it will compile a flat list of Snapshot objects for each of the remaining triples.

A Series object is serialised as:

{
    "protocol": "maker",
    "metric": "borrow_apr",
    "asset": "dai",
    "points": [
      [123456789, "8.1234"],
      ...
    ]
}

The full response payload will include a list of Series objects, and each Series object will include a list of Points. A Point is a two element tuple, representing the timestamp and the value of each measurement.

query Parameters
protocols
string <comma-separated-list>
Enum: "maker" "mcd" "compound" "dydx" "bzx" "ddex" "aave" "lendf"

A comma-separated list of protocols to be included in the query.

assets
string <comma-separated-list>
Enum: "eth" "dai" "sai" "usdc" "bat" "zrx" "rep" "wbtc" "knc" "link" "usdt" "susd" "snx" "mkr" "lend" "mana" "imbtc" "usdx" "tusd"

A comma-separated list of assets to be included in the query.

metrics
string <comma-separated-list>
Enum: "earn_apr" "borrow_apr"

A comma-separated list of metrics to be included in the query. If this parameter isn't provided, all available metrics will be included.

before
integer <unixtime>

Filter data points before a given timestamp.

after
integer <unixtime>

Filter data points after a given timestamp.

granularity
integer [ 1 .. 8760 ]
Default: 24

The aggregation window for the timeseries data points, measured in hours.

header Parameters
Authorization
required
string
Example: Bearer sk_main_xxxxxxxxxxxxx

The Codefi Data API Key associated with the request

Responses

200

History

401

Unauthorized

get/v0/defi/history
https://api.aleth.io/v0/defi/history

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{
  • "data":
    [
    ]
}

Snapshot metrics

Query the current value of the specified metrics for the given protocols and assets.

The endpoint will create all possible triples (protocol, metric, asset) based on the supplied parameters. It will then exclude the triples for which there is no recorded/available data to export and it will compile a flat list of Snapshot objects for each of the remaining triples.

A Snapshot object is serialised as:

{
    "protocol": "maker",
    "metric": "borrow_apr",
    "asset": "dai",
    "timestamp": 123456789,
    "value": "2.4356",
    "change_24h": "-4.2424"
}

The full response payload will include a list of Snapshot objects under the data property.

query Parameters
protocols
string <comma-separated-list>
Enum: "maker" "mcd" "compound" "dydx" "bzx" "ddex" "aave" "lendf"

A comma-separated list of protocols to be included in the query.

assets
string <comma-separated-list>
Enum: "eth" "dai" "sai" "usdc" "bat" "zrx" "rep" "wbtc" "knc" "link" "usdt" "susd" "snx" "mkr" "lend" "mana" "imbtc" "usdx" "tusd"

A comma-separated list of assets to be included in the query.

metrics
string <comma-separated-list>
Enum: "earn_apr" "borrow_apr"

A comma-separated list of metrics to be included in the query. If this parameter isn't provided, all available metrics will be included.

header Parameters
Authorization
required
string
Example: Bearer sk_main_xxxxxxxxxxxxx

The Codefi Data API Key associated with the request

Responses

200

Snapshot

401

Unauthorized

get/v0/defi/snapshot
https://api.aleth.io/v0/defi/snapshot

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{
  • "data":
    [
    ]
}

Protocol Stats

Query historical statistics for the given protocols, assets and metrics.

The endpoint will create all possible (protocol, asset) tuples based on the supplied parameters. It will exclude the tuples for which there is no recorded/available data to export and it will then compile a flat list of Stats objects for each of the remaining tuples.

A Stats object will include, as properties, the protocol, the asset, and the full list of metrics supplied as parameters:

{
    "protocol": "compound",
    "asset": "dai",
    "outstanding_debt": [
      [123456789, "200010.5401"],
      ...
    ],
    "collateral_ratio": [
      [123456789, "4.3175"],
      ...
    ],
    ...
}

The full response payload will include a list of Stats objects under the data property.

query Parameters
protocols
string <comma-separated-list>
Enum: "maker" "mcd" "compound" "dydx" "bzx" "ddex" "aave" "lendf"

A comma-separated list of protocols to be included in the query.

assets
string <comma-separated-list>
Enum: "eth" "dai" "sai" "usdc" "bat" "zrx" "rep" "wbtc" "knc" "link" "usdt" "susd" "snx" "mkr" "lend" "mana" "imbtc" "usdx" "tusd"

A comma-separated list of assets to be included in the query.

metrics
string <comma-separated-list>
Enum: "collateral_ratio" "outstanding_debt" "supply_volume"
before
integer <unixtime>

Filter data points before a given timestamp.

after
integer <unixtime>

Filter data points after a given timestamp.

granularity
integer [ 1 .. 8760 ]
Default: 24

The aggregation window for the timeseries data points, measured in hours.

header Parameters
Authorization
required
string
Example: Bearer sk_main_xxxxxxxxxxxxx

The Codefi Data API Key associated with the request

Responses

200

Stats

401

Unauthorized

get/v0/defi/stats
https://api.aleth.io/v0/defi/stats

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{
  • "data":
    [
    ]
}

Ether Locked

Query the total amount of ETH locked in various protocols.

The endpoint will export a EthLocked object for every protocol supplied as part of the protocols query parameter.

A EthLocked object will include the protocol name and a list of (timestamp, volume) tuples representing historical snapshots:

{
    "protocol": "compound",
    "eth_locked": [
      [1557273600, "15.3002"],
      [1557360000, "25.9002"]
      ...
    ]
}

The final response payload will include a list of EthLocked objects under the data property.

query Parameters
protocols
string <comma-separated-list>
Enum: "maker" "mcd" "compound" "dydx" "bzx" "ddex" "aave" "lendf"

A comma-separated list of protocols to be included in the query.

before
integer <unixtime>

Filter data points before a given timestamp.

after
integer <unixtime>

Filter data points after a given timestamp.

granularity
integer [ 1 .. 8760 ]
Default: 24

The aggregation window for the timeseries data points, measured in hours.

header Parameters
Authorization
required
string
Example: Bearer sk_main_xxxxxxxxxxxxx

The Codefi Data API Key associated with the request

Responses

200

EthLockedHistory

401

Unauthorized

get/v0/defi/eth-locked
https://api.aleth.io/v0/defi/eth-locked

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{
  • "data":
    [
    ]
}

Ether USD Prices

Query historical Ether prices, expressed in USD.

The response payload will include a single-element list under the data property, representing a PriceHistory object associated with the evolution of the Ether price in the timeframe specified by the query parameters.

A PriceHistory object includes the asset name (in this case "eth") and a list of (timestamp, price) tuples representing historical price snapshots:

{
    "asset": "eth",
    "prices": [
      [1513641600, "786.771"],
      [1513728000, "752.3565"]
      ...
    ]
}
query Parameters
before
integer <unixtime>

Filter data points before a given timestamp.

after
integer <unixtime>

Filter data points after a given timestamp.

granularity
integer [ 1 .. 8760 ]
Default: 24

The aggregation window for the timeseries data points, measured in hours.

header Parameters
Authorization
required
string
Example: Bearer sk_main_xxxxxxxxxxxxx

The Codefi Data API Key associated with the request

Responses

200

EthPriceHistory

401

Unauthorized

get/v0/defi/eth-prices
https://api.aleth.io/v0/defi/eth-prices

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{
  • "data":
    [
    ]
}

Token Ether Prices

Query historical Token prices, expressed in ETH. The prices are sourced from on-chain oracles that are and have been historically used by the lending protocols we're supporting.

The endpoint will export a PriceHistory object for every token supplied as part of the assets query parameter.

A PriceHistory object will include the asset name and a list of (timestamp, price) tuples representing historical price snapshots:

{
    "asset": "dai",
    "prices": [
      [1581724800, "0.0035"],
      [1581811200, "0.0038"]
      ...
    ]
}

The final response payload will include a list of PriceHistory objects under the data property.

query Parameters
assets
string <comma-separated-list>
Enum: "eth" "dai" "sai" "usdc" "bat" "zrx" "rep" "wbtc" "knc" "link" "usdt" "susd" "snx" "mkr" "lend" "mana" "imbtc" "usdx" "tusd"

A comma-separated list of assets to be included in the query.

before
integer <unixtime>

Filter data points before a given timestamp.

after
integer <unixtime>

Filter data points after a given timestamp.

granularity
integer [ 1 .. 8760 ]
Default: 24

The aggregation window for the timeseries data points, measured in hours.

header Parameters
Authorization
required
string
Example: Bearer sk_main_xxxxxxxxxxxxx

The Codefi Data API Key associated with the request

Responses

200

TokenPriceHistory

401

Unauthorized

get/v0/defi/token-prices
https://api.aleth.io/v0/defi/token-prices

Response samples

Content type
application/vnd.api+json
Copy
Expand all Collapse all
{
  • "data":
    [
    ]
}