人气排行分类
获取人气排行榜的标签分类配置,second_tags[].key 可传入 rank_list。
SDK Links
Python |
Rust |
Go |
Node.js |
Java |
C++ |
Parameters
SDK 方法参数。
此方法无参数。
Request Example
from longbridge.openapi import MarketContext, Config, OAuthBuilder
oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url))
config = Config.from_oauth(oauth)
ctx = MarketContext(config)
resp = ctx.rank_categories()
print(resp)import asyncio
from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder
async def main() -> None:
oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url))
config = Config.from_oauth(oauth)
ctx = AsyncMarketContext.create(config)
resp = await ctx.rank_categories()
print(resp)
if __name__ == "__main__":
asyncio.run(main())const { Config, MarketContext, OAuth } = require('longbridge')
async function main() {
const oauth = await OAuth.build('your-client-id', (_, url) => {
console.log('Open this URL to authorize: ' + url)
})
const config = Config.fromOAuth(oauth)
const ctx = MarketContext.new(config)
const resp = await ctx.rankCategories()
console.log(resp)
}
main().catch(console.error)import com.longbridge.*;
import com.longbridge.market.*;
class Main {
public static void main(String[] args) throws Exception {
try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get();
Config config = Config.fromOAuth(oauth);
MarketContext ctx = MarketContext.create(config)) {
var resp = ctx.getRankCategories().get();
System.out.println(resp);
}
}
}use std::sync::Arc;
use longbridge::{oauth::OAuthBuilder, market::MarketContext, Config};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let oauth = OAuthBuilder::new("your-client-id").build(|url| println!("Open: {url}")).await?;
let config = Arc::new(Config::from_oauth(oauth));
let ctx = MarketContext::new(config);
let resp = ctx.rank_categories().await?;
println!("{:?}", resp);
Ok(())
}#include <iostream>
#include <longbridge.hpp>
using namespace longbridge;
using namespace longbridge::market;
int main() {
OAuthBuilder("your-client-id").build(
[](const std::string& url) { std::cout << "Open: " << url << std::endl; },
[](auto res) {
if (!res) return;
Config config = Config::from_oauth(*res);
MarketContext ctx = MarketContext::create(config);
ctx.rank_categories([](auto resp) {
if (resp) std::cout << "OK" << std::endl;
});
});
std::cin.get();
}package main
import (
"context"
"fmt"
"log"
"github.com/longbridge/openapi-go/config"
"github.com/longbridge/openapi-go/oauth"
"github.com/longbridge/openapi-go/market"
)
func main() {
o := oauth.New("your-client-id").
OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) })
if err := o.Build(context.Background()); err != nil {
log.Fatal(err)
}
conf, err := config.New(config.WithOAuthClient(o))
if err != nil {
log.Fatal(err)
}
c, err := market.NewFromCfg(conf)
if err != nil {
log.Fatal(err)
}
defer c.Close()
resp, err := c.RankCategories(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", resp)
}Response
Response Example
{
"code": 0,
"message": "success",
"data": {
"first_tags": [
{
"key": "ib_hot",
"name": "热度排行",
"second_tags": [
{ "key": "ib_hot_all-us", "name": "美股总热度", "market": "US" },
{ "key": "ib_hot_all-hk", "name": "港股总热度", "market": "HK" },
{ "key": "ib_hot_all-cn", "name": "A 股总热度", "market": "CN" }
]
},
{
"key": "ib_change",
"name": "涨跌排行",
"second_tags": [
{ "key": "ib_change_top-us", "name": "美股涨幅榜", "market": "US" },
{ "key": "ib_change_top-hk", "name": "港股涨幅榜", "market": "HK" }
]
}
]
}
}
Response Status
| Status | Description | Schema |
|---|---|---|
| 200 | 成功 | RankCategoriesResponse |
| 400 | 请求错误 | None |
Schemas
RankCategoriesResponse
| Name | Type | Required | Description |
|---|---|---|---|
| first_tags | object[] | false | 一级分类列表 |
| ∟ key | string | false | 一级分类键值 |
| ∟ name | string | false | 一级分类名称 |
| ∟ second_tags | object[] | false | 二级分类列表 |
| ∟ ∟ key | string | false | 二级分类键值,可传入 rank_list 的 key 参数 |
| ∟ ∟ name | string | false | 二级分类名称 |
| ∟ ∟ market | string | false | 所属市场:US、HK、CN、SG |