嗶哩嗶哩用戶資料 API (V2)
GET
API 端點健康狀態
24h 健康值
24h 平均耗時
最近檢查時間
健康 可用 少量可用 基本不可用 暫無資料
健康
正在載入健康狀態…
24 小時趨勢
30 天趨勢
檢索由UID標識的嗶哩嗶哩用戶資料。用於查找已知帳號以進行創作者研究、資料審覈或後續獲取該用戶的視頻。
請求參數
| 參數名 | 位置 | 類型 | 必填 | 預設值 | 說明 |
|---|---|---|---|---|---|
token |
query | string |
是 | - | API 的訪問令牌。 |
uid |
query | string |
是 | - | 嗶哩嗶哩用戶ID (UID)。 |
程式碼範例
bash
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/bilibili/get-user-detail/v2?token=YOUR_API_KEY&uid=VALUE'
text
我想使用 JustOneAPI 提供的“用戶資料 (V2)”接口。
接入地址: https://api.justoneapi.com。
接口路徑: /api/bilibili/get-user-detail/v2?token=YOUR_API_KEY&uid=VALUE
接口地址: BASE_URL + /api/bilibili/get-user-detail/v2?token=YOUR_API_KEY&uid=VALUE
HTTP 方法: GET
身份驗證: 在 URL 中傳入 token 查詢參數。
OpenAPI 定義: https://docs.justoneapi.com/openapi/bilibili/user-profile-v2-zh-hant.json
請求參數說明:
- token (query): API 的訪問令牌。 (必填)
- uid (query): 嗶哩嗶哩用戶ID (UID)。 (必填)
返回格式: 請根據實際 Content-Type 安全處理 JSON 或文本回應。
回應處理與錯誤代碼:
1. 需通過返回體中的 "code" 欄位判斷業務結果(code 為 0 表示成功)。
2. 逾時建議:建議將請求逾時時間設置為 120 秒;如果 120 秒偏長,請至少設置為 60 秒,但可能會有少量請求因逾時而未接收到結果。
3. 業務碼說明:
- 0: 成功
- 100: Token 無效或已失效
- 301: 採集失敗,請重試
- 302: 超出速率限制
- 303: 超出每日配額
- 400: 參數錯誤
- 500: 內部伺服器錯誤
- 600: 權限不足
- 601: 帳戶餘額不足
- 602: TOKEN 限額超限
4. code 601 表示帳戶共享餘額不足。code 602 表示當前 API TOKEN 自身的累計消費上限已達到。TOKEN 限額不是資金劃撥,多個 TOKEN 仍共享同一個帳戶餘額。
請幫我用我擅長的編程語言寫一個腳本來呼叫這個接口,並處理返回結果。
python
import requests
BASE_URL = "https://api.justoneapi.com" # 由 OpenAPI servers 提供
url = BASE_URL + "/api/bilibili/get-user-detail/v2?token=YOUR_API_KEY&uid=VALUE"
response = requests.get(url, timeout=120)
print(response.status_code)
if response.content:
content_type = response.headers.get("content-type", "").lower()
if "json" in content_type:
try:
print(response.json())
except ValueError:
print(response.text)
elif content_type.startswith("text/") or "xml" in content_type or content_type.split(";", 1)[0].strip() in {"application/javascript", "application/x-www-form-urlencoded", "application/graphql"}:
print(response.text)
else:
with open("response.bin", "wb") as output:
output.write(response.content)
print(f"Saved {len(response.content)} bytes to response.bin")
js
const BASE_URL = "https://api.justoneapi.com"; // 由 OpenAPI servers 提供
const url = BASE_URL + "/api/bilibili/get-user-detail/v2?token=YOUR_API_KEY&uid=VALUE";
const response = await fetch(url, {
method: "GET",
signal: AbortSignal.timeout(120000)
});
console.log(response.status);
const responseBytes = await response.arrayBuffer();
if (responseBytes.byteLength) {
const contentType = (response.headers.get("content-type") || "").toLowerCase();
const mediaType = contentType.split(";", 1)[0].trim();
const textual = contentType.startsWith("text/") || contentType.includes("json") || contentType.includes("xml") || ["application/javascript", "application/x-www-form-urlencoded", "application/graphql"].includes(mediaType);
if (textual) {
const responseText = new TextDecoder().decode(responseBytes);
let data = responseText;
if (contentType.includes("json")) {
try { data = JSON.parse(responseText); } catch { /* Keep the raw body. */ }
}
console.log(data);
} else {
console.log(`Received ${responseBytes.byteLength} binary bytes`);
}
}
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
public class Main {
public static void main(String[] args) throws Exception {
final String BASE_URL = "https://api.justoneapi.com"; // 由 OpenAPI servers 提供
final String url = BASE_URL + "/api/bilibili/get-user-detail/v2?token=YOUR_API_KEY&uid=VALUE";
HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(120)).build();
HttpRequest.Builder builder = HttpRequest.newBuilder()
.uri(URI.create(url))
.timeout(Duration.ofSeconds(120))
.method("GET", HttpRequest.BodyPublishers.noBody());
HttpRequest request = builder.build();
HttpResponse<byte[]> response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
System.out.println(response.statusCode());
String contentType = response.headers().firstValue("content-type").orElse("").toLowerCase();
String mediaType = contentType.split(";", 2)[0].trim();
if (contentType.startsWith("text/") || contentType.contains("json") || contentType.contains("xml") || mediaType.equals("application/javascript") || mediaType.equals("application/x-www-form-urlencoded") || mediaType.equals("application/graphql")) {
System.out.println(new String(response.body(), StandardCharsets.UTF_8));
} else {
Files.write(Path.of("response.bin"), response.body());
System.out.println("Saved " + response.body().length + " bytes to response.bin");
}
}
}
go
package main
import (
"fmt"
"io"
"os"
"strings"
"net/http"
"time"
)
const BASE_URL = "https://api.justoneapi.com" // 由 OpenAPI servers 提供
func main() {
client := &http.Client{Timeout: 120 * time.Second}
url := BASE_URL + "/api/bilibili/get-user-detail/v2?token=YOUR_API_KEY&uid=VALUE"
req, _ := http.NewRequest("GET", url, nil)
resp, _ := client.Do(req)
defer resp.Body.Close()
fmt.Println(resp.StatusCode)
bodyBytes, _ := io.ReadAll(resp.Body)
contentType := strings.ToLower(resp.Header.Get("Content-Type"))
mediaType := strings.TrimSpace(strings.SplitN(contentType, ";", 2)[0])
if strings.HasPrefix(contentType, "text/") || strings.Contains(contentType, "json") || strings.Contains(contentType, "xml") || mediaType == "application/javascript" || mediaType == "application/x-www-form-urlencoded" || mediaType == "application/graphql" {
fmt.Println(string(bodyBytes))
} else {
os.WriteFile("response.bin", bodyBytes, 0600)
fmt.Printf("Saved %d bytes to response.bin\n", len(bodyBytes))
}
}
php
<?php
$BASE_URL = 'https://api.justoneapi.com'; // 由 OpenAPI servers 提供
$url = $BASE_URL . '/api/bilibili/get-user-detail/v2?token=YOUR_API_KEY&uid=VALUE';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$contentType = strtolower((string) curl_getinfo($ch, CURLINFO_CONTENT_TYPE));
curl_close($ch);
echo $status . PHP_EOL;
$mediaType = trim(explode(';', $contentType, 2)[0]);
if (str_starts_with($contentType, 'text/') || str_contains($contentType, 'json') || str_contains($contentType, 'xml') || in_array($mediaType, ['application/javascript', 'application/x-www-form-urlencoded', 'application/graphql'], true)) {
echo $response;
} else {
file_put_contents('response.bin', $response);
echo 'Saved ' . strlen($response) . ' bytes to response.bin' . PHP_EOL;
}
返回欄位
業務成功時(code = 0)的主要返回欄位。
用戶資料14 個欄位
data.space.info
個人空間展示的用戶資料。
| 欄位 | 類型 | 說明 |
|---|---|---|
mid |
integer |
用戶資料中的 B 站 UID。 |
name |
string |
個人空間展示的用戶名。 |
face |
string |
用戶頭像地址。 |
sign |
string |
個人空間展示的簡介,可以為空字符串。 |
sex |
string |
用戶資料展示的性別標籤。 |
birthday |
string |
存在時返回的用戶資料生日展示文本。 |
level |
integer |
用戶資料中的 B 站帳號等級。 |
top_photo |
string |
個人空間封面圖片地址。 |
top_photo_v2 |
object |
個人空間封面的圖片版本。 |
top_photo_v2.sid |
integer |
個人空間所用封面的標識。 |
top_photo_v2.l_img |
string |
個人空間大尺寸封面圖片地址。 |
top_photo_v2.l_200h_img |
string |
個人空間封面的 200 高度版本圖片地址。 |
tags |
array | null |
用戶資料展示的標籤,存在時返回。 |
tags[] |
string |
結果中的一個用戶資料標籤。 |
認證16 個欄位
data.space.info
| 欄位 | 類型 | 說明 |
|---|---|---|
certificate_show |
boolean |
返回資料是否標明展示認證信息。 |
official |
object |
接口返回的用戶官方認證信息。 |
official.role |
integer |
接口返回的官方認證角色代碼。 |
official.type |
integer |
接口返回的官方認證類型代碼。 |
official.title |
string |
用戶資料展示的官方認證標題。 |
official.desc |
string |
存在時返回的官方認證說明。 |
attestation |
object |
用戶資料展示的認證標籤與圖標。 |
attestation.type |
integer |
接口返回的用戶認證類型代碼。 |
attestation.icon |
string |
存在時返回的認證圖標地址。 |
attestation.desc |
string |
認證展示對應的說明文本。 |
attestation.common_info |
object |
認證標題與前綴信息。 |
attestation.common_info.title |
string |
認證標籤展示的標題。 |
attestation.common_info.prefix |
string |
認證標籤返回的前綴。 |
attestation.common_info.prefix_title |
string |
認證前綴對應的標題。 |
attestation.splice_info |
object |
組合後的認證展示信息。 |
attestation.splice_info.title |
string |
認證展示中的組合標題。 |
大會員13 個欄位
data.space.info.vip
用戶資料中的大會員信息。
| 欄位 | 類型 | 說明 |
|---|---|---|
type |
integer |
接口返回的用戶大會員類型代碼。 |
status |
integer |
接口返回的用戶大會員狀態代碼。 |
due_date |
integer |
大會員到期時間戳值,可以為 0。 |
nickname_color |
string |
大會員樣式所用的暱稱顏色。 |
label |
object |
隨用戶資料返回的大會員標籤信息。 |
label.text |
string |
大會員標籤展示的文本。 |
label.label_id |
integer |
用戶資料中的大會員標籤標識。 |
label.label_goto |
object | null |
大會員標籤關聯的跳轉地址,存在時返回。 |
label.label_goto.mobile |
string |
移動端大會員標籤的跳轉地址。 |
label.label_goto.pc_web |
string |
桌面網頁端大會員標籤的跳轉地址。 |
label.img_label_uri_hans |
string |
簡體中文大會員標籤圖片地址。 |
label.img_label_uri_hans_static |
string |
簡體中文大會員標籤靜態圖片地址。 |
label.img_label_uri_hant_static |
string |
繁體中文大會員標籤靜態圖片地址。 |
勳章與頭像掛件23 個欄位
data.space.info
| 欄位 | 類型 | 說明 |
|---|---|---|
nameplate |
object |
帳號個人資料展示的勳章。 |
nameplate.nid |
integer |
所展示勳章的標識。 |
nameplate.name |
string |
所展示勳章的名稱。 |
nameplate.image |
string |
勳章圖片地址。 |
nameplate.image_small |
string |
小尺寸勳章圖片地址。 |
nameplate.level |
string |
勳章的等級標籤。 |
nameplate.condition |
string |
勳章獲得條件的展示文本。 |
pendant |
object |
用戶資料展示的頭像掛件信息。 |
pendant.pid |
integer |
用戶資料中的頭像掛件標識。 |
pendant.name |
string |
頭像掛件名稱。 |
pendant.image |
string |
頭像掛件圖片地址。 |
pendant.image_enhance |
string |
存在時返回的頭像掛件增強版圖片地址。 |
fans_badge |
boolean |
接口返回的用戶粉絲標識狀態。 |
fans_medal |
object |
用戶資料展示的粉絲勳章信息。 |
fans_medal.show |
boolean |
粉絲勳章是否標明在個人資料中展示。 |
fans_medal.wear |
boolean |
個人資料是否標明佩戴了粉絲勳章。 |
fans_medal.detail |
object | null |
存在時返回的粉絲勳章詳細信息。 |
fans_medal.detail.medal_id |
integer |
所展示粉絲勳章的標識。 |
fans_medal.detail.medal_name |
string |
詳細信息中的粉絲勳章名稱。 |
fans_medal.detail.level |
integer |
詳細信息中的粉絲勳章等級。 |
fans_medal.medal |
object | null |
存在時返回的粉絲勳章展示信息。 |
fans_medal.medal.medal_name |
string |
界面展示的粉絲勳章名稱。 |
fans_medal.medal.level |
integer |
界面展示的粉絲勳章等級。 |
直播與充電16 個欄位
data.space.info
| 欄位 | 類型 | 說明 |
|---|---|---|
live_room |
object | null |
存在時返回的個人資料直播間信息。 |
live_room.roomid |
integer |
B 站直播間 ID。 |
live_room.roomStatus |
integer |
接口返回的直播間可用狀態代碼。 |
live_room.liveStatus |
integer |
接口返回的直播間開播狀態代碼。 |
live_room.title |
string |
直播間展示的標題。 |
live_room.cover |
string |
直播間封面圖片地址。 |
live_room.url |
string |
直播間地址。 |
live_room.watched_show |
object |
直播間關聯的觀看人數展示信息。 |
live_room.watched_show.num |
integer |
直播間觀看人數展示中的數值。 |
live_room.watched_show.text_small |
string |
直播間展示的簡短觀看人數文本。 |
live_room.watched_show.text_large |
string |
直播間展示的完整觀看人數文本。 |
elec |
object |
個人資料中的充電支持區信息。 |
elec.show_info |
object |
充電支持區的展示信息。 |
elec.show_info.show |
boolean |
充電支持區是否標明展示。 |
elec.show_info.title |
string |
充電支持區展示的標題。 |
elec.show_info.total |
integer |
充電支持區展示的總數量。 |
空間動態1 個欄位
data.space.feedList
隨用戶資料返回的空間動態信息。
| 欄位 | 類型 | 說明 |
|---|---|---|
result |
array |
空間動態返回的條目。即使同時返回用戶資料,此數組也可能為空。 |
查詢結果2 個欄位
data
用戶空間查詢結果。部分成功回應只包含提示信息。
| 欄位 | 類型 | 說明 |
|---|---|---|
message |
string |
此次查詢未返回用戶空間時給出的提示信息。 |
space.mid |
integer |
返回的個人空間對應的 B 站 UID。 |
回應示例
正在載入回應範例…