🇱🇰 lk-lottery-results
lk-lottery-results is an open-source TypeScript/Node.js npm package designed to make Sri Lankan lottery data easily accessible to developers.
The library retrieves real-time and historical lottery results from both the National Lotteries Board (NLB) and Development Lotteries Board (DLB) and converts them into clean, structured JSON that can be easily integrated into websites, mobile applications, APIs, dashboards, and other software.
🎯 Project Goal
Sri Lankan lottery information is primarily published for human consumption through official websites. This project provides a developer-friendly abstraction for accessing that information programmatically through a simple, type-safe JavaScript/TypeScript API.
✨ Key Features
- Real-time lottery result retrieval
- Historical draw lookup
- Complete NLB and DLB lottery coverage
- Structured JSON output
- Draw numbers and ISO-formatted dates
- Winning numbers and special letters
- Zodiac signs and special/super numbers
- Full prize breakdown tables
- Winner counts and total payouts
- Next jackpot / Super Prize information
- Automatic NLB verification challenge handling
- Exponential backoff and retry handling
- Configurable request timeouts
- Custom headers and proxy support
- Strongly typed TypeScript API
- Dual ESM and CommonJS support
- Custom error classes for predictable error handling
🛡️ Resilient Data Retrieval
The package includes built-in mechanisms for dealing with network failures and source-site restrictions.
For NLB requests, it can automatically resolve the site's verification challenge and maintain the required cookie in memory. Requests also support retries with exponential backoff, configurable timeouts, custom headers, and proxies.
📊 Rich Structured Data
Lottery results are normalized into predictable JavaScript objects containing information such as:
- Lottery board
- Lottery ID and name
- Draw number
- Draw date
- Day of the week
- Winning numbers
- Special letters
- Jackpot information
- Prize tiers
- Winning patterns
- Prize amounts
- Winner counts
- Total payouts
- Original source URL
This allows applications to consume lottery information without implementing their own scraping and parsing logic.
🧩 Developer-Friendly API
The package provides simple helper functions for common operations, including:
- Fetching all latest NLB and DLB results
- Fetching board-specific results
- Retrieving a specific lottery draw
- Searching historical draws
- Looking up results by date
- Automatically routing requests to the correct lottery board
For more advanced applications, the SriLankaLottery client provides configurable access to both NLB and DLB data sources.
⚙️ Technologies
- TypeScript
- Node.js
- Web Scraping
- HTML Parsing
- Asynchronous JavaScript
- JSON Data Processing
- ESM & CommonJS
- npm Package Development
📦 Distribution
Published as an npm package, allowing developers to integrate Sri Lankan lottery results directly into Node.js and TypeScript projects.
npm install lk-lottery-results
🧪 Reliability
The project includes unit testing and live integration verification to help ensure parsers and data retrieval continue working as expected.
Clear error types are provided for network failures, unavailable lottery draws, and parsing errors, allowing applications to handle failures gracefully.
🔓 Open Source
The project is open source and distributed under the MIT License, making it available for developers to use, modify, and contribute to.