篮球联赛数据api示例

简介: 篮球联赛数据api示例

分享之前调用过的体育数据api,可注册使用下篮球联赛数据,在线文档

import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
 
/**
 * @API: 4.联赛、赛事资料
 * @Website: https://www.feijing88.com
 */
public class BasketballLeagueInfo {
 
    public static void main(String[] args) {
        try {
            String content = getContent();
 
            JAXBContext jaxbContext = JAXBContext.newInstance(LeagueList.class);
            Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
 
            LeagueList list = (LeagueList) unmarshaller.unmarshal(new ByteArrayInputStream(content.getBytes()));
            list.getLeagueList().forEach(System.out::println);
 
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }
 
    /**
     * 获取API返回内容
     * <p>
     * Note: 这里为了方便测试我使用了一份本地文件,使用时应替换为真实接口返回内容
     */
    private static String getContent() {
        try {
            StringBuilder builder = new StringBuilder();
            List<String> lines = Files.readAllLines(Paths.get("./src/main/resources/BasketballLeagueInfo.xml"), StandardCharsets.UTF_8);
            lines.forEach(builder::append);
            return builder.toString();
        } catch (Throwable t) {
            t.printStackTrace();
            return "";
        }
    }
 
    @XmlRootElement(name = "list")
    public static class LeagueList {
        @XmlElement(name = "match")
        private List<League> leagueList;
 
        public List<League> getLeagueList() {
            return leagueList;
        }
    }
 
    public static class League {
        @XmlElement(name = "id")
        private String id;
        @XmlElement(name = "short")
        private String nameShort;
        @XmlElement(name = "gb")
        private String nameGb;
        @XmlElement(name = "big")
        private String nameBig;
        @XmlElement(name = "en")
        private String nameEn;
        @XmlElement(name = "type")
        private int type;
        @XmlElement(name = "Curr_matchSeason")
        private String currentSeason;
        @XmlElement(name = "countryID")
        private String countryId;
        @XmlElement(name = "country")
        private String countryName;
        @XmlElement(name = "curr_year")
        private int currentYear;
        @XmlElement(name = "curr_month")
        private int currentMonth;
        @XmlElement(name = "sclass_kind")
        private int kind;
 
        @Override
        public String toString() {
            return "League{" +
                    "id='" + id + '\'' +
                    ", nameShort='" + nameShort + '\'' +
                    ", nameGb='" + nameGb + '\'' +
                    ", nameBig='" + nameBig + '\'' +
                    ", nameEn='" + nameEn + '\'' +
                    ", type=" + type +
                    ", currentSeason='" + currentSeason + '\'' +
                    ", countryId='" + countryId + '\'' +
                    ", countryName='" + countryName + '\'' +
                    ", currentYear=" + currentYear +
                    ", currentMonth=" + currentMonth +
                    ", kind=" + kind +
                    '}';
        }
    }
}

API 返回数据如下(部分):

League{id='2', nameShort='WNBA', nameGb='美国女子职业篮球联赛', nameBig='美國女子職業籃球聯賽', nameEn='Women’s National Basketball Association', type=4, currentSeason='19', countryId='1', countryName='美国', currentYear=2011, currentMonth=9, kind=1}
League{id='3', nameShort='斯坦杯', nameGb='斯坦科维奇洲际冠军杯', nameBig='斯坦科域治洲際冠軍盃', nameEn='Stank Vic Basketball Champions LeagueChampions Cup', type=4, currentSeason='18', countryId='20', countryName='国际赛事', currentYear=2011, currentMonth=8, kind=2}
League{id='5', nameShort='CBA', nameGb='中国男子篮球联赛', nameBig='中國男子籃球聯賽', nameEn='Chinese Basketball Association', type=4, currentSeason='18-19', countryId='2', countryName='中国', currentYear=2011, currentMonth=11, kind=1}
League{id='7', nameShort='Euro', nameGb='欧洲篮球冠军联赛', nameBig='歐洲籃球冠軍聯賽', nameEn='EURO', type=4, currentSeason='19-20', countryId='16', countryName='欧洲赛事', currentYear=2011, currentMonth=10, kind=2}
League{id='8', nameShort='NCAA', nameGb='美国大学男子篮球联赛', nameBig='美國大學男子籃球聯賽', nameEn='National Committee Association America', type=2, currentSeason='18-19', countryId='1', countryName='美国', currentYear=2009, currentMonth=11, kind=1}
League{id='9', nameShort='女南锦U17', nameGb='南美洲女子篮球锦标赛U17', nameBig='女南錦U17', nameEn='FIBA Sudamericano Femenino U17', type=4, currentSeason='17', countryId='18', countryName='美洲赛事', currentYear=2011, currentMonth=6, kind=2}
League{id='10', nameShort='篮世杯', nameGb='篮球世界杯', nameBig='籃球世界盃', nameEn='FIBA Basketball World Cup', type=4, currentSeason='19', countryId='20', countryName='国际赛事', currentYear=2010, currentMonth=8, kind=2}
League{id='13', nameShort='世女俱', nameGb='世女俱', nameBig='世女俱', nameEn='The world women Club', type=4, currentSeason='17', countryId='20', countryName='国际赛事', currentYear=2007, currentMonth=10, kind=2}
相关文章
|
2月前
|
JSON 安全 API
亚马逊商品列表API秘籍!轻松获取商品列表数据
亚马逊商品列表API(SP-API)提供标准化接口,支持通过关键词、分类、价格等条件搜索商品,获取ASIN、价格、销量等信息。采用OAuth 2.0认证与AWS签名,保障安全。数据以JSON格式传输,便于开发者批量获取与分析。
|
2月前
|
JSON 缓存 算法
如何通过API获取1688商品类目数据:技术实现指南
1688开放平台提供alibaba.category.get接口,支持获取全量商品类目树。RESTful架构,返回JSON数据,含类目ID、名称、层级等信息。需注册账号、创建应用并授权。请求需签名认证,QPS限10次,建议缓存更新周期≥24小时。
245 2
|
2月前
|
JSON 监控 API
小红书笔记评论API:一键获取分层评论与用户互动数据
小红书笔记评论API可获取指定笔记的评论详情,包括内容、点赞数、评论者信息等,支持分页与身份认证,返回JSON格式数据,适用于舆情监控、用户行为分析等场景。
|
2月前
|
JSON API 数据格式
淘宝拍立淘按图搜索API系列,json数据返回
淘宝拍立淘按图搜索API系列通过图像识别技术实现商品搜索功能,调用后返回的JSON数据包含商品标题、图片链接、价格、销量、相似度评分等核心字段,支持分页和详细商品信息展示。以下是该API接口返回的JSON数据示例及详细解析:
|
2月前
|
XML JSON API
苏宁商品详情API秘籍!轻松获取商品详情数据
苏宁商品详情API基于RESTful架构,支持JSON/XML格式,通过AppKey、AppSecret与签名三重认证,结合OAuth 2.0实现安全调用。开发者可获取商品名称、价格、销量、库存、促销等实时数据,适用于电商分析与商业智能。接口强制使用HTTPS协议,支持POST/GET请求,统一采用UTF-8编码,确保数据传输安全可靠。
|
2月前
|
自然语言处理 监控 API
速卖通商品详情API秘籍!轻松获取SKU属性数据
速卖通商品详情API(aliexpress.item.get)支持通过编程获取商品标题、价格、SKU、库存、销量、物流模板、评价及店铺信息,适用于价格监控、选品分析等场景。接口支持多语言返回,采用AppKey+AppSecret+Token认证,需签名验证,确保安全调用。
|
2月前
|
安全 API
亚马逊商品详情 API 秘籍!轻松获取 SKU 属性数据
亚马逊商品详情API是官方接口,通过ASIN获取商品标题、价格、库存、评价等50余项数据,支持多站点查询。包含Product Advertising API与MWS两类,分别用于商品信息获取和卖家店铺管理,采用AWS4-HMAC-SHA256认证,保障请求安全。
|
2月前
|
缓存 监控 前端开发
顺企网 API 开发实战:搜索 / 详情接口从 0 到 1 落地(附 Elasticsearch 优化 + 错误速查)
企业API开发常陷参数、缓存、错误处理三大坑?本指南拆解顺企网双接口全流程,涵盖搜索优化、签名验证、限流应对,附可复用代码与错误速查表,助你2小时高效搞定开发,提升响应速度与稳定性。
|
2月前
|
JSON 算法 API
Python采集淘宝商品评论API接口及JSON数据返回全程指南
Python采集淘宝商品评论API接口及JSON数据返回全程指南
|
3月前
|
数据可视化 测试技术 API
从接口性能到稳定性:这些API调试工具,让你的开发过程事半功倍
在软件开发中,接口调试与测试对接口性能、稳定性、准确性及团队协作至关重要。随着开发节奏加快,传统方式已难满足需求,专业API工具成为首选。本文介绍了Apifox、Postman、YApi、SoapUI、JMeter、Swagger等主流工具,对比其功能与适用场景,并推荐Apifox作为集成度高、支持中文、可视化强的一体化解决方案,助力提升API开发与测试效率。