Usagey + Express Example

Demonstration of integrating Usagey for usage-based pricing in an Express application

API Key Not Configured

Please set your Usagey API key in the .env file to enable full functionality of this example. Alternatively, set USE_MOCK_DATA=true.

Track Usage

Send usage events to Usagey to track how your customers are using your application.

View Demo

Usage Dashboard

View your usage data with charts and visualizations to understand consumption patterns.

View Demo

Pricing Plans

Implement flexible pricing tiers and see how they affect billing based on usage.

View Demo

How To Use This Example

This example demonstrates how to integrate the Usagey SDK into an Express application for tracking usage and implementing usage-based pricing.

Getting Started:

  1. Copy .env.example to .env and add your Usagey API key
  2. Run npm install to install dependencies
  3. Run npm start to start the server (or npm run dev for development with hot reload)
  4. Open http://localhost:3000 in your browser

Check out the source code to see how each feature is implemented. The main functionality is in the lib/usagey-client.js file and the Express route handlers.

For more information, visit the Usagey NPM package or read the official documentation.

API Endpoints

POST /api/track

Track a usage event

GET /api/stats

Get usage statistics

GET /api/events

Get recent usage events

POST /api/calculate

Calculate cost based on pricing model and usage