feat: tiered API plans (Free/Bronze/Gold/Platinum)
- Free: $0, 30 req/min, market data only - Bronze: $29/mo, 100 req/min, + companies & search - Gold: $99/mo, 500 req/min, + filings & historical - Platinum: $299/mo, 2000 req/min, all features + priority - Plan-aware rate limiting per API key (or per IP for free) - Usage tracking with daily aggregation - GET /api/v1/plans — plan listing - POST /api/v1/plans/register — instant free API key - GET /api/v1/plans/usage — usage stats - /pricing — dark-themed HTML pricing page - X-RateLimit-* and X-Plan headers on every response - Restricted endpoints return upgrade prompt - Updated OpenAPI spec with security scheme - 53 handlers, compiles clean
This commit is contained in:
@@ -11,19 +11,28 @@ func RegisterRoutes(app *fiber.App, database *db.DB) {
|
||||
h := handlers.New(database)
|
||||
|
||||
app.Get("/health", h.Health)
|
||||
app.Get("/pricing", h.PricingPage)
|
||||
|
||||
v1 := app.Group("/api/v1")
|
||||
|
||||
// Plans endpoints (accessible to all)
|
||||
v1.Get("/plans", h.ListPlans)
|
||||
v1.Get("/plans/usage", h.PlanUsage)
|
||||
v1.Post("/plans/register", h.RegisterPlan)
|
||||
|
||||
// Companies
|
||||
v1.Get("/companies", h.ListCompanies)
|
||||
v1.Get("/companies/search", h.SearchCompanies)
|
||||
v1.Get("/companies/:id", h.GetCompany)
|
||||
v1.Get("/companies/:id/filings", h.CompanyFilings)
|
||||
|
||||
// Filings
|
||||
v1.Get("/filings", h.ListFilings)
|
||||
v1.Get("/filings/search", h.SearchFilings)
|
||||
v1.Get("/filings/recent", h.RecentFilings)
|
||||
v1.Get("/filings/:id", h.GetFiling)
|
||||
|
||||
// Market
|
||||
v1.Get("/market/selic", h.ListSelic)
|
||||
v1.Get("/market/selic/current", h.CurrentSelic)
|
||||
v1.Get("/market/cdi", h.ListCDI)
|
||||
@@ -34,5 +43,6 @@ func RegisterRoutes(app *fiber.App, database *db.DB) {
|
||||
v1.Get("/market/fx/current", h.CurrentFX)
|
||||
v1.Get("/market/overview", h.MarketOverview)
|
||||
|
||||
// Search
|
||||
v1.Get("/search", h.GlobalSearch)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user