Endpoints

API Documentation

This document outlines the available endpoints for the Statistics API.

Base URL

All endpoints are relative to the base URL of your API.

Authentication

All requests to the API must include an "authorization" header with a valid API key. You can obtain your API key from the MinerMag Dashboard (opens in a new tab).

Example:

Authorization: YOUR_API_KEY_HERE

Endpoints

1. Get All Statistics

Retrieves all statistics data or data for a specific chart.

GET /

Authentication

Required. Include your API key in the "authorization" header.

Query Parameters

ParameterTypeDescription
chartstring(Optional) Slug of the specific chart to retrieve

Response

  • If successful, returns a JSON object with a data array containing statistics objects.
  • If an error occurs, returns a JSON object with an error string.
Success Response Structure
{
  "data": [
    {
      "chart_name": string,
      "slug": string,
      "company": string,
      "data_points": any,
      "source": string,
      "sortByValue": boolean,
      "subtitle": string,
      "listOrder": number,
      "description": string,
      "maxTabs": number
    }
  ],
  "error": null
}
Error Response Structure
{
  "error": string
}

Status Codes

  • 200 OK: Successfully retrieved data
  • 500 Internal Server Error: Error occurred while fetching data

2. Get Statistics by Company

Retrieves all statistics data for a specific company.

GET /:company

Authentication

Required. Include your API key in the "authorization" header.

Path Parameters

ParameterTypeDescription
companystringThe company name (in URL)

Response

Similar to the root endpoint, but filtered for the specified company.

Status Codes

  • 200 OK: Successfully retrieved data
  • 500 Internal Server Error: Error occurred while fetching data or company doesn't exist

3. Get Specific Chart for a Company

Retrieves data for a specific chart of a specific company.

GET /:company/:chartname

Authentication

Required. Include your API key in the "authorization" header.

Path Parameters

ParameterTypeDescription
companystringThe company name (in URL)
chartnamestringThe slug of the chart (in URL)

Response

Similar to the root endpoint, but filtered for the specified company and chart.

Status Codes

  • 200 OK: Successfully retrieved data
  • 500 Internal Server Error: Error occurred while fetching data, or company or chart doesn't exist

Error Handling

All endpoints use the same error response format:

{
  "error": string
}

Common error messages include:

  • "Error Getting Data From Database"
  • "Company Doesn't Exist"
  • "Company Or Chart Doesn't Exist"

Notes

  • The company parameter in URLs is case-insensitive (converted to uppercase internally).
  • The chartname parameter in URLs is case-insensitive (converted to lowercase internally).
  • The chart query parameter for the root endpoint is case-insensitive (converted to lowercase internally).
  • All requests must include a valid API key in the "authorization" header.