Skip to main content

Aptos API Documentation

Dora Factory offers a set of Aptos APIs for hackers, developers, and teams working on Aptos native applications. More APIs will be added over time.

Aptos Grant DAO BUIDL teams will have access to unlimited free APIs for 45 days.

To apply for the free 45-day use of the Aptos API, please fill in the application form at https://forms.gle/qGdvu5P5PUdJntVB9 Our staff will send the API Token Key via email. Please make sure the registered email address is valid.

Aptos Mainnet Api server

  • Http: https://aptos.dorafactory.org/mainnet-api/
  • WebSocket: wss://aptos.dorafactory.org/mainnet-ws/

General Instructions

Our Aptos API service is built on the TSRPC framework.

  • Request method is POST.
  • All requests need to submit a token in order to verify identity.
  • All requests need to include the following Header :
    • Content-Type: application/json

Preface

If you want to use typescript to implement client to call APIs, please configure first.

  1. Install tsrpc
yarn add tsrpc
  1. Download serviceProto file to local.

Download serviceProto

Copy this file to the project folder and extract them.

tar -zxvf service_protocols.tar.gz

TSRPC automatically parses the TypeScript source code into the format required by the runtime type system -- ServiceProto, which is also the first parameter you pass when creating a TSRPC client instance.

  1. After decompression, the serviceProto file will appear and the client needs to import this file.
import { serviceProto } from '../shared/protocols/serviceProto';
  1. Make a client call
import { HttpClient } from 'tsrpc';
import { serviceProto } from '../shared/protocols/serviceProto'; // import serviceProto

// Create the Client
let client = new HttpClient(serviceProto, {
server: 'https://aptos.dorafactory.org/mainnet-api/', // our api url
logger: console
});

async function main() {
// callApi
let ret = await client.callApi('coin/coin_info/GetCoinInfo', {
coin_type_hash: "91ceb1308a98389691e05158b07ed5f079ab78461a6bb8d5a4054b1bb5cb8bb6",
token: "203db03b-1880-4926-b0a3-9937521a1386"
});
if (ret.res != undefined) {
console.log(ret.res.coinInfos)
}
// Error
if (!ret.isSucc) {
return;
}
}
main()

More about TSRPC: https://tsrpc.cn/

And you can also make API calls from other programming languages based on requests using http or websocket.

Catalog


blockchain

event

ListenEventsByAddress

Events listening service by account address.

Path

  • POST /blockchain/event/ListenEvents

Request

interface ReqListenEventsByAddress {
account_address: string,
startVersion?: string,
endVersion?: string,
offset?: number,
limit?: number,
token: string
}

Response

interface ResListenEventsByAddress {
events: {
sequence_number: string,
creation_number: string,
account_address: string,
transaction_version: string,
transaction_block_height: string,
type: string,
data: string,
inserted_at: /*datetime*/ string
}[],
total: number
}

Client Demo

import { WsClient } from 'tsrpc';
import { serviceProto } from '../shared/protocols/serviceProto';

const main = async () => {
// Create Client
let client = new WsClient(serviceProto, {
server: 'wss://aptos.dorafactory.org/mainnet-ws/',
logger: console
});
// Connect
await client.connect().then(res=>{
if(!res.isSucc){
console.log(res.errMsg);
}
})

let ret = await client.callApi('blockchain/event/ListenEvents', {
account_address: "0x7865f4682eefa75b360b6c426a1f73de8261749d472ad71ba2f88a2e31ebf096",
startVersion: "1",
limit: 20,
token: "5ba58ba8-49f2-43e8-856a-8bc503ad0ed2"
});

let handle = client.listenMsg('blockchain/events/ListenEventsBy', msg => {
console.log(msg)
});

// await client.disconnect();
}

main()

ListenLatestOneByAddress

Event listening service, which only returns the latest event information for account_address.

Path

  • POST /blockchain/event/ListenLatestOneByAddress

Request

interface ReqListenLatestOneByAddress {
account_address: string,
token: string
}

Response

interface ResListenLatestOneByAddress {
sequence_number: string,
creation_number: string,
account_address: string,
transaction_version: string,
transaction_block_height: string,
type: string,
data: string,
inserted_at: /*datetime*/ string
}

Client Demo

import { WsClient } from 'tsrpc';
import { serviceProto } from '../shared/protocols/serviceProto';

const main = async () => {
// Create Connect
let client = new WsClient(serviceProto, {
server: 'wss://aptos.dorafactory.org/mainnet-ws/',
logger: console
});
// Connect
await client.connect().then(res=>{
if(!res.isSucc){
console.log(res.errMsg);
}
})

let ret = await client.callApi('blockchain/event/ListenLatestOneByAddress', {
account_address: "0x7865f4682eefa75b360b6c426a1f73de8261749d472ad71ba2f88a2e31ebf096",
token: "5ba58ba8-49f2-43e8-856a-8bc503ad0ed2"
});
console.log(ret)
let handle = client.listenMsg('blockchain/event/ListenLatestOneByAddress', msg => {
console.log(msg);
});

// await client.disconnect();
}

main()

move_resource

ListenResourcesByAddress

Resources listening service by account address.

Path

  • POST /blockchain/move_resource/ListenResourcesByAddress

Request

interface ReqListenResourcesByAddress {
address: string,
module?: string,
name?: string,
startVersion?: string,
endVersion?: string,
offset?: number,
limit?: number,
token: string
}

Response

interface ResListenResourcesByAddress {
resources: {
transaction_version: string,
write_set_change_index: string,
transaction_block_height: string,
name: string,
address: string,
type: string,
module: string,
generic_type_params: string,
data: string,
inserted_at: /*datetime*/ string
}[],
total: number
}

Client Demo

import { WsClient } from 'tsrpc';
import { serviceProto } from '../shared/protocols/serviceProto';

export const main = async (token: string) => {
// Create Client
let client = new WsClient(serviceProto, {
server: 'wss://aptos.dorafactory.org/mainnet-ws/',
logger: console
});
// Connect
await client.connect().then(res=>{
if(!res.isSucc){
console.log(res.errMsg);
}
})

let ret = await client.callApi('blockchain/move_resource/ListenResourcesByAddress', {
address: "0x1066cd66f48841107052acc6050532e890d5d1bfb39029dbb80df71a96d6b2d1",
token: "203db03b-1880-4926-b0a3-9937521a1386"
});

let handle = client.listenMsg('blockchain/move_resource/ListenResourcesByAddress', msg => {
console.log(msg)
});

await client.disconnect();
}
main()

coin

coin_info

GetCoinInfo

Returns the corresponding coin information according to coin_type_hash

Path

  • POST /coin/coin_info/GetCoinInfo

Request

interface ReqGetCoinInfo {
coin_type_hash: string,
token: string
}

Response

interface ResGetCoinInfo {
coinInfo: {
coin_type_hash: string,
coin_type: string,
transaction_version_created: string,
creator_address: string,
name: string,
symbol: string,
decimals: number,
transaction_created_timestamp: /*datetime*/ string,
inserted_at: /*datetime*/ string,
supply_aggregator_table_handle: string,
supply_aggregator_table_key: string
}
}

Client Demo

import { HttpClient } from 'tsrpc';
import { serviceProto } from '../shared/protocols/serviceProto';

// Create the Client
let client = new HttpClient(serviceProto, {
server: 'https://aptos.dorafactory.org/mainnet-api/',
logger: console
});

async function main() {
// callApi
let ret = await client.callApi('coin/coin_info/GetCoinInfo', {
coin_type_hash: "91ceb1308a98389691e05158b07ed5f079ab78461a6bb8d5a4054b1bb5cb8bb6",
token: "203db03b-1880-4926-b0a3-9937521a1386"
});
if (ret.res != undefined) {
console.log(ret.res.coinInfos)
}
// Error
if (!ret.isSucc) {
return;
}
}
main()

ListCoinInfo

List all coin information.

Path

  • POST /coin/coin_info/ListCoinInfo

Request

interface ReqListCoinInfo {
token: string
}

Response

interface ResListCoinInfo {
coinInfos: {
coin_type_hash: string,
coin_type: string,
transaction_version_created: string,
creator_address: string,
name: string,
symbol: string,
decimals: number,
transaction_created_timestamp: /*datetime*/ string,
inserted_at: /*datetime*/ string,
supply_aggregator_table_handle: string,
supply_aggregator_table_key: string
}[],
total: number
}

Client Demo

import { HttpClient } from 'tsrpc';
import { serviceProto } from '../shared/protocols/serviceProto';

// Create the Client
let client = new HttpClient(serviceProto, {
server: 'https://aptos.dorafactory.org/mainnet-api/',
logger: console
});


async function main() {
// callApi
let ret = await client.callApi('coin/coin_info/ListCoinInfo', {
token: "5ba58ba8-49f2-43e8-856a-8bc503ad0ed2"
});
if (ret.res != undefined) {
ret.res.coinInfos.map((coininfo) => {
console.log(coininfo)
})
}
// Error
if (!ret.isSucc) {
return;
}

}
main()

current_coin_balance

GetCurrentBalanceByAddress

Get the coin balance of your account.

Path

  • POST /coin/current_coin_balance/GetCurrentBalanceByAddress

Request

interface ReqGetCurrentBalanceByAddress {
owner_address: string,
coin_type_hash: string,
token: string
}

Response

interface ResGetCurrentBalanceByAddress {
currentCoin: {
owner_address: string,
coin_type_hash: string,
coin_type: string,
amount: string,
last_transaction_version: string,
last_transaction_timestamp: /*datetime*/ string,
inserted_at: /*datetime*/ string
}
}

Client Demo

import { HttpClient } from 'tsrpc';
import { serviceProto } from '../shared/protocols/serviceProto';

// Create the Client
let client = new HttpClient(serviceProto, {
server: 'https://aptos.dorafactory.org/mainnet-api/',
logger: console
});

async function main() {
// callApi
let ret = await client.callApi('coin/current_coin_balance/GetCurrentBalanceByAddress', {
owner_address: "0xc610048001bfb3391b4ddf4b3d9748b148ef6635814362e5a335f9a4f76625a0",
coin_type_hash: "91ceb1308a98389691e05158b07ed5f079ab78461a6bb8d5a4054b1bb5cb8bb6",
token: "203db03b-1880-4926-b0a3-9937521a1386"
});

if (ret.res != undefined) {
console.log(ret.res)
}
// Error
if (!ret.isSucc) {
return;
}

}
main()

ListCurrentBalanceByAddress

Get information about all coins owned by owner_address.

Path

  • POST /coin/current_coin_balance/ListCurrentBalanceByAddress

Request

interface ReqListCurrentBalanceByAddress {
owner_address: string,
token: string
}

Response

interface ResListCurrentBalanceByAddress {
currentCoins: {
owner_address: string,
coin_type_hash: string,
coin_type: string,
amount: string,
last_transaction_version: string,
last_transaction_timestamp: /*datetime*/ string,
inserted_at: /*datetime*/ string
}[],
total: number
}

Client Demo

import { HttpClient } from 'tsrpc';
import { serviceProto } from '../shared/protocols/serviceProto';

// Create the Client
let client = new HttpClient(serviceProto, {
server: 'https://aptos.dorafactory.org/mainnet-api/',
logger: console
});

async function main() {
// callApi
let ret = await client.callApi('coin/current_coin_balance/ListCurrentBalanceByAddress', {
owner_address: "0x1c1635c05968d9715e5e5cfad10567bba6a63cbfb3280c2777a2bbbcd8194e1a",
token: "203db03b-1880-4926-b0a3-9937521a1386"
});
if (ret.res != undefined) {
console.log(ret.res)
}
// Error
if (!ret.isSucc) {
return;
}

}
main()

ListCurrentCoin

Returns the corresponding current_coin information based on coin_type_hash, which allows you to query all holders of a certain coin in this way.

Path

  • POST /coin/current_coin_balance/ListCurrentCoin

Request

interface ReqListCurrentCoin {
coin_type_hash: string,
offset?: number,
limit?: number,
token: string
}

Response

interface ResListCurrentCoin {
currentCoins: {
owner_address: string,
coin_type_hash: string,
coin_type: string,
amount: string,
last_transaction_version: string,
last_transaction_timestamp: /*datetime*/ string,
inserted_at: /*datetime*/ string
}[],
total: number
}

Client Demo

import { HttpClient } from 'tsrpc';
import { serviceProto } from '../shared/protocols/serviceProto';

// Create the Client
let client = new HttpClient(serviceProto, {
server: 'https://aptos.dorafactory.org/mainnet-api/',
logger: console
});

async function main() {
// callApi
let ret = await client.callApi('coin/current_coin_balance/ListCurrentCoin', {
coin_type_hash: "91ceb1308a98389691e05158b07ed5f079ab78461a6bb8d5a4054b1bb5cb8bb6",
limit: 3,
token: "203db03b-1880-4926-b0a3-9937521a1386"
});
if (ret.res != undefined) {
console.log(ret.res)
}
// Error
if (!ret.isSucc) {
return;
}
}
main()

token

collection_data

GetCollectionDetailById

Get the corresponding collection data information based on collection_data_id_hash.

Path

  • POST /token/collection_data/GetCollectionDetailById

Request

interface ReqGetCollectionDetailById {
collection_data_id_hash: string,
transaction_version?: string,
token: string
}

Response

interface ResGetCollectionDetailById {
collectionData: {
collection_data_id_hash: string,
transaction_version: string,
creator_address: string,
collection_name: string,
description: string,
metadata_uri: string,
supply: string,
maximum: string,
maximum_mutable: boolean,
uri_mutable: boolean,
description_mutable: boolean,
inserted_at: /*datetime*/ string,
table_handle: string,
transaction_timestamp: /*datetime*/ string
}
}

Client Demo

import { HttpClient } from 'tsrpc';
import { serviceProto } from '../shared/protocols/serviceProto';

// Create the Client
let client = new HttpClient(serviceProto, {
server: 'https://aptos.dorafactory.org/mainnet-api/',
logger: console
});

async function main() {
// callApi
let ret = await client.callApi('token/collection_data/GetCollectionDetailById', {
collection_data_id_hash: "fb648e574d632589a2f026d8341ca0c95a7c3f8cb9ec6b8c82f76755a0d37afb",
token: "203db03b-1880-4926-b0a3-9937521a1386"
});
if (ret.res != undefined) {
console.log(ret.res)
}
// Error
if (!ret.isSucc) {
return;
}
}
main()

current_token_ownership

GetCurrentTokenById

Query the owner of a current_token.

Path

  • POST /token/current_token_ownership/GetCurrentTokenById

Request

interface ReqGetCurrentTokenById {
token_data_id_hash: string,
last_transaction_version?: string,
token: string
}

Response

interface ResGetCurrentTokenById {
currentToken: {
token_data_id_hash: string,
property_version: string,
owner_address: string,
creator_address: string,
collection_name: string,
name: string,
amount: string,
token_properties: string,
last_transaction_version: string,
inserted_at: /*datetime*/ string,
collection_data_id_hash: string,
table_type: string,
last_transaction_timestamp: /*datetime*/ string
}
}

Client Demo

import { HttpClient } from 'tsrpc';
import { serviceProto } from '../shared/protocols/serviceProto';

// Create the Client
let client = new HttpClient(serviceProto, {
server: 'https://aptos.dorafactory.org/mainnet-api/',
logger: console
});

async function main() {
// callApi
let ret = await client.callApi('token/current_token_ownership/GetCurrentTokenById', {
token_data_id_hash: "77482d3a8adda7a1827a42e59824cc231884541d8fbfa3e9c24dae9be0c40190",
token: "203db03b-1880-4926-b0a3-9937521a1386"
});
if (ret.res != undefined) {
console.log(ret.res)
}
// Error
if (!ret.isSucc) {
return;
}
}
main()

ListCurrentToken

Query the relevant current_tokens according to creator_address / collections_name, you can use this way to count the relevant holder information.

tips: creator_address and collections_name cannot both be empty.

Path

  • POST /token/current_token_ownership/ListCurrentToken

Request

interface ReqListCurrentToken {
creator_address?: string,
collections_name?: string,
offset?: number,
limit?: number,
token: string
}

Response

interface ResListCurrentToken {
currentTokens: {
token_data_id_hash: string,
property_version: string,
owner_address: string,
creator_address: string,
collection_name: string,
name: string,
amount: string,
token_properties: string,
last_transaction_version: string,
inserted_at: /*datetime*/ string,
collection_data_id_hash: string,
table_type: string,
last_transaction_timestamp: /*datetime*/ string
}[],
total: number
}

Client Demo

import { HttpClient } from 'tsrpc';
import { serviceProto } from '../shared/protocols/serviceProto';

// Create the Client
let client = new HttpClient(serviceProto, {
server: 'https://aptos.dorafactory.org/mainnet-api/',
logger: console
});

async function main() {
// callApi
let ret = await client.callApi('token/current_token_ownership/ListCurrentToken', {
creator_address: "0x3488a32e97334466be5a7977207e4eba513dda8730364878a670db6c1354d567",
token: "203db03b-1880-4926-b0a3-9937521a1386"
});
if (ret.res != undefined) {
console.log(ret.res)
}
// Error
if (!ret.isSucc) {
return;
}
}
main()

ListCurrentTokenByAddress

Get the current_token information under a user.

Path

  • POST /token/current_token_ownership/ListCurrentTokenByAddress

Request

interface ReqListCurrentTokenByAddress {
owner_address: string,
offset?: number,
limit?: number,
token: string
}

Response

interface ResListCurrentTokenByAddress {
currentTokens: {
token_data_id_hash: string,
property_version: string,
owner_address: string,
creator_address: string,
collection_name: string,
name: string,
amount: string,
token_properties: string,
last_transaction_version: string,
inserted_at: /*datetime*/ string,
collection_data_id_hash: string,
table_type: string,
last_transaction_timestamp: /*datetime*/ string
}[],
total: number
}

Client Demo

import { HttpClient } from 'tsrpc';
import { serviceProto } from '../shared/protocols/serviceProto';

// Create the Client
let client = new HttpClient(serviceProto, {
server: 'https://aptos.dorafactory.org/mainnet-api/',
logger: console
});

async function main() {
// callApi
let ret = await client.callApi('token/current_token_ownership/ListCurrentTokenByAddress', {
owner_address: "0x3ca30f13c0392e7ae03ab48b560595454805925b1bc23e47157bb8232633021b",
token: "203db03b-1880-4926-b0a3-9937521a1386"
});
if (ret.res != undefined) {
console.log(ret.res)
}
// Error
if (!ret.isSucc) {
return;
}
}
main()

token_data

GetTokenDetailById

Get the corresponding token_data based on token_data_id_hash.

Path

  • POST /token/token_data/GetTokenDetailById

Request

interface ReqGetTokenDetailById {
token_data_id_hash: string,
transaction_version?: string,
token: string
}

Response

interface ResGetTokenDetailById {
tokenData: {
token_data_id_hash: string,
transaction_version: string,
creator_address: string,
collection_name: string,
name: string,
maximum: string,
supply: string,
largest_property_version: string,
metadata_uri: string,
payee_address: string,
royalty_points_numerator: string,
royalty_points_denominator: string,
maximum_mutable: boolean,
uri_mutable: boolean,
description_mutable: boolean,
properties_mutable: boolean,
royalty_mutable: boolean,
default_properties: string,
inserted_at: /*datetime*/ string,
collection_data_id_hash: string,
transaction_timestamp: /*datetime*/ string,
description: string
}
}

Client Demo

import { HttpClient } from 'tsrpc';
import { serviceProto } from '../shared/protocols/serviceProto';

// Create the Client
let client = new HttpClient(serviceProto, {
server: 'https://aptos.dorafactory.org/mainnet-api/',
logger: console
});

async function main() {
// callApi
let ret = await client.callApi('token/token_data/GetTokenDetailById', {
token_data_id_hash: "7f7b7e3e8f12ef925b8feb0016f4ec51db9cbc4c4e779edccf7de63a1b38b1f8",
token: "203db03b-1880-4926-b0a3-9937521a1386"
});
if (ret.res != undefined) {
console.log(ret.res)
}
// Error
if (!ret.isSucc) {
return;
}
}
main()

token_ownership

GetTokenById

Query the Token.

Path

  • POST /token/token_ownership/GetTokenById

Request

interface ReqGetTokenById {
token_data_id_hash: string,
property_version: string,
table_handle: string,
transaction_version?: string,
token: string
}

Response

interface ResGetTokenById {
token: {
token_data_id_hash: string,
property_version: string,
transaction_version: string,
table_handle: string,
collection_name: string,
name: string,
owner_address: string,
amount: string,
table_type: string,
inserted_at: /*datetime*/ string,
collection_data_id_hash: string,
transaction_timestamp: /*datetime*/ string
}
}

Client Demo

import { HttpClient } from 'tsrpc';
import { serviceProto } from '../shared/protocols/serviceProto';

// Create the Client
let client = new HttpClient(serviceProto, {
server: 'https://aptos.dorafactory.org/mainnet-api/',
logger: console
});

async function main() {
// callApi
let ret = await client.callApi('token/token_ownership/GetTokenById', {
token_data_id_hash: "72bb4980fd7b1866fa660c496fc555fbbb28baa23b68463df4763d485da1c100",
property_version: "0",
table_handle: "0xa3ce7bb4acea0bcc6827d23c8ccef3bb388df2c8478696b7d061474b01392803",
token: "203db03b-1880-4926-b0a3-9937521a1386"
});
if (ret.res != undefined) {
console.log(ret.res)
}
// Error
if (!ret.isSucc) {
return;
}
}
main()

ListTokenByAddress

List relevant token_ownerships data by owner_address

Path

  • POST /token/token_ownership/ListTokenByAddress

Request

interface ReqListTokenByAddress {
owner_address: string,
transaction_version?: string,
offset?: number,
limit?: number,
token: string
}

Response

interface ResListTokenByAddress {
tokens: {
token_data_id_hash: string,
property_version: string,
transaction_version: string,
table_handle: string,
collection_name: string,
name: string,
owner_address: string,
amount: string,
table_type: string,
inserted_at: /*datetime*/ string,
collection_data_id_hash: string,
transaction_timestamp: /*datetime*/ string
}[],
total: number
}

Client Demo

import { HttpClient } from 'tsrpc';
import { serviceProto } from '../shared/protocols/serviceProto';

// Create the Client
let client = new HttpClient(serviceProto, {
server: 'https://aptos.dorafactory.org/mainnet-api/',
logger: console
});

async function main() {
// callApi
let ret = await client.callApi('token/token_ownership/ListTokenByAddress', {
owner_address: "0x3ca30f13c0392e7ae03ab48b560595454805925b1bc23e47157bb8232633021b",
token: "203db03b-1880-4926-b0a3-9937521a1386"
});
if (ret.res != undefined) {
console.log(ret.res)
}
// Error
if (!ret.isSucc) {
return;
}
}
main()