查询用户余额
curl --request GET \
--url https://api.poyo.ai/api/user/balance \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.poyo.ai/api/user/balance"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.poyo.ai/api/user/balance', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.poyo.ai/api/user/balance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.poyo.ai/api/user/balance"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.poyo.ai/api/user/balance")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.poyo.ai/api/user/balance")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"code": 200,
"data": {
"email": "[email protected]",
"credits_amount": 17276
}
}{
"code": 401,
"error": {
"message": "Invalid API key",
"type": "authentication_error"
}
}{
"code": 429,
"error": {
"message": "Rate limit exceeded",
"type": "rate_limit_error"
}
}{
"code": 500,
"error": {
"message": "Internal server error",
"type": "server_error"
}
}账户管理
查询用户余额
查询你的用户账户积分余额
GET
/
api
/
user
/
balance
查询用户余额
curl --request GET \
--url https://api.poyo.ai/api/user/balance \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.poyo.ai/api/user/balance"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.poyo.ai/api/user/balance', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.poyo.ai/api/user/balance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.poyo.ai/api/user/balance"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.poyo.ai/api/user/balance")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.poyo.ai/api/user/balance")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"code": 200,
"data": {
"email": "[email protected]",
"credits_amount": 17276
}
}{
"code": 401,
"error": {
"message": "Invalid API key",
"type": "authentication_error"
}
}{
"code": 429,
"error": {
"message": "Rate limit exceeded",
"type": "rate_limit_error"
}
}{
"code": 500,
"error": {
"message": "Internal server error",
"type": "server_error"
}
}查询用户余额
实时查询你的用户账户当前积分余额。使用场景
控制台展示
在你的应用控制台中展示实时账户余额
余额提醒
积分低于阈值时发送通知
充值提醒
在积分用完前提示用户充值
用量追踪
监控积分消耗并追踪消费模式
重要说明
实时余额:返回的余额反映请求时刻的当前积分数量。
频率控制:避免过度轮询。缓存余额,仅在必要时刷新(例如完成一个生成任务之后)。
授权
所有 API 接口都需要 Bearer Token 认证。
创建 API Key:登录 PoYo,进入 仪表盘 → API 密钥(poyo.ai/zh/dashboard/api-key),点击创建 Key。
在请求头中添加:
Authorization: Bearer YOUR_API_KEY
响应
余额获取成功
Show child attributes
Show child attributes