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
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
Plan | Requests / Second | Daily Limit |
---|---|---|
Free | 5 | 10,000 |
Developer | 25 | 100,000 |
Enterprise | 100 | Unlimited |
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 Block by Number
Retrieves block information by block number
Parameters
Name | Type | Required | Description | Example |
---|---|---|---|---|
blockNumber | number | Yes | The block number to retrieve | 1234567 |
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 Transaction by Hash
Retrieves transaction details by transaction hash
Parameters
Name | Type | Required | Description | Example |
---|---|---|---|---|
txHash | string | Yes | The transaction hash to retrieve | 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef |
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 Account Balance
Retrieves account balance for a specific address across all chains
Parameters
Name | Type | Required | Description | Example |
---|---|---|---|---|
address | string | Yes | The account address to query | 0x1234567890abcdef1234567890abcdef12345678 |
chain | string | No | Chain 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 Account Transactions
Retrieves transactions for a specific account
Parameters
Name | Type | Required | Description | Example |
---|---|---|---|---|
address | string | Yes | The account address | 0x1234567890abcdef1234567890abcdef12345678 |
page | number | No | Page number for pagination | 1 |
limit | number | No | Number of results per page (max 100) | 20 |
sort | string | No | Sort 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 Token Holdings
Retrieves all tokens held by an account address
Parameters
Name | Type | Required | Description | Example |
---|---|---|---|---|
address | string | Yes | The account address to query | 0x1234567890abcdef1234567890abcdef12345678 |
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 Token Information
Retrieves detailed information about a token
Parameters
Name | Type | Required | Description | Example |
---|---|---|---|---|
tokenAddress | string | Yes | The token contract address | 0x1234567890abcdef1234567890abcdef12345678 |
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 Smart Contract Information
Retrieves information about a smart contract
Parameters
Name | Type | Required | Description | Example |
---|---|---|---|---|
contractAddress | string | Yes | The contract address | 0x1234567890abcdef1234567890abcdef12345678 |
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 Contract Source Code
Retrieves source code for a verified smart contract
Parameters
Name | Type | Required | Description | Example |
---|---|---|---|---|
contractAddress | string | Yes | The contract address | 0x1234567890abcdef1234567890abcdef12345678 |
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 Network 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 NFT Metadata
Retrieves metadata for a specific NFT
Parameters
Name | Type | Required | Description | Example |
---|---|---|---|---|
contractAddress | string | Yes | The NFT contract address | 0x1234567890abcdef1234567890abcdef12345678 |
tokenId | string | Yes | The token ID of the NFT | 1234 |
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
Code | Description |
---|---|
400 | Bad Request - Invalid parameters |
401 | Unauthorized - Missing or invalid API key |
403 | Forbidden - API key doesn't have access |
404 | Not Found - Resource not found |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error - Something went wrong |
Support
Need help with the Megapayer Explorer API? Our developer support team is ready to assist you.
Ready to Start Building?
Get your API key today and start integrating blockchain data into your applications