Introduction
In this tutorial, you’ll learn how to build interactive cryptocurrency price charts using OHLC (Open, High, Low, Close) data from the Moralis API. We’ll use the Lightweight Charts library from TradingView to create professional-looking candlestick charts that can be embedded in any web application. We’ll use the following Moralis API endpoint:- Get OHLCV Data - Fetch historical candlestick price data for token pairs
Prerequisites
- Node.js v18+ installed
- A Moralis API key (get one free)
- Basic HTML/JavaScript knowledge
Step 1: Set Up Your Project
Create a new directory and files:Step 2: Create the HTML File
Create anindex.html file:
Step 3: Create the JavaScript File
Create achart.js file:
YOUR_API_KEY with your actual Moralis API key.
Step 4: Run the Chart
Openindex.html in your browser, or serve it with a simple HTTP server:
Example OHLC Response
Understanding the Response
| Field | Description |
|---|---|
timestamp | The start time of the candle |
open | Opening price for the period |
high | Highest price during the period |
low | Lowest price during the period |
close | Closing price for the period |
volume | Trading volume in USD |
Next Steps
- Get OHLC Data - Learn about OHLC data
- Get Token Price - Get current prices
- Build a DEX Screener - Build a trading dashboard
- API Reference - Full API documentation

