---
title: "Twitter熱門話題 API (V1)"
description: "獲取某個國家/地區當前的 X（Twitter）熱門話題，預設為美國。可用於發現市場中的熱門話題。"
lastUpdated: false
aiUsagePrompt: true
---

# Twitter熱門話題 API \(V1\)

<ApiTester
  method="GET"
  :path='JSON.parse("\"/api/twitter/get-trends/v1\"")'
  :summary='JSON.parse("\"熱門話題 (V1)\"")'
  openapiDefinitionUrl="https://docs.justoneapi.com/openapi/twitter/trending-topics-v1-zh-hant.json"
  openapiVersion="3.1.0"
  :parameters='JSON.parse("[{\"name\":\"token\",\"in\":\"query\",\"description\":\"訪問API所需的鑑權令牌。\",\"required\":true,\"schema\":{\"type\":\"string\"}},{\"name\":\"country\",\"in\":\"query\",\"description\":\"要獲取熱門話題的國家/地區。\\n\\n可用值：\\n- `UnitedStates`: UnitedStates\\n- `China`: China\\n- `India`: India\\n- `Japan`: Japan\\n- `Russia`: Russia\\n- `Germany`: Germany\\n- `Indonesia`: Indonesia\\n- `Brazil`: Brazil\\n- `France`: France\\n- `UnitedKingdom`: UnitedKingdom\\n- `Turkey`: Turkey\\n- `Italy`: Italy\\n- `Mexico`: Mexico\\n- `SouthKorea`: SouthKorea\\n- `Canada`: Canada\\n- `Spain`: Spain\\n- `SaudiArabia`: SaudiArabia\\n- `Egypt`: Egypt\\n- `Australia`: Australia\\n- `Poland`: Poland\\n- `Iran`: Iran\\n- `Pakistan`: Pakistan\\n- `Vietnam`: Vietnam\\n- `Nigeria`: Nigeria\\n- `Bangladesh`: Bangladesh\\n- `Netherlands`: Netherlands\\n- `Argentina`: Argentina\\n- `Philippines`: Philippines\\n- `Malaysia`: Malaysia\\n- `Colombia`: Colombia\\n- `UniteArabEmirates`: United Arab Emirates\\n- `Romania`: Romania\\n- `Belgium`: Belgium\\n- `Switzerland`: Switzerland\\n- `Singapore`: Singapore\\n- `Sweden`: Sweden\\n- `Norway`: Norway\\n- `Austria`: Austria\\n- `Kazakhstan`: Kazakhstan\\n- `Algeria`: Algeria\\n- `Chile`: Chile\\n- `Czechia`: Czechia\\n- `Peru`: Peru\\n- `Iraq`: Iraq\\n- `Israel`: Israel\\n- `Ukraine`: Ukraine\\n- `Denmark`: Denmark\\n- `Portugal`: Portugal\\n- `Hungary`: Hungary\\n- `Greece`: Greece\\n- `Finland`: Finland\\n- `NewZealand`: NewZealand\\n- `Belarus`: Belarus\\n- `Slovakia`: Slovakia\\n- `Serbia`: Serbia\\n- `Lithuania`: Lithuania\\n- `Luxembourg`: Luxembourg\\n- `Estonia`: Estonia\",\"required\":false,\"schema\":{\"type\":\"string\",\"default\":\"UnitedStates\",\"description\":\"X (Twitter) 熱門話題的國家/地區\",\"enum\":[\"UnitedStates\",\"China\",\"India\",\"Japan\",\"Russia\",\"Germany\",\"Indonesia\",\"Brazil\",\"France\",\"UnitedKingdom\",\"Turkey\",\"Italy\",\"Mexico\",\"SouthKorea\",\"Canada\",\"Spain\",\"SaudiArabia\",\"Egypt\",\"Australia\",\"Poland\",\"Iran\",\"Pakistan\",\"Vietnam\",\"Nigeria\",\"Bangladesh\",\"Netherlands\",\"Argentina\",\"Philippines\",\"Malaysia\",\"Colombia\",\"UniteArabEmirates\",\"Romania\",\"Belgium\",\"Switzerland\",\"Singapore\",\"Sweden\",\"Norway\",\"Austria\",\"Kazakhstan\",\"Algeria\",\"Chile\",\"Czechia\",\"Peru\",\"Iraq\",\"Israel\",\"Ukraine\",\"Denmark\",\"Portugal\",\"Hungary\",\"Greece\",\"Finland\",\"NewZealand\",\"Belarus\",\"Slovakia\",\"Serbia\",\"Lithuania\",\"Luxembourg\",\"Estonia\"]}}]")'
  :requestBody='JSON.parse("null")'
  :responses='JSON.parse("{\"200\":{\"description\":\"好的\",\"content\":{\"application/json\":{\"schema\":{\"if\":{\"properties\":{\"code\":{\"const\":0}},\"required\":[\"code\"]},\"then\":{\"properties\":{\"data\":{\"type\":\"object\",\"description\":\"所請求國家/地區的熱門話題載荷。\",\"properties\":{\"trends\":{\"type\":\"array\",\"description\":\"所選擇國家/地區的熱門話題，按返回順序排列。\",\"items\":{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\",\"description\":\"話題名稱或話題標籤。\"},\"context\":{\"type\":\"string\",\"description\":\"趨勢的顯示標籤，可能包含分類。\"},\"description\":{\"description\":\"趨勢的附加描述（若提供）。可能為 null。\"}}}}},\"required\":[\"trends\"]}}},\"allOf\":[{\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"integer\",\"format\":\"int32\",\"enum\":[0,100,101,202,300,301,302,303,400,404,500,503,600,601,602]},\"message\":{\"type\":[\"string\",\"null\"]},\"data\":{},\"recordTime\":{\"type\":[\"string\",\"null\"]},\"requestId\":{\"type\":\"string\"},\"reason\":{\"type\":\"string\"},\"requestParams\":{\"type\":\"object\",\"properties\":{\"query\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"object\"}},\"body\":{\"type\":\"object\",\"properties\":{\"empty\":{\"type\":\"boolean\"},\"array\":{\"type\":\"boolean\"},\"null\":{\"type\":\"boolean\"},\"object\":{\"type\":\"boolean\"},\"float\":{\"type\":\"boolean\"},\"integralNumber\":{\"type\":\"boolean\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"type\":\"boolean\"},\"bigDecimal\":{\"type\":\"boolean\"},\"bigInteger\":{\"type\":\"boolean\"},\"textual\":{\"type\":\"boolean\",\"deprecated\":true},\"boolean\":{\"type\":\"boolean\"},\"binary\":{\"type\":\"boolean\"},\"number\":{\"type\":\"boolean\"},\"embeddedValue\":{\"type\":\"boolean\"}}}}}},\"required\":[\"code\",\"data\",\"message\",\"recordTime\"]}]}}}},\"400\":{\"description\":\"請求參數或請求本文無效\",\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"integer\",\"format\":\"int32\",\"enum\":[0,100,101,202,300,301,302,303,400,404,500,503,600,601,602]},\"message\":{\"type\":[\"string\",\"null\"]},\"data\":{},\"recordTime\":{\"type\":[\"string\",\"null\"]},\"requestId\":{\"type\":\"string\"},\"reason\":{\"type\":\"string\"},\"requestParams\":{\"type\":\"object\",\"properties\":{\"query\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"object\"}},\"body\":{\"type\":\"object\",\"properties\":{\"empty\":{\"type\":\"boolean\"},\"array\":{\"type\":\"boolean\"},\"null\":{\"type\":\"boolean\"},\"object\":{\"type\":\"boolean\"},\"float\":{\"type\":\"boolean\"},\"integralNumber\":{\"type\":\"boolean\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"type\":\"boolean\"},\"bigDecimal\":{\"type\":\"boolean\"},\"bigInteger\":{\"type\":\"boolean\"},\"textual\":{\"type\":\"boolean\",\"deprecated\":true},\"boolean\":{\"type\":\"boolean\"},\"binary\":{\"type\":\"boolean\"},\"number\":{\"type\":\"boolean\"},\"embeddedValue\":{\"type\":\"boolean\"}}}}}},\"required\":[\"code\",\"data\",\"message\",\"recordTime\"]}}}},\"401\":{\"description\":\"訪問令牌無效或未激活\",\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"integer\",\"format\":\"int32\",\"enum\":[0,100,101,202,300,301,302,303,400,404,500,503,600,601,602]},\"message\":{\"type\":[\"string\",\"null\"]},\"data\":{},\"recordTime\":{\"type\":[\"string\",\"null\"]},\"requestId\":{\"type\":\"string\"},\"reason\":{\"type\":\"string\"},\"requestParams\":{\"type\":\"object\",\"properties\":{\"query\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"object\"}},\"body\":{\"type\":\"object\",\"properties\":{\"empty\":{\"type\":\"boolean\"},\"array\":{\"type\":\"boolean\"},\"null\":{\"type\":\"boolean\"},\"object\":{\"type\":\"boolean\"},\"float\":{\"type\":\"boolean\"},\"integralNumber\":{\"type\":\"boolean\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"type\":\"boolean\"},\"bigDecimal\":{\"type\":\"boolean\"},\"bigInteger\":{\"type\":\"boolean\"},\"textual\":{\"type\":\"boolean\",\"deprecated\":true},\"boolean\":{\"type\":\"boolean\"},\"binary\":{\"type\":\"boolean\"},\"number\":{\"type\":\"boolean\"},\"embeddedValue\":{\"type\":\"boolean\"}}}}}},\"required\":[\"code\",\"data\",\"message\",\"recordTime\"]}}}},\"403\":{\"description\":\"權限不足\",\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"integer\",\"format\":\"int32\",\"enum\":[0,100,101,202,300,301,302,303,400,404,500,503,600,601,602]},\"message\":{\"type\":[\"string\",\"null\"]},\"data\":{},\"recordTime\":{\"type\":[\"string\",\"null\"]},\"requestId\":{\"type\":\"string\"},\"reason\":{\"type\":\"string\"},\"requestParams\":{\"type\":\"object\",\"properties\":{\"query\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"object\"}},\"body\":{\"type\":\"object\",\"properties\":{\"empty\":{\"type\":\"boolean\"},\"array\":{\"type\":\"boolean\"},\"null\":{\"type\":\"boolean\"},\"object\":{\"type\":\"boolean\"},\"float\":{\"type\":\"boolean\"},\"integralNumber\":{\"type\":\"boolean\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"type\":\"boolean\"},\"bigDecimal\":{\"type\":\"boolean\"},\"bigInteger\":{\"type\":\"boolean\"},\"textual\":{\"type\":\"boolean\",\"deprecated\":true},\"boolean\":{\"type\":\"boolean\"},\"binary\":{\"type\":\"boolean\"},\"number\":{\"type\":\"boolean\"},\"embeddedValue\":{\"type\":\"boolean\"}}}}}},\"required\":[\"code\",\"data\",\"message\",\"recordTime\"]}}}},\"429\":{\"description\":\"請求速率或每日配額已超限\",\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"integer\",\"format\":\"int32\",\"enum\":[0,100,101,202,300,301,302,303,400,404,500,503,600,601,602]},\"message\":{\"type\":[\"string\",\"null\"]},\"data\":{},\"recordTime\":{\"type\":[\"string\",\"null\"]},\"requestId\":{\"type\":\"string\"},\"reason\":{\"type\":\"string\"},\"requestParams\":{\"type\":\"object\",\"properties\":{\"query\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"object\"}},\"body\":{\"type\":\"object\",\"properties\":{\"empty\":{\"type\":\"boolean\"},\"array\":{\"type\":\"boolean\"},\"null\":{\"type\":\"boolean\"},\"object\":{\"type\":\"boolean\"},\"float\":{\"type\":\"boolean\"},\"integralNumber\":{\"type\":\"boolean\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"type\":\"boolean\"},\"bigDecimal\":{\"type\":\"boolean\"},\"bigInteger\":{\"type\":\"boolean\"},\"textual\":{\"type\":\"boolean\",\"deprecated\":true},\"boolean\":{\"type\":\"boolean\"},\"binary\":{\"type\":\"boolean\"},\"number\":{\"type\":\"boolean\"},\"embeddedValue\":{\"type\":\"boolean\"}}}}}},\"required\":[\"code\",\"data\",\"message\",\"recordTime\"]}}}},\"500\":{\"description\":\"伺服器內部錯誤\",\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"integer\",\"format\":\"int32\",\"enum\":[0,100,101,202,300,301,302,303,400,404,500,503,600,601,602]},\"message\":{\"type\":[\"string\",\"null\"]},\"data\":{},\"recordTime\":{\"type\":[\"string\",\"null\"]},\"requestId\":{\"type\":\"string\"},\"reason\":{\"type\":\"string\"},\"requestParams\":{\"type\":\"object\",\"properties\":{\"query\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"object\"}},\"body\":{\"type\":\"object\",\"properties\":{\"empty\":{\"type\":\"boolean\"},\"array\":{\"type\":\"boolean\"},\"null\":{\"type\":\"boolean\"},\"object\":{\"type\":\"boolean\"},\"float\":{\"type\":\"boolean\"},\"integralNumber\":{\"type\":\"boolean\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"type\":\"boolean\"},\"bigDecimal\":{\"type\":\"boolean\"},\"bigInteger\":{\"type\":\"boolean\"},\"textual\":{\"type\":\"boolean\",\"deprecated\":true},\"boolean\":{\"type\":\"boolean\"},\"binary\":{\"type\":\"boolean\"},\"number\":{\"type\":\"boolean\"},\"embeddedValue\":{\"type\":\"boolean\"}}}}}},\"required\":[\"code\",\"data\",\"message\",\"recordTime\"]}}}},\"503\":{\"description\":\"服務暫時不可用\",\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"integer\",\"format\":\"int32\",\"enum\":[0,100,101,202,300,301,302,303,400,404,500,503,600,601,602]},\"message\":{\"type\":[\"string\",\"null\"]},\"data\":{},\"recordTime\":{\"type\":[\"string\",\"null\"]},\"requestId\":{\"type\":\"string\"},\"reason\":{\"type\":\"string\"},\"requestParams\":{\"type\":\"object\",\"properties\":{\"query\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"object\"}},\"body\":{\"type\":\"object\",\"properties\":{\"empty\":{\"type\":\"boolean\"},\"array\":{\"type\":\"boolean\"},\"null\":{\"type\":\"boolean\"},\"object\":{\"type\":\"boolean\"},\"float\":{\"type\":\"boolean\"},\"integralNumber\":{\"type\":\"boolean\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"type\":\"boolean\"},\"bigDecimal\":{\"type\":\"boolean\"},\"bigInteger\":{\"type\":\"boolean\"},\"textual\":{\"type\":\"boolean\",\"deprecated\":true},\"boolean\":{\"type\":\"boolean\"},\"binary\":{\"type\":\"boolean\"},\"number\":{\"type\":\"boolean\"},\"embeddedValue\":{\"type\":\"boolean\"}}}}}},\"required\":[\"code\",\"data\",\"message\",\"recordTime\"]}}}}}")'
  :servers='JSON.parse("[{\"url\":\"https://api.justoneapi.com\",\"description\":\"全球生產 API（預設）\"}]")'
  :security='JSON.parse("[]")'
  :securitySchemes='JSON.parse("{}")'
  :schemas='JSON.parse("{}")'
/>

<ApiHealthSection :api='JSON.parse("\"/api/twitter/get-trends/v1\"")' />

<p>獲取某個國家/地區當前的 X（Twitter）熱門話題，預設為美國。可用於發現市場中的熱門話題。</p>

## 請求參數

<div class="api-doc-table api-doc-table--params">

| 參數名 | 位置 | 類型 | 必填 | 預設值 | 說明 |
| --- | --- | --- | --- | --- | --- |
| <code>token</code> | query | <code>string</code> | 是 | - | 訪問API所需的鑑權令牌。 |
| <code>country</code> | query | <code>string</code> | 否 | <code>UnitedStates</code> | 要獲取熱門話題的國家/地區。<br /><br><br>可用值：<br /><br>- <code>UnitedStates</code>: UnitedStates<br /><br>- <code>China</code>: China<br /><br>- <code>India</code>: India<br /><br>- <code>Japan</code>: Japan<br /><br>- <code>Russia</code>: Russia<br /><br>- <code>Germany</code>: Germany<br /><br>- <code>Indonesia</code>: Indonesia<br /><br>- <code>Brazil</code>: Brazil<br /><br>- <code>France</code>: France<br /><br>- <code>UnitedKingdom</code>: UnitedKingdom<br /><br>- <code>Turkey</code>: Turkey<br /><br>- <code>Italy</code>: Italy<br /><br>- <code>Mexico</code>: Mexico<br /><br>- <code>SouthKorea</code>: SouthKorea<br /><br>- <code>Canada</code>: Canada<br /><br>- <code>Spain</code>: Spain<br /><br>- <code>SaudiArabia</code>: SaudiArabia<br /><br>- <code>Egypt</code>: Egypt<br /><br>- <code>Australia</code>: Australia<br /><br>- <code>Poland</code>: Poland<br /><br>- <code>Iran</code>: Iran<br /><br>- <code>Pakistan</code>: Pakistan<br /><br>- <code>Vietnam</code>: Vietnam<br /><br>- <code>Nigeria</code>: Nigeria<br /><br>- <code>Bangladesh</code>: Bangladesh<br /><br>- <code>Netherlands</code>: Netherlands<br /><br>- <code>Argentina</code>: Argentina<br /><br>- <code>Philippines</code>: Philippines<br /><br>- <code>Malaysia</code>: Malaysia<br /><br>- <code>Colombia</code>: Colombia<br /><br>- <code>UniteArabEmirates</code>: United Arab Emirates<br /><br>- <code>Romania</code>: Romania<br /><br>- <code>Belgium</code>: Belgium<br /><br>- <code>Switzerland</code>: Switzerland<br /><br>- <code>Singapore</code>: Singapore<br /><br>- <code>Sweden</code>: Sweden<br /><br>- <code>Norway</code>: Norway<br /><br>- <code>Austria</code>: Austria<br /><br>- <code>Kazakhstan</code>: Kazakhstan<br /><br>- <code>Algeria</code>: Algeria<br /><br>- <code>Chile</code>: Chile<br /><br>- <code>Czechia</code>: Czechia<br /><br>- <code>Peru</code>: Peru<br /><br>- <code>Iraq</code>: Iraq<br /><br>- <code>Israel</code>: Israel<br /><br>- <code>Ukraine</code>: Ukraine<br /><br>- <code>Denmark</code>: Denmark<br /><br>- <code>Portugal</code>: Portugal<br /><br>- <code>Hungary</code>: Hungary<br /><br>- <code>Greece</code>: Greece<br /><br>- <code>Finland</code>: Finland<br /><br>- <code>NewZealand</code>: NewZealand<br /><br>- <code>Belarus</code>: Belarus<br /><br>- <code>Slovakia</code>: Slovakia<br /><br>- <code>Serbia</code>: Serbia<br /><br>- <code>Lithuania</code>: Lithuania<br /><br>- <code>Luxembourg</code>: Luxembourg<br /><br>- <code>Estonia</code>: Estonia |

</div>

## 程式碼範例

::: code-group

```bash [🐚 cURL]
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/twitter/get-trends/v1?token=YOUR_API_KEY'
```

```text [🤖 AI 提示詞]
我想使用 JustOneAPI 提供的“熱門話題 (V1)”接口。
接入地址: https://api.justoneapi.com。
接口路徑: /api/twitter/get-trends/v1?token=YOUR_API_KEY
接口地址: BASE_URL + /api/twitter/get-trends/v1?token=YOUR_API_KEY
HTTP 方法: GET
身份驗證: 在 URL 中傳入 token 查詢參數。
OpenAPI 定義: https://docs.justoneapi.com/openapi/twitter/trending-topics-v1-zh-hant.json

請求參數說明:
- token (query): 訪問API所需的鑑權令牌。 (必填)
- country (query): 要獲取熱門話題的國家/地區。

可用值：
- `UnitedStates`: UnitedStates
- `China`: China
- `India`: India
- `Japan`: Japan
- `Russia`: Russia
- `Germany`: Germany
- `Indonesia`: Indonesia
- `Brazil`: Brazil
- `France`: France
- `UnitedKingdom`: UnitedKingdom
- `Turkey`: Turkey
- `Italy`: Italy
- `Mexico`: Mexico
- `SouthKorea`: SouthKorea
- `Canada`: Canada
- `Spain`: Spain
- `SaudiArabia`: SaudiArabia
- `Egypt`: Egypt
- `Australia`: Australia
- `Poland`: Poland
- `Iran`: Iran
- `Pakistan`: Pakistan
- `Vietnam`: Vietnam
- `Nigeria`: Nigeria
- `Bangladesh`: Bangladesh
- `Netherlands`: Netherlands
- `Argentina`: Argentina
- `Philippines`: Philippines
- `Malaysia`: Malaysia
- `Colombia`: Colombia
- `UniteArabEmirates`: United Arab Emirates
- `Romania`: Romania
- `Belgium`: Belgium
- `Switzerland`: Switzerland
- `Singapore`: Singapore
- `Sweden`: Sweden
- `Norway`: Norway
- `Austria`: Austria
- `Kazakhstan`: Kazakhstan
- `Algeria`: Algeria
- `Chile`: Chile
- `Czechia`: Czechia
- `Peru`: Peru
- `Iraq`: Iraq
- `Israel`: Israel
- `Ukraine`: Ukraine
- `Denmark`: Denmark
- `Portugal`: Portugal
- `Hungary`: Hungary
- `Greece`: Greece
- `Finland`: Finland
- `NewZealand`: NewZealand
- `Belarus`: Belarus
- `Slovakia`: Slovakia
- `Serbia`: Serbia
- `Lithuania`: Lithuania
- `Luxembourg`: Luxembourg
- `Estonia`: Estonia

返回格式: 請根據實際 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 [🐍 Python]
import requests

BASE_URL = "https://api.justoneapi.com"  # 由 OpenAPI servers 提供

url = BASE_URL + "/api/twitter/get-trends/v1?token=YOUR_API_KEY"
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 [🌐 JavaScript]
const BASE_URL = "https://api.justoneapi.com"; // 由 OpenAPI servers 提供
const url = BASE_URL + "/api/twitter/get-trends/v1?token=YOUR_API_KEY";

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 [☕ 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/twitter/get-trends/v1?token=YOUR_API_KEY";

        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 [🐹 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/twitter/get-trends/v1?token=YOUR_API_KEY"
	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]
<?php
$BASE_URL = 'https://api.justoneapi.com'; // 由 OpenAPI servers 提供
$url = $BASE_URL . '/api/twitter/get-trends/v1?token=YOUR_API_KEY';

$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;
}
```

:::

<div style="text-align: right; margin-top: -20px; margin-bottom: 20px;">
<a href="/openapi/twitter/trending-topics-v1-zh-hant.json" target="_blank" style="font-size: 12px; color: var(--vp-c-text-3); text-decoration: none; opacity: 0.8;">[OpenAPI 定義 (JSON)]</a>
</div>

## 返回欄位

業務成功時（`code = 0`）的主要返回欄位。

<div class="api-doc-table api-doc-table--response">

| 欄位路徑 | 類型 | 說明 |
| --- | --- | --- |
| <code>data</code> | <code>object</code> | 所請求國家/地區的熱門話題載荷。 |
| <code>data.trends</code> | <code>array</code> | 所選擇國家/地區的熱門話題，按返回順序排列。 |
| <code>data.trends[]</code> | <code>object</code> | - |
| <code>data.trends[].name</code> | <code>string</code> | 話題名稱或話題標籤。 |
| <code>data.trends[].context</code> | <code>string</code> | 趨勢的顯示標籤，可能包含分類。 |
| <code>data.trends[].description</code> | - | 趨勢的附加描述（若提供）。可能為 null。 |

</div>

## 回應示例

<ApiExampleSection :api='JSON.parse("\"/api/twitter/get-trends/v1\"")' />

