How to Use iTick API for Nigerian Stocks:Real-Time & Historical K-Line

In today’s increasingly interconnected global financial markets, Nigeria, as Africa’s largest economy, is drawing growing attention from investors worldwide. The Nigerian Stock Exchange (NSE) lists companies across various sectors such as energy, finance, and consumer goods—including prominent names like Dangote Cement (DANGCEM) and Zenith Bank (ZENITHBANK). Access to real-time data and historical trend analysis for these stocks is critical for informed investment decisions. However, accessing this data often presents challenges such as high technical barriers and unstable data sources.
The iTick API offers a simple yet powerful solution! As a professional financial data provider, iTick supports multiple global markets, including Nigeria (region=NG). Through its RESTful API interface, users can effortlessly obtain real-time stock quotes and historical K-line data. iTick’s strengths lie in its strong real-time performance, comprehensive coverage, user-friendly interface, and tiered free plans that enable rapid onboarding for developers. Whether you're an individual investor, quantitative trader, or financial application developer, iTick delivers tangible benefits. This article will walk you through how to use the iTick API to access Nigerian equities, complete with practical Python code examples. Let’s dive in!
I. Why Choose the iTick API for Accessing Nigerian Stocks?
- Global Market Coverage: iTick provides data for multiple emerging markets, including NG (Nigeria), ensuring accurate localized information.
- Real-Time & Historical Data: From instant quotes to multi-period K-lines, iTick has everything needed to analyze market trends.
- Easy Integration: With a straightforward REST API design, integration requires just a few lines of code and supports languages like Python and Java.
- Reliable & Free Options: Direct exchange connectivity ensures high-quality data; free plans suit beginners while paid tiers cater to institutional users.
- Emerging Market Opportunities: As Nigeria’s equity market continues expanding, iTick helps capture investment opportunities and avoid data silos.
First-time users should register at the iTick official website to obtain an API token—a prerequisite for all API calls.
II. Detailed API Interface Overview
iTick offers a rich suite of stock APIs. Here we focus on two core interfaces: real-time quotes (Stock Quote) and historical K-line data (Stock Kline). Both utilize the GET method with clear and concise parameters.
1. Real-Time Stock Quote API (Stock Quote)
This endpoint retrieves up-to-date pricing, percentage changes, trading volume, and other key metrics for specific securities—ideal for monitoring live market activity.
- Endpoint:
GET https://api.itick.org/stock/quote - Required Parameters:
region: Market identifier; use"NG"for Nigeria.- code: Ticker symbol, e.g.,
"DANGCEM"(Dangote Cement).
- Sample Response:
{ "code": 0, "msg": null, "data": { "s": "DANGCEM", "ld": 500.00, // Last price "o": 495.00, // Open price "p": 490.00, // Previous close "h": 505.00, // High price "l": 490.00, // Low price "t": 1765526889000, // Timestamp "v": 1000000, // Volume "tu": 500000000.00, // Turnover "ts": 0, // Trading status "ch": 10.00, // Change amount "chp": 2.04 // Percentage change } }
2. Historical K-Line Data API (Stock Kline)
This endpoint returns K-line data for specified intervals—including open, high, low, close prices, and volume—for technical analysis and backtesting strategies.
- Endpoint:
GET https://api.itick.org/stock/kline - Required Parameters:
- Optional Parameter:
et: End timestamp (milliseconds); defaults to current time
- Sample Response:
{ "code": 0, "msg": null, "data": [ { "t": 1741239000000, // Timestamp "o": 495.00, // Open "h": 505.00, // High "l": 490.00, // Low "c": 500.00, // Close "v": 1000000, // Volume "tu": 500000000.00 // Turnover } // Additional records... ] }
III. Python Code Example: Connecting to Nigerian Stocks
Below is sample Python code using the requests library to call these APIs. Remember to replace "your_token" with your actual API token. The example assumes querying Dangote Cement data.
import requests
import json
# Base API URL
BASE_URL = "https://api.itick.org"
# Your API Token
TOKEN = "your_token"
# Common headers
headers = {
"accept": "application/json",
"token": TOKEN
}
def get_stock_quote(region, code):
"""Fetch real-time stock quote"""
url = f"{BASE_URL}/stock/quote"
params = {
"region": region,
"code": code.upper()
}
response = requests.get(url, params=params, headers=headers)
if response.status_code == 200:
return response.json()
else:
print(f"Error: {response.status_code}")
return None
def get_stock_kline(region, code, ktype, limit=10):
"""Fetch historical K-line data"""
url = f"{BASE_URL}/stock/kline"
params = {
"region": region,
"code": code.upper(),
"kType": ktype,
"limit": limit
}
response = requests.get(url, params=params, headers=headers)
if response.status_code == 200:
return response.json()
else:
print(f"Error: {response.status_code}")
return None
# Example: Query real-time quote for DANGCEM
quote_data = get_stock_quote("NG", "DANGCEM")
if quote_data:
print("Real-Time Quote:")
print(json.dumps(quote_data, indent=4))
# Example: Query last 10 daily K-lines for DANGCEM
kline_data = get_stock_kline("NG", "DANGCEM", 8, 10)
if kline_data:
print("Historical K-Line Data:")
print(json.dumps(kline_data, indent=4))
Run this code to see the output! For error handling or larger project integration, additional exception handling can be added.
IV. Conclusion: Embark on Your Nigerian Stock Journey
With the iTick API, accessing the Nigerian stock market has never been easier. Whether building personal dashboards, developing quantitative models, or creating educational tools, this API provides robust support. Register now at iTick, experiment with these endpoints, and unlock the vast potential of Africa’s emerging markets. Advanced features such as tick data and IPO calendars are also available for more sophisticated needs.
Official Documentation: https://docs.itick.org
GitHub Repository: https://github.com/itick-org