The Histori REST API is a powerful tool for accessing historical blockchain data across multiple networks. This API provides reliable, developer-friendly endpoints for querying blocks, transactions, and accounts with high scalability and performance.
- Multi-Network Support: Access blockchain data from Ethereum, Binance Smart Chain, and more.
- Developer-Friendly: Intuitive endpoints and clear documentation for seamless integration.
- Production-Ready: High-performance and scalable architecture.
- Node.js (version 16 or higher)
- npm (Node Package Manager)
Clone the repository:
git clone https://github.com/your-repo/histori-rest-api.git
cd histori-rest-apiInstall dependencies:
npm installThe networks.json file is where you configure network-specific details for accessing blockchain data through the Histori REST API. This includes RPC URLs, network IDs, chain IDs, block explorer links, and more. You can fill this configuration with custom RPC URLs or use Histori’s multi-RPC service for seamless integration.
-
Understand the Fields:
name: The friendly name of the network (e.g., Ethereum Mainnet).networkId: A unique identifier for the network (e.g.,eth-mainnet).chainId: The chain ID of the network (e.g.,1for Ethereum Mainnet).active: Indicates whether this network is active (trueorfalse).history: Whether historical data is enabled for this network.blockExplorer: URL for the network's block explorer.blockTime: Average time (in seconds) between blocks.nativeCurrencyToUSDPool: Address of the liquidity pool for native currency to USD conversion.poolInversed: Boolean indicating whether the pool ratio is inversed.rpc: List of RPC URLs for the network.poolScale: Scale factor for the native currency to USD conversion.USDCAddress/USDTAddress: Token contract addresses for USDC/USDT.
-
Option 1: Using Custom RPC URLs:
- Replace the
<YOUR_HISTORI_PROJECT_ID_HERE>placeholder in therpc.urlwith your preferred RPC URL. - Example:
{ "url": "https://custom-node.example.com/eth-mainnet" }
- Replace the
-
Option 2: Using Histori Multi-RPC Service:
- Histori provides a multi-RPC service with optimized performance and reliability. Follow these steps to obtain your
projectId:
- Histori provides a multi-RPC service with optimized performance and reliability. Follow these steps to obtain your
-
Visit the Histori Dashboard:
- Go to the Histori Dashboard and log in or sign up for an account.
-
Create a Project:
- Navigate to the Projects section and click Create New Project.
- Fill in your project details and save.
-
Get Your
projectId:- Once your project is created, you’ll see a unique
projectIdassociated with it. - Example:
abc123xyz456
- Once your project is created, you’ll see a unique
-
Update
networks.json:- Replace
<YOUR_HISTORI_PROJECT_ID_HERE>in the RPC URLs with yourprojectId. - Example:
{ "url": "https://node.histori.xyz/eth-mainnet?projectId=abc123xyz456" }
- Replace
[
{
"name": "Ethereum Mainnet",
"networkId": "eth-mainnet",
"chainId": 1,
"active": true,
"history": true,
"blockExplorer": "https://etherscan.io/",
"blockTime": 12,
"nativeCurrencyToUSDPool": "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640",
"poolInversed": true,
"rpc": [
{
"url": "https://node.histori.xyz/eth-mainnet?projectId=abc123xyz456"
}
],
"poolScale": 6,
"USDCAddress": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"USDTAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7"
},
{
"name": "Ethereum Sepolia Testnet",
"networkId": "eth-sepolia",
"chainId": 11155111,
"active": true,
"history": false,
"blockExplorer": "https://sepolia.etherscan.io/",
"blockTime": 12,
"rpc": [
{
"url": "https://node.histori.xyz/eth-sepolia?projectId=abc123xyz456"
}
],
"USDCAddress": "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"
}
]The .env file is essential for configuring environment variables required for running the Histori REST API. This includes settings for the server port and database connections for different blockchain networks. Follow the steps below to configure your .env file.
-
Copy the Template:
- Create a new
.envfile by copying the provided.env.examplefile:cp .env.example .env
- Create a new
-
Set the Server Port:
- Define the port where the API will run. The default is
3001:PORT=3001
- Define the port where the API will run. The default is
-
Configure the Database Connection:
- If you want to use endpoints that use scraped data (get tokens by symbol, get tokens by name, etc.), you need to access a database containing the scraped and parsed data. You can use the Histori Scraper or create your own and fill up a database table. Set the database connection details for each network you intend to support. Use the format below, replacing
<chain_id>with the chain ID of the network (e.g.,1for Ethereum Mainnet).
Example template for Ethereum Mainnet (
chain_id 1):DB_HOST_1=<YOUR_DB_HOST> DB_PORT_1=<YOUR_DB_PORT> DB_USER_1=<YOUR_DB_USERNAME> DB_PASSWORD_1=<YOUR_DB_PASSWORD> DB_DATABASE_1=<YOUR_DB_NAME>
- If you want to use endpoints that use scraped data (get tokens by symbol, get tokens by name, etc.), you need to access a database containing the scraped and parsed data. You can use the Histori Scraper or create your own and fill up a database table. Set the database connection details for each network you intend to support. Use the format below, replacing
- Replace the placeholder values (e.g.,
<YOUR_DB_HOST>,<YOUR_DB_PORT>, etc.) with actual values specific to your database setup. - Ensure the database user has sufficient privileges to access and manage the specified database.
With this setup, the application will connect to the appropriate database for each supported blockchain network. If you need further assistance, refer to the Histori Documentation.
Development Mode
Start the API in development mode with live-reload for faster iteration:
npm run start:devProduction Mode
Compile and run the project in production mode:
npm run build
npm run start:prodComprehensive documentation is available at: Histori REST API Documentation
Use the following Swagger URL locally after starting the server:
http://localhost:3001/api-docsExplore the power of blockchain history with Histori. Whether you’re a developer, researcher, or visionary, we’re here to support your journey.
- Website: histori.xyz
- Docs: docs.histori.xyz
- Email: contact@histori.xyz
- Telegram: Join
⭐️ From the Histori Team – Your gateway to blockchain insights!