RESTful API

Megapayer Explorer API Documentation

Integrate blockchain data directly into your applications with our comprehensive API suite. Access transactions, blocks, accounts, tokens, and more across the Megapayer ecosystem.

Base URL

https://api.megapayer.io/v1

All API requests should be made to this base URL, followed by the specific endpoint path. Remember to include your API key in each request.

Authentication

All API requests require authentication using an API key. You can obtain your API key from theDeveloper Portal. Include your API key in the request headers as follows:

x-api-key: YOUR_API_KEY

Rate Limits

PlanRequests / SecondDaily Limit
Free510,000
Developer25100,000
Enterprise100Unlimited

Code Examples

// Using fetch API
const apiKey = 'YOUR_API_KEY';
const blockNumber = 1234567;

fetch(`https://api.megapayer.io/v1/blocks/${blockNumber}`, {
  headers: {
    'x-api-key': apiKey
  }
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

API Endpoints

GET

Get Block by Number

/api/v1/blocks/{blockNumber}
Blockchain

Retrieves block information by block number

Parameters

NameTypeRequiredDescriptionExample
blockNumbernumberYesThe block number to retrieve1234567

Response Example

{
  "status": "success",
  "data": {
    "blockNumber": 1234567,
    "hash": "0x8c2a3d24a10568d03c9b30e1c28d12bd078d783fc9a7c9e566c1d81541543355",
    "timestamp": 1678934567,
    "parentHash": "0x7d2a5d24a10568d03c9b30e1c28d12bd078d783fc9a7c9e566c1d81541543123",
    "miner": "0xabcdef1234567890abcdef1234567890abcdef12",
    "nonce": "0x1234567890abcdef",
    "difficulty": "1234567890",
    "gasLimit": 15000000,
    "gasUsed": 12345678,
    "transactions": [
      "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
      "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
    ]
  }
}
GET

Get Transaction by Hash

/api/v1/transactions/{txHash}
Transactions

Retrieves transaction details by transaction hash

Parameters

NameTypeRequiredDescriptionExample
txHashstringYesThe transaction hash to retrieve0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef

Response Example

{
  "status": "success",
  "data": {
    "hash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "blockNumber": 1234567,
    "blockHash": "0x8c2a3d24a10568d03c9b30e1c28d12bd078d783fc9a7c9e566c1d81541543355",
    "timestamp": 1678934567,
    "from": "0x1234567890abcdef1234567890abcdef12345678",
    "to": "0xabcdef1234567890abcdef1234567890abcdef12",
    "value": "1.25000000000000000",
    "gasPrice": "20000000000",
    "gasLimit": 21000,
    "gasUsed": 21000,
    "nonce": 123,
    "input": "0x",
    "status": true
  }
}
GET

Get Account Balance

/api/v1/accounts/{address}/balance
Accounts

Retrieves account balance for a specific address across all chains

Parameters

NameTypeRequiredDescriptionExample
addressstringYesThe account address to query0x1234567890abcdef1234567890abcdef12345678
chainstringNoChain ID to filter results (optional)megapayer

Response Example

{
  "status": "success",
  "data": {
    "address": "0x1234567890abcdef1234567890abcdef12345678",
    "balances": [
      {
        "chain": "megapayer",
        "balance": "1250.75000000000000000",
        "symbol": "MPC",
        "usdValue": 52125.37
      },
      {
        "chain": "ethereum",
        "balance": "0.25000000000000000",
        "symbol": "ETH",
        "usdValue": 750.25
      }
    ],
    "totalUsdValue": 52875.62
  }
}
GET

Get Account Transactions

/api/v1/accounts/{address}/transactions
Accounts

Retrieves transactions for a specific account

Parameters

NameTypeRequiredDescriptionExample
addressstringYesThe account address0x1234567890abcdef1234567890abcdef12345678
pagenumberNoPage number for pagination1
limitnumberNoNumber of results per page (max 100)20
sortstringNoSort order (asc or desc)desc

Response Example

{
  "status": "success",
  "data": {
    "transactions": [
      {
        "hash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
        "blockNumber": 1234567,
        "timestamp": 1678934567,
        "from": "0x1234567890abcdef1234567890abcdef12345678",
        "to": "0xabcdef1234567890abcdef1234567890abcdef12",
        "value": "1.25000000000000000",
        "gasUsed": 21000
      }
    ],
    "pagination": {
      "page": 1,
      "limit": 20,
      "totalPages": 5,
      "totalItems": 87
    }
  }
}
GET

Get Token Holdings

/api/v1/accounts/{address}/tokens
Tokens

Retrieves all tokens held by an account address

Parameters

NameTypeRequiredDescriptionExample
addressstringYesThe account address to query0x1234567890abcdef1234567890abcdef12345678

Response Example

{
  "status": "success",
  "data": {
    "address": "0x1234567890abcdef1234567890abcdef12345678",
    "tokens": [
      {
        "contract": "0x1234567890abcdef1234567890abcdef12345678",
        "name": "Sample Token",
        "symbol": "SMPL",
        "decimals": 18,
        "balance": "100.000000000000000000",
        "usdValue": 250.75
      },
      {
        "contract": "0xabcdef1234567890abcdef1234567890abcdef12",
        "name": "Example Token",
        "symbol": "EXMP",
        "decimals": 6,
        "balance": "500.000000",
        "usdValue": 125.50
      }
    ]
  }
}
GET

Get Token Information

/api/v1/tokens/{tokenAddress}
Tokens

Retrieves detailed information about a token

Parameters

NameTypeRequiredDescriptionExample
tokenAddressstringYesThe token contract address0x1234567890abcdef1234567890abcdef12345678

Response Example

{
  "status": "success",
  "data": {
    "address": "0x1234567890abcdef1234567890abcdef12345678",
    "name": "Sample Token",
    "symbol": "SMPL",
    "decimals": 18,
    "totalSupply": "1000000.000000000000000000",
    "holders": 1500,
    "transactions": 35000,
    "price": {
      "usd": 2.5075,
      "btc": 0.00005,
      "eth": 0.001
    },
    "marketCap": 2507500
  }
}
GET

Get Smart Contract Information

/api/v1/contracts/{contractAddress}
Smart Contracts

Retrieves information about a smart contract

Parameters

NameTypeRequiredDescriptionExample
contractAddressstringYesThe contract address0x1234567890abcdef1234567890abcdef12345678

Response Example

{
  "status": "success",
  "data": {
    "address": "0x1234567890abcdef1234567890abcdef12345678",
    "name": "Example Contract",
    "creator": "0xabcdef1234567890abcdef1234567890abcdef12",
    "creationTransaction": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "creationBlock": 1000000,
    "creationTimestamp": 1670000000,
    "isVerified": true,
    "verifiedDate": 1670100000,
    "balance": "10.500000000000000000",
    "transactions": 5000
  }
}
GET

Get Contract Source Code

/api/v1/contracts/{contractAddress}/source
Smart Contracts

Retrieves source code for a verified smart contract

Parameters

NameTypeRequiredDescriptionExample
contractAddressstringYesThe contract address0x1234567890abcdef1234567890abcdef12345678

Response Example

{
  "status": "success",
  "data": {
    "address": "0x1234567890abcdef1234567890abcdef12345678",
    "name": "Example Contract",
    "compiler": "solc",
    "version": "0.8.17",
    "optimization": true,
    "runs": 200,
    "license": "MIT",
    "abi": [...],
    "sourceCode": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.17;\n\ncontract ExampleContract {\n    // Contract source code\n}",
    "constructorArguments": "0000000000000000000000000000000000000000000000000000000000000000"
  }
}
GET

Get Network Statistics

/api/v1/stats
Statistics

Retrieves network statistics and metrics

Parameters

No parameters required

Response Example

{
  "status": "success",
  "data": {
    "latestBlock": 1234567,
    "blockTime": 3.2,
    "averageGasPrice": 25000000000,
    "totalTransactions": 50000000,
    "pendingTransactions": 326,
    "activeAddresses": 125000,
    "validators": 100,
    "tps": 125.7,
    "price": 41.23
  }
}
GET

Get NFT Metadata

/api/v1/nfts/{contractAddress}/{tokenId}
NFTs

Retrieves metadata for a specific NFT

Parameters

NameTypeRequiredDescriptionExample
contractAddressstringYesThe NFT contract address0x1234567890abcdef1234567890abcdef12345678
tokenIdstringYesThe token ID of the NFT1234

Response Example

{
  "status": "success",
  "data": {
    "contract": "0x1234567890abcdef1234567890abcdef12345678",
    "tokenId": "1234",
    "name": "Example NFT #1234",
    "description": "This is an example NFT with detailed metadata",
    "imageUrl": "https://ipfs.io/ipfs/QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco/1234",
    "attributes": [
      {
        "trait_type": "Background",
        "value": "Blue"
      },
      {
        "trait_type": "Eyes",
        "value": "Green"
      }
    ],
    "owner": "0xabcdef1234567890abcdef1234567890abcdef12",
    "creator": "0x1234567890abcdef1234567890abcdef12345678",
    "lastTransferTimestamp": 1678934567,
    "lastTransferValue": 1.5
  }
}

Error Handling

When an error occurs, the API returns a JSON response with an error code and message:

{
  "status": "error",
  "error": {
    "code": 400,
    "message": "Invalid parameter: address format is incorrect"
  }
}

Common Error Codes

CodeDescription
400Bad Request - Invalid parameters
401Unauthorized - Missing or invalid API key
403Forbidden - API key doesn't have access
404Not Found - Resource not found
429Too Many Requests - Rate limit exceeded
500Internal Server Error - Something went wrong

Support

Ready to Start Building?

Get your API key today and start integrating blockchain data into your applications