npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ada-derana-news-scraper

v1.0.0

Published

A web scraper and API for fetching the latest news from Ada Derana, a popular Sri Lankan news website.

Readme

📰 Ada Derana News Scraper (v1.0.0)

A lightweight API and scraper for Ada Derana Sinhala news content. This package allows you to easily access hot news headlines, summaries, and links from the Ada Derana Sinhala news website.

🚀 Installation

npm install ada-derana-news-scraper

✨ Features

  • 🌐 Express.js API endpoint for hot news
  • 🔍 Standalone scraper function
  • 🔌 Easy integration with existing Node.js applications
  • 🖼️ Returns news images, summary, and links

📘 Usage

🖥️ Using a Custom Server (server.js)

You can create a simple server to run the API:

// server.js
const express = require('express');
const adaDerana = require('ada-derana-news-scraper');
require('dotenv').config(); // Load environment variables

const server = adaDerana.createAdaDeranaNewsAPI();
const PORT = process.env.PORT || 3000;

server.listen(PORT, () => {
    console.log(`Server is running on http://localhost:${PORT}/hotNews`);
});

🛠️ As an Express API

const { createAdaDeranaNewsAPI } = require('ada-derana-news-scraper');
require('dotenv').config(); // Load environment variables

const app = createAdaDeranaNewsAPI();

// Optional: Add more routes or middleware here

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
  console.log(`Ada Derana API server running on port ${PORT}`);
});

🧰 As a Scraper

const { scrapeHotNews } = require('ada-derana-news-scraper');

async function getNews() {
  try {
    const news = await scrapeHotNews();
    console.log(news);
  } catch (error) {
    console.error('Error scraping news:', error);
  }
}

getNews();

🔧 Environment Configuration

You can configure the application using environment variables:

Available Environment Variables:

  • PORT: The port number for the server (default: 3000)

Setting Environment Variables:

Using .env file (recommended for development):

Create a .env file in your project root:

PORT=8080

Then install the dotenv package:

npm install dotenv

And import it in your server file as shown in the usage examples above.

Using command line (for production):

# Linux/Mac
PORT=8080 node server.js

# Windows Command Prompt
set PORT=8080 && node server.js

# Windows PowerShell
$env:PORT=8080; node server.js

📚 API Documentation

🔄 API Endpoints

📋 GET /hotNews

Returns the latest hot news headlines from Ada Derana Sinhala.

Response Format:

{
  "success": true,
  "code": 200,
  "creator": {
    "name": "H.A. Diluka Hetti Arachchi",
    "github": "https://github.com/DillaCodeX"
  },
  "count": 5,
  "data": [
    {
      "title": "News headline",
      "summary": "News summary",
      "time": "Published time",
      "url": "https://sinhala.adaderana.lk/news-url",
      "image": "https://sinhala.adaderana.lk/image.jpg",
      "comments_url": "https://sinhala.adaderana.lk/news-url#disqus_thread"
    }
    // More news items...
  ]
}

Error Response Format:

{
  "success": false,
  "code": 500,
  "error": "Failed to fetch AdaDerana hot news"
}

⚙️ Functions

🔧 createAdaDeranaNewsAPI()

Creates an Express application with the AdaDerana News API routes configured.

Returns: Express application instance with the following endpoints:

  • GET /hotNews - Returns the latest hot news headlines

🔍 scrapeHotNews()

Scrapes hot news headlines directly from Ada Derana Sinhala website.

Returns: Promise that resolves to an array of news objects with the following properties:

  • title: The headline of the news article
  • image: News image URL
  • summary: A snippet of the news article
  • url: The full URL to the news article
  • comments_url: Direct link to comments
  • time: The published time of the article

📝 License

MIT

👨‍💻 Author