Skip to main content

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 an index.html file:

Step 3: Create the JavaScript File

Create a chart.js file:
Replace YOUR_API_KEY with your actual Moralis API key.

Step 4: Run the Chart

Open index.html in your browser, or serve it with a simple HTTP server:

Example OHLC Response

Understanding the Response

Next Steps