Skip to content

nawangdorjay/farmer-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒพ Farmer Advisory API

Screenshot

Production REST API for the Farmer Advisory Agent. Built with FastAPI.

This is the backend โ€” the Streamlit app is the demo layer. Real products need APIs.


๐Ÿš€ Quick Start

pip install -r requirements.txt
uvicorn api.main:app --reload

Open http://localhost:8000/docs for Swagger UI (auto-generated API docs).


๐Ÿ“ก Endpoints

Method Endpoint Description
GET /crops List all crops
GET /crops/{name} Get crop details (rice, wheat, cotton...)
GET /schemes List all schemes
GET /schemes/{key} Get scheme details (pm_kisan, ayushman...)
GET /schemes/search?q=loan Search schemes by keyword
GET /weather/{location} Get weather + farming advisory
POST /chat Ask any farming question (requires API key)
GET /docs Swagger UI
GET /redoc ReDoc
GET /openapi.json OpenAPI schema

๐Ÿงช Tests

pip install httpx
python tests/test_api.py

12 tests covering all endpoints, error handling, and schema validation.


๐Ÿง  Learn & Extend

Level 1: Understand FastAPI

  • Read api/main.py โ€” see how routes, models, and responses work
  • Open /docs โ€” try the interactive Swagger UI
  • Run tests โ€” see how TestClient works

Level 2: Add features

  • TODO: Add API key authentication (FastAPI security)
  • TODO: Add rate limiting (slowapi)
  • TODO: Add response caching (Redis)
  • TODO: Add request logging

Level 3: Production

  • TODO: Add Dockerfile
  • TODO: Deploy to Railway/Fly.io
  • TODO: Add monitoring (Prometheus metrics)
  • TODO: Add database (PostgreSQL) for analytics

๐Ÿค– AI-Assisted Development

Scaffolded with AI, extended with domain expertise. See BUILDING.md in the parent farmer-advisory-agent repo.

About

๐ŸŒพ Production REST API for farmer advisory โ€” crops, weather, schemes, market prices. FastAPI + Swagger docs.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages