Vector Motion
AI/ML

API Volume Card - Request Monitoring Dashboard

Monitor API request volume, throughput, and usage patterns in real-time. Track peak usage times and optimize API performance with interactive analytics.

API Volume Card

The API Volume Card tracks API request volume for machine learning inference endpoints, helping teams monitor usage patterns and capacity.

Preview

Installation

npx shadcn@latest add https://vectormotion.vercel.app/registry/api-volume-card.json
API Volume Card
'use client'import React from 'react';import { BarChart, ArrowUpRight, Globe, Zap, Clock } from 'lucide-react';import { motion } from 'motion/react';import { clsx, type ClassValue } from "clsx"import { twMerge } from "tailwind-merge"import { ResponsiveContainer, BarChart as RechartsBarChart, Bar, Tooltip, Cell, XAxis } from 'recharts';function cn(...inputs: ClassValue[]) {   return twMerge(clsx(inputs))}interface ApiVolumeData {   time: string;   req: number;   [key: string]: any;}interface ApiVolumeCardProps {   className?: string;   title?: string;   totalVolume?: string;   trend?: string;   trendIcon?: React.ElementType;   data?: ApiVolumeData[];   peakVolume?: string;}const DEFAULT_DATA: ApiVolumeData[] = [   { time: '10:00', req: 1200 },   { time: '10:05', req: 1350 },   { time: '10:10', req: 1250 },   { time: '10:15', req: 1550 },   { time: '10:20', req: 1900 },   { time: '10:25', req: 1400 },   { time: '10:30', req: 1300 },   { time: '10:35', req: 1100 },   { time: '10:40', req: 1600 },   { time: '10:45', req: 1750 },   { time: '10:45', req: 1850 },   { time: '10:45', req: 1650 },];const DEFAULT_TITLE = "API Volume";const DEFAULT_TOTAL_VOLUME = "1.2k";const DEFAULT_TREND = "+14%";const DEFAULT_PEAK_VOLUME = "1.9k";export const ApiVolumeCard: React.FC<ApiVolumeCardProps> = ({   className = "",   title = DEFAULT_TITLE,   totalVolume = DEFAULT_TOTAL_VOLUME,   trend = DEFAULT_TREND,   trendIcon: TrendIcon = ArrowUpRight,   data = DEFAULT_DATA,   peakVolume = DEFAULT_PEAK_VOLUME,}) => {   return (      <motion.div         initial={{ opacity: 0, y: 20 }}         animate={{ opacity: 1, y: 0 }}         transition={{ duration: 0.5, delay: 0.2 }}         className={cn(            "relative overflow-hidden rounded-2xl border border-border bg-card text-card-foreground shadow-sm transition-all hover:border-blue-300 dark:hover:border-blue-700 hover:shadow-md flex flex-col h-full",            className         )}      >         <div className="p-5 flex flex-col h-full relative z-10">            <div className="mb-4 flex items-start justify-between">               <div>                  <h3 className="font-bold text-lg text-foreground">                     {title}                  </h3>                  <div className="flex items-center gap-2 mt-1">                     <span className="text-2xl font-bold text-foreground">{totalVolume}</span>                     <span className="text-xs font-medium text-emerald-500 bg-emerald-500/10 px-1.5 py-0.5 rounded-full flex items-center gap-0.5">                        <TrendIcon className="w-3 h-3" /> {trend}                     </span>                  </div>               </div>               <div className="rounded-lg border-2 border-blue-100 dark:border-blue-800 p-2 text-blue-500 dark:text-blue-400 flex items-center justify-center">                  <BarChart className="h-5 w-5" />               </div>            </div>            <div className="flex-1 w-full min-h-[100px] relative">               <ResponsiveContainer width="100%" height="100%">                  <RechartsBarChart data={data}>                     <Tooltip                        cursor={{ fill: 'transparent' }}                        content={({ active, payload }) => {                           if (active && payload && payload.length) {                              return (                                 <div className="rounded-lg border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800 p-2 shadow-sm text-xs">                                    <span className="font-bold text-blue-500">                                       {payload[0].payload.time}:                                    </span> {payload[0].value} reqs                                 </div>                              );                           }                           return null;                        }}                     />                     <Bar dataKey="req" radius={[2, 2, 0, 0]}>                        {data.map((entry, index) => (                           <Cell key={`cell-${index}`} fill={entry.req > 1800 ? '#3b82f6' : '#93c5fd'} />                        ))}                     </Bar>                  </RechartsBarChart>               </ResponsiveContainer>            </div>            <div className="mt-4 flex items-center justify-between text-xs text-muted-foreground bg-muted p-2 rounded-lg border border-border">               <div className="flex items-center gap-1">                  <Globe className="w-3 h-3" />                  <span>Global</span>               </div>               <div className="flex items-center gap-1">                  <Zap className="w-3 h-3" />                  <span className="font-medium text-foreground">Peak: {peakVolume}</span>               </div>               <div className="flex items-center gap-1">                  <Clock className="w-3 h-3" />                  <span>24h</span>               </div>            </div>            <div className="absolute -bottom-4 -right-4 z-0 opacity-5 pointer-events-none">               <BarChart className="w-40 h-40 text-blue-500" />            </div>         </div>      </motion.div>   );};

Props

Prop

Type

Usage

This component is a demo card displaying API volume metrics with animated visualizations and dark mode support.