# AIOZ Pin — Billing

Base URL: https://api.aiozpin.network/api
Authentication: pinning_api_key + pinning_secret_key headers

## Setup

```typescript
const BASE = 'https://api.aiozpin.network/api'
const PIN_HEADERS = {
  'pinning_api_key': process.env.AIOZ_PIN_API_KEY!,
  'pinning_secret_key': process.env.AIOZ_PIN_SECRET_KEY!
}
```

---

## This Month's Usage

GET https://api.aiozpin.network/api/billing/thisMonthUsage

```typescript
async function getThisMonthUsage() {
  const res = await fetch(`${BASE}/billing/thisMonthUsage`, { headers: PIN_HEADERS })
  return res.json()
}

const result = await getThisMonthUsage()
// result.data.total_storage    — total storage quota (bytes)
// result.data.storage_usage    — used storage (bytes)
// result.data.bandwidth_usage  — used bandwidth (bytes)
// result.data.storage_cost     — storage cost (string)
// result.data.bandwidth_cost   — bandwidth cost (string)
```

---

## Historical Usage

GET https://api.aiozpin.network/api/billing/historyUsage

```typescript
async function getHistoryUsage(offset = 0, limit = 10) {
  const params = new URLSearchParams({ offset: String(offset), limit: String(limit) })
  const res = await fetch(`${BASE}/billing/historyUsage?${params}`, { headers: PIN_HEADERS })
  return res.json()
}

const result = await getHistoryUsage()
// result.data.total_days
// result.data.history_usages[].date
// result.data.history_usages[].total_storage    — bytes
// result.data.history_usages[].total_bandwidth  — bytes
// result.data.history_usages[].total_amount     — cost string
```

---

## Top-Up History

GET https://api.aiozpin.network/api/billing/topUp

```typescript
async function getTopUpHistory(offset = 0, limit = 10) {
  const params = new URLSearchParams({ offset: String(offset), limit: String(limit) })
  const res = await fetch(`${BASE}/billing/topUp?${params}`, { headers: PIN_HEADERS })
  return res.json()
}

const result = await getTopUpHistory()
// result.data.totals
// result.data.top_up_usages[].id
// result.data.top_up_usages[].cosmos_tx_hash
// result.data.top_up_usages[].evm_tx_hash
// result.data.top_up_usages[].sender
// result.data.top_up_usages[].recipient
// result.data.top_up_usages[].amount.denom
// result.data.top_up_usages[].amount.amount
// result.data.top_up_usages[].total_amount
// result.data.top_up_usages[].status
// result.data.top_up_usages[].created_at
```
