Image Usage Analytics

This endpoint helps you get image analytics data like bandwidth consumption, request count, CDN hit ratio, etc.

Body
application/json
  • date_range
    Type: object
    required

    The timeframe to get the data for. Currently we only support a maximum of 30 days between start_at and end_at.

  • metrics
    Type: array string[] enum
    required

    Define the metric you need the data for, currently we support "bandwidth_consumption", "requests_count","status_4xx","status_5xx","avg_response_time""

    values
    • bandwidth_consumption
    • requests_count
    • transformations_count
    • bandwidth_savings
    • origin_hit_rate
  • filters
    Type: object
  • group_by
    Type: string enum
    values
    • daily
    • weekly
    • monthly
    • hourly
Responses
  • application/json
  • application/json
Request Example for post/image/analytics
import Gumlet from '@gumlet/nodejs-sdk';

const client = new Gumlet({
  apiKey: process.env['API_KEY'], // defaults to the API_KEY env var
});

const imageUsageAnalytic = await client.imageUsageAnalytics.retrieve({
  metrics: ['bandwidth_consumption'],
  date_range: {},
  group_by: 'daily',
});

console.log(imageUsageAnalytic);
{
  "bandwidth_consumption": [
    {
      "units": 1,
      "timestamp": 1
    }
  ],
  "requests_count": [
    {
      "units": 1,
      "timestamp": 1
    }
  ],
  "status_2xx": [
    {
      "units": 0,
      "timestamp": 1
    }
  ],
  "status_4xx": [
    {
      "units": 0,
      "timestamp": 1
    }
  ],
  "status_5xx": [
    {
      "units": 0,
      "timestamp": 1
    }
  ],
  "avg_response_time": [
    {
      "units": 0,
      "timestamp": 1
    }
  ],
  "cdn_hit_rate": [
    {
      "units": 0,
      "timestamp": 1
    }
  ],
  "transformations_count": [
    {
      "units": 1,
      "timestamp": 1
    }
  ],
  "origin_hit_rate": [
    {
      "units": 0,
      "timestamp": 1
    }
  ],
  "avg_transformation_response_time": [
    {
      "timestamp": 1,
      "fetch_time": 0,
      "response_time": 1
    }
  ],
  "content_type": [
    {
      "avif": 1,
      "png": 1,
      "jpeg": 1,
      "gif": 1,
      "webp": 1,
      "jxl": 1,
      "mp4": 1,
      "timestamp": 1
    }
  ],
  "bandwidth_savings": [
    {
      "units": 0,
      "timestamp": 1
    }
  ],
  "bandwidth_consumption_by_source": [
    {
      "bytes": 1,
      "domain": "string"
    }
  ],
  "ai_credit_usage": [
    {
      "timestamp": 1,
      "bg_removal": 1,
      "shadow_gen": 1
    }
  ]
}