The single source of truth for Nigerian news 🇳🇬
9ja News API is a Django-based REST API that aggregates news from major Nigerian news sources including Vanguard, Punch, and more. It provides a clean, simple interface for developers to access Nigerian news programmatically.
- 📰 News Aggregation: Scrapes and serves news from multiple Nigerian sources
- 🔍 Search Functionality: Search across all news sources with keywords
- 📊 Categorization: Politics, Business, Entertainment, Technology, Sports, Health
- 🔐 API Key Authentication: Secure access with rate limiting
- 📱 RESTful API: Clean JSON responses for easy integration
- 🕒 Real-time Updates: Fresh news content updated regularly
# Clone the repository
git clone <repository-url>
cd 9janewsapi/newsapi
# Start with Docker Compose
docker-compose up --build
# The API will be available at http://localhost:8000- Python 3.9+
- pip
- Virtual environment (recommended)
- Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r requirements.txt- Environment setup
cp .env.example .env
# Edit .env with your configuration- Database setup
python manage.py migrate
python manage.py createsuperuser- Run the server
python manage.py runserverAll API requests require an API key. Get yours by registering at the frontend application.
https://api.api.9janewsapi.com.ng/api/
GET /api/vanguard/apikey={YOUR_API_KEY}/{category}/Categories: politics, business, entertainment, technology, sports, health
Example:
curl "https://api.api.9janewsapi.com.ng/api/vanguard/apikey=your_key_here/politics/"GET /api/search/apikey={YOUR_API_KEY}/{search_term}Example:
curl "https://api.api.9janewsapi.com.ng/api/search/apikey=your_key_here/president%20buhari"{
"message": "Success!",
"data": [
{
"id": "unique_id",
"title": "News headline",
"summary": "Brief description of the news",
"date": "2024-01-01",
"photo": "https://image-url.com/image.jpg",
"link": "https://full-article-url.com"
}
]
}- Free Tier: 1000 requests per day
- Contact sales for higher limits
newsapi/
├── api/ # News scraping and API endpoints
├── users/ # User management and API keys
├── newsapi/ # Django settings and config
├── requirements.txt # Python dependencies
├── Dockerfile # Docker configuration
├── docker-compose.yml # Multi-container setup
└── manage.py # Django management script
- Create a new scraper module in
api/ - Follow the pattern in
vanguard.py - Add URL patterns in
api/urls.py - Update documentation
python manage.py testWe use Black for code formatting:
black .docker-compose -f docker-compose.prod.yml up -dSECRET_KEY=your-secret-key
DEBUG=False
ALLOWED_HOSTS=yourdomain.com
DATABASE_URL=postgresql://user:pass@host:5432/dbname
REDIS_URL=redis://localhost:6379/0- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
MIT License - see LICENSE file for details
- 📧 Email: support@9janews.com
- 🐛 Issues: GitHub Issues
- 📖 Docs: Full Documentation
Thank you for contributing to this project! 🎉
To keep our codebase clean and consistent, we follow a few simple rules for commits and branch names.
We follow the Conventional Commits specification.
():
[optional body]
[optional footer(s)]
- feat – a new feature
- fix – a bug fix
- docs – documentation changes
- style – formatting changes (no code impact)
- refactor – code restructuring without behavior change
- test – adding or updating tests
- chore – maintenance tasks
feat(auth): add Google login support fix(api): handle null user ID in profile endpoint docs(readme): update setup instructions
- Use lowercase for types and scopes.
- Keep the subject line short (≤ 72 characters).
- Use the body to explain why the change was made, not just what.
- Reference issues in the footer when relevant:
Closes #42
We use a structured format for branch names:
/
- feat/ – for new features
- fix/ – for bug fixes
- docs/ – for documentation updates
- chore/ – for maintenance tasks
- refactor/ – for code refactoring
- test/ – for adding/updating tests
- release/ – for release preparation
- Use lowercase with hyphens (
-) to separate words. - Keep it short but descriptive.
- Match the branch type to the commit type when possible.
feat/add-user-auth fix/payment-timeout-bug docs/update-contributing-guide refactor/api-service-layer release/v1.2.0
- Branches describe what you’re working on.
- Commits describe what changed and why.
- Following these rules helps everyone understand the project history at a glance.
👉 You can even enforce these rules automatically using tools like commitlint and husky.
Made with ❤️ for the Nigerian developer community