Web Metrics API

A Django application that serves business metrics via a REST API. This application is designed to be deployed to AWS Elastic Beanstalk.

Features

  • Years in business calculation
  • Customer satisfaction score
  • Response time metrics
  • Background update of metrics
  • REST API for retrieving metrics

Metrics Refresh Timer

Our metrics are automatically updated every hour.

Next refresh in:

59:59

Next refresh at:

Calculating...

API Endpoints

Documentation

GET /

This documentation page.

Health Check

GET /ping/

Simple health check endpoint to verify the API is running.

Years in Business

GET /api/years-in-business/

Returns the number of years in business since April 6th, 2006.

Customer Satisfaction Score

GET /api/satisfaction-score/

Returns the current customer satisfaction score as a numerical value.

Average Response Time

GET /api/response-time/

Returns the current average response time value.

All Metrics

GET /api/metrics/

Returns all available metrics with their current values and last update timestamps in a single response.

{
    "success": true,
    "data": {
        "years_in_business": {
            "value": 17.8,
            "last_updated": "2025-02-24T00:27:07.123456"
        },
        "response_time": {
            "value": 4.20,
            "last_updated": "2025-02-24T00:27:07.123456"
        },
        "satisfaction_score": {
            "value": 98.9,
            "last_updated": "2025-02-24T00:27:07.123456"
        }
    },
    "error": null,
    "timestamp": "2025-02-24T00:27:07.123456"
}

Response Format

All API endpoints return data in the following standardized format:

{
    "success": true,
    "data": 123.45,
    "error": null,
    "timestamp": "2023-07-21T12:34:56.789Z"
}

Error Handling

In case of errors, the response will include:

  • HTTP status code 4xx or 5xx
  • Error message in the response body
  • Success field set to false
{
    "success": false,
    "data": null,
    "error": "Error message description",
    "timestamp": "2023-07-21T12:34:56.789Z"
}

Local Development

  1. Clone the repository
  2. Create a virtual environment:
    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:
    pip install -r requirements.txt
  4. Run migrations:
    python manage.py migrate
  5. Create a superuser:
    python manage.py createsuperuser
  6. Run the development server:
    python manage.py runserver