-
Notifications
You must be signed in to change notification settings - Fork 7
[Deprecated] API Documentation
Getting Started
Installation
Usage
Web3data-js API
Web3data
Blockchains
.blockchains()
.blockchains(blockchainId/slug)
Addresses
.Address(hash)
.addresses()
.addresses(hash)
.info()
.stats()
.transactions()
.transactions(txhash)
.logs()
.logs(logHash)
.messages()
.messages(messageHash)
.tokens()
.tokens(tokenHash)
Modifiers
Filters
.filter(filterOptions)
Pagination
.limit(n)
.offset(index)
.orderBy(fieldName)
.direction(dir)
Websockets
.websockets()
.websockets(options)
npm install web3data
yarn add web3data
<script src=".../web3data.min.js"></script>
bower install web3data
Web3data(configObject)
The web3data
object provides all methods.
-
configObject
| Type:Object
- An object that contains configurations options-
apiKey
| Type:String
- Authorized api key, user based -
blockchainId
| Type:Object
- The blockchain id referencing the blockchain with which the user wishes to interact
-
-
Web3data
instance
import Web3data from 'web3data-js'
let config = {
'apiKey': 't_42e84016b2f18a5a40592292843cb4de',
'blockchainId': '1c9c969065fcd1cf ' // or 'slug': 'ethereum-mainnet'
}
const web3data = new Web3data(config)
web3data.blockchains()
- None
- Type:
Array
- An array containing a list of currently indexed blockchain data objects.
let blockchains = web3data.blockchains()
console.log(blockchains)
/* --- Returns --- */
[
{
"blockchainId": "k9j7d...",
"config": {...},
.
.
.
},
{...},
{...}
]
web3data.blockchains(blockchainId /* or slug */)
-
blockchainId
| Type:String
- The perdetermined ID corresponding to a blockchain and network or -
slug
| Type:String
- The human readable name corresponding to a blockchain and network
- Type:
Object
- An object containing data pertaining to the specified blockchain:-
blockchainId
| Type:String
- The predetermined ID corresponding to a blockchain and network -
config
-
icon
| Type:String
- The URL of the blockchain's logo -
color
| Type:String
- The hex value referring to the blockchain's primary brand color -
website
| Type:String
- The URL of the blockchain's main website -
decimals
| Type:Int
- The number of significant digits, per smart contract definition -
unit
| Type:String
- The name of the smallest denomination of a token -
utility
| Type:String
- The name of the unit of computation, based proof of work systems -
token
| Type:String
- The name of the payment medium of a network -
ethAddress
| Type:String
- The address of the smart contract on Ethereum that is used for inter-chain communication
-
-
consensus
| Type:String
- The type of consensus mechanism employed by the network // TODO: List possible values -
name
| Type:String
- The name of the blockchain -
network
| Type:String
- The name of the network within the given blockchain -
type
| Type:String
- The type of network. Ex. production:mainnet
vs development:testnet
-
slug
| Type:String
- The human readable name corresponding to a blockchain and network -
admin
| Type:String
- Returns true if thex-amberdata-api-key
is the owner of the blockchain
-
let blockchains = web3data.blockchains("1c9c969065fcd1cf" /*Ethereum Mainnet id*/)
console.log(blockchains)
/* --- Returns --- */
{
"blockchainId": "1c9c969065fcd1cf",
"config": {
"icon": "https://s3.us-east-2.amazonaws.com/amberdata-public/images/ethereum_logo_mainnet.svg",
"color": "#222222",
"website": "https://ethereum.org/",
"decimals": 18,
"unit": "wei",
"utility": "gas",
"token": "Ether",
"ethAddress": ""
},
"consensus": "PoW",
"name": "Ethereum",
"network": "Mainnet",
"type": "mainnet",
"slug": "ethereum-mainnet",
"admin": false
}
Methods to retrieve address statistics and general information.
web3data.Address(hash)
Constructs an address object. Provided to allow reuse when working with a frequently used address. For instance, a contract address used by a dApp.
- None
-
hash
| Type:String
- The address hash
- Type:
Object
- An address object
let address = new web3data.Address("0x407d73d...")
// All method calls a 'address' will pertain to the previously specfied address
let transactions = address.transactions()
let info = address.info()
// etc...
web3data.addresses()
Retrieves paginated list of addresses in a blockchain.
- None
- None
- Type:
Array
- An array of address objects
let addresses = web3data.addresses()
console.log(addresses)
web3data.addresses(hash)
Retrieves data pertaining to the specified address (invokes .info()
under the hood). Can be chained with other methods as shown below.
-
hash
| Type:String
- The address hash
- Type:
Object
- An object containing data pertaining to the specified address.
let addresses = web3data.addresses("0x407d73d...")
console.log(addresses)
/* --- Returns --- */
// Result of addresses("0x407d73d...").info()
web3data.addresses(hash).info()
Provides information pertaining to the specified address.
- None
- None
- Type:
Array
- An array containing information about the specified address organised by blockchain and network, ordered by likelihood of accuracy (most probable first and least probable last).-
type
| Type:String
- The type of account:address
orcontract
. -
contractTypes
| Type:Array
- An array ofStrings
corresponding to the type of contract interface/standard. -
firstSeen
| Type:String
- The ISO Formatted date of when the address made its first public appearance. -
network
| Type:Object
- An object containing network specific data-
name
| Type:String
- The name of the network -
slug
| Type:String
- The human readable name corresponding to a blockchain and network -
blockchainId
| Type:String
- The predetermined ID corresponding to a blockchain and network -
link
| Type:String
- Link to address details page
-
-
let addressInfo = web3data.addresses("0x407d73d...").info()
console.log(addressInfo)
// or
let address = new web3data.Address("0x407d73d...")
console.log(address.info())
/* --- Returns --- */
[
{
// Address/Account spec
type: 'address',
contractTypes: ['ERC20', 'ERC721'],
firstSeen: "2018-01-09T07:02:49.000Z",
network: {
name: 'testnet',
slug: 'fake-testnet',
blockchainId: '40592292843cb4de',
link: 'https://fake-testnet.amberdata.io/addresses/:hash',
}
},
{
type: 'address',
contractTypes: ['Token'],
firstSeen: "2018-01-09T07:02:49.000Z",
network: {
name: 'testnet2',
slug: 'fake-testnet2',
blockchainId: '123abc456def789',
link: 'https://fake-testnet2.amberdata.io/addresses/:hash',
}
}
]
web3data.address(hash).stats()
Provides key insights into history, operations & metrics of an address
- None
- None
- Type:
Object
- An object containing key insights into history, operations & metrics of the specified address-
balance
| Type:String
- The current balance of the address -
balanceIn
| Type:String
- The balance that has been transferred into the address -
balanceOut
| Type:String
- The balance that has been transferred out of the address -
decimals
| Type:Int
- The number of significant digits, per smart contract definition -
name
* | Type:String
- Name of the contract -
numHolders
* | Type:Int
- The total amount of unique addresses -
numTransfers
| Type:Int
- The total amount of unique transfers where any type of transaction has occurred -
symbol
* | Type:String
- The token symbol -
totalSupply
* | Type:String
- Total number of tokens in circulation -
totalValueUSD
* | Type:String
- Total value of all tokens -
unitValueUSD
* | Type:String
- The value of the token in USD
-
*specific to contract addresses
let addressStats = web3data.addresses("0x407d73d...").stats()
console.log(addressStats)
// or
let address = new web3data.Address("0x407d73d...")
console.log(address.stats())
/* --- Returns --- */
{
balance: '1392408324.943209090',
balanceIn: '1392408324.943209090',
balanceOut: '0',
decimals: 18,
name: "0x Protocol Token"
numHolders: 654,
numTransfers: 489241,
symbol: 'ZRX',
totalSupply: '1000000000.0000000000000000',
totalValueUSD: '881363131.50000000000000000000000000',
unitValueUSD: '0.8813631315',
}
web3data.addresses(hash).transactions()
Retrieves a list of all transactions pertaining to the specified address.
filter
pagination
- None
- Type:
Array
- An array of transaction objects
let allTransactions = web3data.addresses("0x407d73d...").transactions()
console.log(allTransactions)
// or
let address = new web3data.Address("0x407d73d...")
console.log(address.transactions())
/* --- Returns --- */
{
`totalRecords': 2132,
'records': [
{
'blockNumber': '6124274',
.
.
'amount': {...}
},
{...},
{...},
.
.
{...}
]
}
web3data.addresses(hash).transactions(txhash)
Retrieves data pertaining to the specified transaction hash.
-
txhash
| Type:String
- The transaction hash
- Type:
Object
- An object containing data pertaining to the specified transaction-
blockNumber
| TypeString
- The blocknumber of the block which contains the specified transaction. -
index
| TypeInt
- The index of the transaction within the block -
hash
| TypeString
- The transaction hash -
timestamp
| TypeString
- The time of when the transaction was confirmed -
value
| TypeString
- The blockchain value -
from
| TypeString
- The address hash of the sender -
to
| TypeString
- The address hash of the recipient -
gasLimit
| TypeInt
- An object containing details about the gas price of the transaction-
type
| TypeString
- -
unit
| TypeString
- -
value
| TypeString
-
-
-
gasPrice
| TypeObject
- An object containing details about the gas price of the transaction-
type
| TypeString
- -
unit
| TypeString
- -
value
| TypeString
-
-
-
gasUsed
| TypeObject
- An object containing details about the gas used in the transaction-
type
| TypeString
- -
unit
| TypeString
- -
value
| TypeString
-
-
-
confirmations
| TypeString
- The number of confirmations on the block in which this transaction resides -
fee
| TypeObject
- An object containing details about the transaction fee-
type
| TypeString
- -
unit
| TypeString
- -
value
| TypeString
- The transaction fee amount
-
-
miner
| TypeString
- The address hash of the miner who mined the block in which this transaction resides-
inputSize
| TypeInt
- The size in bytes of the input data -
nonce
| TypeInt
- The number of transactions sent from an address (this is typically used to prevent double spending for example)
-
-
let singleTransaction = web3data.addresses("0x407d73d...").transactions("0xe9b36f1...")
console.log(singleTransaction)
// or
let address = new web3data.Address("0x407d73d...")
console.log(address.transactions("0xe9b36f1..."))
/* --- Returns --- */
{
"blockNumber": "6124274",
"index": 28,
"hash": "0xe7be36f174503d8bc40839ca55502b2a27f9aa7ac2bd02da57d3aa408cd51b4b",
"timestamp": "2018-08-10T20:19:25.000Z",
"value": "0",
"from": "0x40120b5a5994f7e3afe3c0a3dc56d1ccb0b75262",
"to": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"gasLimit": {
"type": "metric",
"unit": "k",
"value": "74.34"
},
"gasPrice": {
"type": "wei",
"unit": "Gwei",
"value": "20"
},
"gasUsed": {
"type": "metric",
"unit": "k",
"value": "22.17"
},
"confirmations": "8",
"fee": {
"type": "wei",
"unit": "ether",
"value": "0.0004434"
},
"miner": "0xea674fdde714fd979de3edf0f56aa9716b898ec8",
}
web3data.addresses(hash).logs()
filter
pagination
- None
- Type:
Object
- An object contain log information about the specified address.-
totalRecords
| TypeInt
- The total number of log records -
records
| TypeArray
- An array containing a list of log objects. (See below)
-
let addressLogs = web3data.addresses("0x407d73d...").logs()
console.log(addressLogs)
// or
let address = new web3data.Address("0x407d73d...")
console.log(address.logs())
/* --- Returns --- */
{
"totalRecords": 5,
"records": [
{...},
{...},
.
.
{...}
]
}
web3data.addresses(hash).logs(logHash)
-
logHash
| Type:String
- The hash of the log
- Type:
Object
- An object contain log information about the specified address.-
LogIndex
| TypeInt
- The index of the log -
address
| TypeString
- The address that the log is associated with -
data
| TypeArray
- The arguments of the function call -
topics
| TypeArray
- The indexed argument names -
name
| TypeString
- The name of the event
-
let addressLog = web3data.addresses("0x407d73d...").logs("0x6f8f73...")
console.log(addressLog)
// or
let address = new web3data.Address("0x407d73d...")
console.log(address.logs("0x6f8f73..."))
/* --- Returns --- */
{
"logIndex": 8,
"address": "0xdd9fd6b6f8f7ea932997992bbe67eabb3e316f3c",
"data": ["67c026...", "79646d...", ..."2dab3f..."],
"topics": ["0x8f36...", "0x0000..."],
"name": null
},
web3data.addresses(hash).messages()
filter
pagination
- None
- Type:
Object
- An object containing messages corresponding to the specified address-
totalRecords
| TypeInt
- The total number of messages -
records
| TypeArray
- An array containing a list of message objects (see below).
-
let messages = web3data.addresses("0x407d73d...").messages()
console.log(messages)
// or
let address = new web3data.Address("0x407d73d...")
console.log(address.messages())
/* --- Returns --- */
{
"totalRecords": 5,
"records": [
{...},
{...},
.
.
{...}
]
}
web3data.addresses(hash).messages(messageHash)
-
messageHash
| Type:String
The has of the message
- Type:
Object
- An object containing details about a message-
initialGas
| Type:String
- The gas before the message (transaction) is sent -
leftOverGas
| Type:String
- The gas after the message (transaction) is sent -
from
| Type:String
- The address hash of the message sender -
to
| Type:String
- The address hash of the message recipient -
value
| Type:String
- The data associated with the message -
depth
| Type:Int
- The call stack depth of messages -
opcode
| Type:String
- The name of opcode -
error
| Type:String
- The error message if applicable. Empty if no error message. -
messageIndex
| Type:Int
-
-
let message = web3data.addresses("0x407d73d...").messages("0xe9b36f1...")
console.log(message)
// or
let address = new web3data.Address("0x407d73d...")
console.log(address.messages("0xe9b36f1..."))
/* --- Returns --- */
{
"initialGas": "98065",
"leftOverGas": "39992",
"from": "0xc35a5fe...",
"to": "0x06012c...",
"value": "8000000000000000",
"depth": 0,
"opcode": "CALL",
"error": "",
"messageIndex": 0
}
web3data.addresses(hash).tokens()
filter
pagination
- None
- Type:
Object
- An object contain messages corresponding to the specified address-
totalBalance
| TypeString
- The summation of the token unit values -
records
| TypeArray
- An array containing a list of token objects which details tokens owned by the specified address (see below).
-
/* --- Returns --- */
{
"totalBalance": 334.80467768332375,
"records": [
{...},
{...},
.
.
{...}
]
}
web3data.addresses(hash).tokens(tokenHash)
-
tokenHash
| Type:String
- (Conf) The address hash of the token
- Type:
Object
- An object containing details about a token owned by the specified address-
address
| Type:String
- (Conf) The address hash of the token -
name
| Type:String
- The token name -
symbol
| Type:String
- The token symbol -
totalSupply
| Type:String
- Total number of tokens in circulation -
unitValue
| Type:String
- -
totalValue
| Type:String
-
-
/* --- Returns --- */
{
"address": "0x08f5a9...",
"name": "Tierion Network Token",
"symbol": "TNT",
"totalSupply": "14864.2730000000000000",
"unitValue": "0.0225241206",
"totalValue": "334.80467768332380000000000000"
}
web3data.address(hash).transactions().filter(filterOptions)
-
filterOptions
| Type:Object
- An object containing desired filter options-
status
| Type:String
- (what does this apply to? transactions doesn't havestatus
field) -
dateStart
| Type:String
- ISO Formatted date -
dateEnd
| Type:String
- ISO Formatted date -
from
| Type:String
- The address hash of the sender -
to
| Type:String
- The address hash of the recipient -
blockNumber
| Type:Int
- The blocknumber
-
- Type:
Object
-
let filter = {
'status':'',
'dateStart':'',
'dateEnd':'',
'from':'',
'to':'',
'blockNumber':'',
}
let transactions = web3data.addresses("0x407d73d...").transactions().filter(filter)
console.log(transactions)
/* --- Returns --- */
/* TODO: Fill in
web3data.address(hash).transactions().limit(n)
-
n
| Type:Int
- Number of results per page
- Type:
Array
- An array containingn
results. (Is there a page number?)
/* --- Returns --- */
/* TODO: Fill in */
web3data.address(hash).transactions().offset(index)
Used to retrieve a single page from the list of pages returned by .limit(n)
.
-
index
| Type:Int
- Index of the page to display. . Required:index
<n
(totla pages)
- Type:
Array
- An array containing the results of the query
/* --- Returns --- */
/* TODO: Fill in */
web3data.address(hash).transactions().orderBy(fieldName)
Order the returned results by the specified field.
Note: Currently, only the default value is supported.
-
fieldName
| Type:String
the name of the field by which to order (default value:timestamp
)*
- Type:
Array
- An array containing the results of the query
/* --- Returns --- */
/* TODO: Fill in */
web3data.address(hash).transactions().direction(dir)
The direction of which to order the results of query.
-
dir
| Type:String
- The direction with which to order the results. Accepted values:asc
,desc
.
- Type:
Array
- An array containing the results of the query
/* --- Returns --- */
/* TODO: Fill in */
let socket = new web3data.websocket(configObj)
socket.connect(callback/asyc await) // returns erros / connection status
socket.on(eventName, function(payload))
socket.off
socket.close
- None
- Type:
Object
-
/* --- Returns --- */
/* TODO: Fill in