Kunci API
Daftar API key
Gunakan CometAPI GET /api/token/ untuk mencantumkan API key untuk akun yang terautentikasi dengan pagination.
GET
/
api
/
token
/
cURL
curl "https://api.cometapi.com/api/token/?p=1&page_size=20" \
-H "Authorization: your-access-token"import requests
url = "https://api.cometapi.com/api/token/"
headers = {"Authorization": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.cometapi.com/api/token/', 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.cometapi.com/api/token/",
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: <api-key>"
],
]);
$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.cometapi.com/api/token/"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<api-key>")
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.cometapi.com/api/token/")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/api/token/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"success": true,
"message": "",
"data": {
"page": 1,
"page_size": 20,
"total": 1,
"items": [
{
"id": 1234,
"user_id": 5678,
"key": "$COMETAPI_KEY",
"status": 1,
"name": "production",
"created_time": 1766102400,
"accessed_time": 1766102400,
"expired_time": -1,
"remain_quota": 100000,
"unlimited_quota": false,
"model_limits_enabled": false,
"model_limits": "",
"allow_ips": null,
"used_quota": 0,
"group": "",
"cross_group_retry": false
}
]
}
}Gunakan endpoint ini untuk mencantumkan API key yang dimiliki oleh akun CometAPI yang terautentikasi. Key terbaru dikembalikan terlebih dahulu.
Buat personal access token di Console → Personal Settings, lalu kirimkan sebagai nilai mentah header
Authorization. Jangan tambahkan prefiks Bearer.Pagination
| Query parameter | Deskripsi |
|---|---|
p | Nomor halaman. Default adalah 1. |
page_size | Jumlah item per halaman. Nilai di atas 100 akan dibatasi menjadi 100. |
Status API key
| Status | Arti |
|---|---|
1 | Aktif |
2 | Dinonaktifkan |
3 | Kedaluwarsa |
4 | Habis |
Field yang dikembalikan
| Field | Tipe | Deskripsi |
|---|---|---|
id | integer | ID numerik API key. Gunakan nilai ini dengan Dapatkan satu API key, Perbarui API key, dan Hapus API key. |
key | string | Nilai API key yang dikembalikan oleh management API. Perlakukan ini sebagai rahasia dan gunakan sebagai Authorization: Bearer $COMETAPI_KEY untuk permintaan model. |
status | integer | Status operasional. Hanya 1 yang berarti key diaktifkan untuk permintaan model. |
name | string | Nama tampilan yang mudah dibaca pengguna untuk key ini. |
created_time | integer | Unix timestamp dalam detik saat key dibuat. |
accessed_time | integer | Unix timestamp dalam detik saat key terakhir digunakan. |
expired_time | integer | Unix timestamp dalam detik saat key kedaluwarsa. -1 berarti tidak ada kedaluwarsa. |
remain_quota | integer | Kuota tersisa dalam satuan kuota internal CometAPI. |
used_quota | integer | Kuota yang sudah digunakan oleh key ini dalam satuan kuota internal CometAPI. |
unlimited_quota | boolean | Apakah key melewati pemeriksaan kuota tersisa. |
model_limits_enabled | boolean | Apakah pembatasan model aktif untuk key ini. |
model_limits | string | model ID yang diizinkan oleh key ini, dipisahkan dengan koma, saat model_limits_enabled bernilai true. Kosong berarti tidak ada daftar model yang dikonfigurasi. |
allow_ips | string or null | Daftar IP yang diizinkan sebagai satu string yang dipisahkan oleh baris baru. Setiap entri bisa berupa satu alamat IPv4, satu alamat IPv6, IPv4 CIDR, atau IPv6 CIDR. null atau "" berarti tidak ada pembatasan IP. |
group | string | Pembatasan grup akun. Kosong berarti tidak ada pembatasan grup eksplisit. |
cross_group_retry | boolean | Apakah percobaan ulang lintas grup diaktifkan untuk perutean grup otomatis. |
Otorisasi
Personal access token copied from CometAPI Console > Personal Settings. Send the raw token value; do not prefix it with Bearer.
Parameter Query
Page number to return. Defaults to 1.
Rentang yang diperlukan:
x >= 1Number of keys per page. Values above 100 are capped at 100 by the backend.
Rentang yang diperlukan:
1 <= x <= 100⌘I
cURL
curl "https://api.cometapi.com/api/token/?p=1&page_size=20" \
-H "Authorization: your-access-token"import requests
url = "https://api.cometapi.com/api/token/"
headers = {"Authorization": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.cometapi.com/api/token/', 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.cometapi.com/api/token/",
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: <api-key>"
],
]);
$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.cometapi.com/api/token/"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<api-key>")
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.cometapi.com/api/token/")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/api/token/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"success": true,
"message": "",
"data": {
"page": 1,
"page_size": 20,
"total": 1,
"items": [
{
"id": 1234,
"user_id": 5678,
"key": "$COMETAPI_KEY",
"status": 1,
"name": "production",
"created_time": 1766102400,
"accessed_time": 1766102400,
"expired_time": -1,
"remain_quota": 100000,
"unlimited_quota": false,
"model_limits_enabled": false,
"model_limits": "",
"allow_ips": null,
"used_quota": 0,
"group": "",
"cross_group_retry": false
}
]
}
}