Lingara Lingara 說明文件 學習指南 API 函式庫 App 建立 網頁版
語言: 繁體中文

取得剩餘額度

API 版本 2026-10-affable-towhee

get https://api.getlingara.com/v1/usage

列出適用於你帳戶的每項額度,包括已使用量及重設時間。

權限範圍 usage:read

參數

Lingara-Versionheaderstring選填
回應此要求所用的 API 版本。未提供時,存取權杖使用其用戶端綁定的版本,不帶權杖的要求使用目前版本。仍在開發中的版本只能透過在此指定來存取。未知版本會以 400 回應,代碼為 api_version_unknown。GET /v1/versions 會列出所有版本。

回應

200 你的額度

allowancearray of AllowanceRow必填
featurestring必填
windowstring必填
limitinteger必填
usedinteger必填
remaininginteger必填
reset_atinteger | null選填
ledgerUsageLedger | null選填

此用戶端自每月一日 UTC 午夜以來的呼叫次數與單位數。僅在按用量計費的用戶端上出現,其呼叫不消耗額度。可能比你最近一次呼叫延遲最多五秒。

sincestring必填
callsinteger必填
unitsinteger必填

錯誤

410application/json
回應此要求所用的 API 版本已停用。請在 Lingara-Version 中傳送一個受支援的版本,或將用戶端綁定到其他版本。
4XXapplication/json
要求遭到拒絕。code 說明原因,error 以文字描述原因。
503application/json · text/plain
服務暫時無法使用;請在 Retry-After 所示的秒數之後重試。維護期間,回應內文為純文字,而非錯誤封包。
5XXapplication/json
要求遭到拒絕。code 說明原因,error 以文字描述原因。
codestring必填

請求被拒絕的原因,以穩定的代碼表示,可據此進行分支處理:例如 insufficient_scope(403)、rate_limited(429),以及按用量計費的用戶端的 spend_cap_reached(402)和 metered_billing_inactive(402)。

errorstring必填

範例

程式碼範例語言

curl

curl "https://api.getlingara.com/v1/usage" \
  -H "Authorization: Bearer $LINGARA_TOKEN"

TypeScript

const usage = await client.getUsage();
for (const row of usage.allowance) {
  console.log(row.feature, row.window, `${row.remaining} of ${row.limit} left`);
}

Rust

let usage = client.get_usage().await?;
for row in &usage.allowance {
    println!("{} {}: {} of {} left", row.feature, row.window, row.remaining, row.limit);
}

Go

usage, err := client.GetUsage(ctx)
if err != nil {
	return err
}
for _, row := range usage.Value.Allowance {
	fmt.Printf("%s (%s): %d of %d left\n", row.Feature, row.Window, row.Remaining, row.Limit)
}

Java

import com.getlingara.client.model.AllowanceRow;
import com.getlingara.client.model.Usage;

Usage usage = client.getUsage().body();
for (AllowanceRow row : usage.getAllowance()) {
  System.out.println(
      row.getFeature()
          + " ("
          + row.getWindow()
          + "): "
          + row.getRemaining()
          + " of "
          + row.getLimit()
          + " left");
}

Kotlin

val usage = client.getUsage().body
for (row in usage.allowance) {
    println("${row.feature} (${row.window}): ${row.remaining} of ${row.limit} left")
}

Ruby

usage = client.get_usage.value
usage.allowance.each { |row| puts "#{row.feature} (#{row.window}): #{row.remaining} of #{row.limit} left" }
puts "#{usage.ledger.calls} calls this month" if usage.ledger

PHP

foreach ($client->getUsage()->value->getAllowance() as $row) {
    echo $row->getFeature(), ': ', $row->getRemaining(), ' of ', $row->getLimit(), ' left this ', $row->getWindow(), "\n";
}

想用函式庫?請參閱「函式庫」一節。

如譯文與英文參考文件有出入,以英文參考文件為準。