Skip to main content
GET
/
v1
/
usage
Usage
curl --request GET \
  --url https://api.example.com/v1/usage
{
  "storage_bytes": 123,
  "bandwidth_bytes": 123,
  "upload_count": 123,
  "period_start": "<string>"
}
Retrieve your current usage statistics including storage, bandwidth, and upload counts.

Response

storage_bytes
integer
required
Total storage used in bytes.
bandwidth_bytes
integer
required
Bandwidth used this period in bytes.
upload_count
integer
required
Number of uploads this period.
period_start
string
required
Start of current billing period (YYYY-MM-DD).

Example

curl https://api.stashfyle.com/v1/usage \
  -H "Authorization: Bearer sk_live_xxx"
Response
{
  "storage_bytes": 524288000,
  "bandwidth_bytes": 1073741824,
  "upload_count": 150,
  "period_start": "2024-01-01"
}

Understanding Usage

Storage

Total bytes of all files currently stored. Decreases when you delete files.
const storageGB = usage.storage_bytes / (1024 * 1024 * 1024);
console.log(`Using ${storageGB.toFixed(2)} GB`);

Bandwidth

Total bytes downloaded from your files this billing period. Resets monthly.
Bandwidth has zero egress fees thanks to Cloudflare R2. Limits are for fair use only.

Upload Count

Number of files uploaded this billing period. Resets monthly.

Monitoring Usage

Check Against Limits

const PLAN_LIMITS = {
  free: { storage: 1 * 1024 * 1024 * 1024, uploads: 1000 },
  hobby: { storage: 10 * 1024 * 1024 * 1024, uploads: 50000 },
  pro: { storage: 100 * 1024 * 1024 * 1024, uploads: 500000 },
};

async function checkUsage(plan) {
  const response = await fetch('https://api.stashfyle.com/v1/usage', {
    headers: { 'Authorization': `Bearer ${API_KEY}` }
  });

  const usage = await response.json();
  const limits = PLAN_LIMITS[plan];

  return {
    storageUsedPercent: (usage.storage_bytes / limits.storage) * 100,
    uploadsUsedPercent: (usage.upload_count / limits.uploads) * 100,
    isNearLimit: usage.storage_bytes > limits.storage * 0.8
  };
}

Set Up Alerts

async function checkAndAlert() {
  const { storageUsedPercent, isNearLimit } = await checkUsage('hobby');

  if (isNearLimit) {
    // Send notification to upgrade or clean up
    console.warn(`Storage at ${storageUsedPercent.toFixed(1)}%`);
  }
}

// Run daily
setInterval(checkAndAlert, 24 * 60 * 60 * 1000);

Plan Limits Reference

PlanStorageBandwidth/moUploads/mo
Free1 GB5 GB1,000
Hobby10 GB50 GB50,000
Pro100 GB500 GB500,000

Errors

CodeStatusDescription
unauthorized401Invalid or missing API key
rate_limit_exceeded429Too many requests