电竞CSGO数据API接口 - 【即时指数】API调用示例代码

CSGO的【即时指数】api接口调用示例,在线文档查看,需注册下

mport com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
 
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
 
/**
 * @API: 赔率信息
 * @Website: https://www.feijing88.com
 */
public class CsgoBet {
 
 
    public static void main(String[] args) {
        try {
            String content = getContent();
            Respond rsp = JSON.parseObject(content, Respond.class);
            System.out.println(rsp.code);
            System.out.println(rsp.message);
            rsp.getData().forEach(System.out::println);
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }
 
    /**
     * 获取API返回内容
     * 

* Note: 这里为了方便测试我使用了一份本地文件,使用时应替换为真实接口返回内容 */ private static String getContent() { try { StringBuilder builder = new StringBuilder(); List lines = Files.readAllLines(Paths.get("./src/main/resources/CsgoBet.json"), StandardCharsets.UTF_8); lines.forEach(builder::append); return builder.toString(); } catch (Throwable t) { t.printStackTrace(); return ""; } } public static class Respond { @JSONField private int code; @JSONField private String message; @JSONField private List data; public int getCode() { return code; } public void setCode(int code) { this.code = code; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public List getData() { return data; } public void setData(List data) { this.data = data; } } public static class Bet { @JSONField private String betId; @JSONField private String matchId; @JSONField private String title; @JSONField private long endTime; @JSONField private int status; @JSONField private String resultId; @JSONField private List options; @JSONField private int betType; @JSONField private int boardNum; @JSONField private String typeDesc; @Override public String toString() { return "Bet{" + "betId='" + betId + '\'' + ", matchId='" + matchId + '\'' + ", title='" + title + '\'' + ", endTime=" + endTime + ", status=" + status + ", resultId='" + resultId + '\'' + ", options=" + options + ", betType=" + betType + ", boardNum=" + boardNum + ", typeDesc='" + typeDesc + '\'' + '}'; } public void setBetId(String betId) { this.betId = betId; } public void setMatchId(String matchId) { this.matchId = matchId; } public void setTitle(String title) { this.title = title; } public void setEndTime(long endTime) { this.endTime = endTime; } public void setStatus(int status) { this.status = status; } public void setResultId(String resultId) { this.resultId = resultId; } public void setOptions(List options) { this.options = options; } public void setBetType(int betType) { this.betType = betType; } public void setBoardNum(int boardNum) { this.boardNum = boardNum; } public void setTypeDesc(String typeDesc) { this.typeDesc = typeDesc; } } public static class Options { @JSONField private String betItemId; @JSONField private String teamId; @JSONField private String name; @JSONField private String odds; @Override public String toString() { return "Options{" + "betItemId='" + betItemId + '\'' + ", teamId='" + teamId + '\'' + ", name='" + name + '\'' + ", odds='" + odds + '\'' + '}'; } public void setBetItemId(String betItemId) { this.betItemId = betItemId; } public void setTeamId(String teamId) { this.teamId = teamId; } public void setName(String name) { this.name = name; } public void setOdds(String odds) { this.odds = odds; } } }

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

200
成功
Bet{betId='7887031-8', matchId='7887031', title='全场获胜', endTime=1554184800000, status=1, resultId='null', options=[Options{betItemId='2332075-3-1', teamId='9966', name='NiP', odds='1'}, Options{betItemId='2332075-3-2', teamId='3202', name='ViCi', odds='13.51'}], betType=1, boardNum=0, typeDesc=''}
Bet{betId='7887031-62', matchId='7887031', title='全场获胜', endTime=1554184800000, status=1, resultId='null', options=[Options{betItemId='2332075-16-1', teamId='9966', name='NiP', odds='1'}, Options{betItemId='2332075-16-2', teamId='3202', name='ViCi', odds='13.51'}], betType=1, boardNum=0, typeDesc=''}
Bet{betId='7887031-3', matchId='7887031', title='全场获胜', endTime=1554184800000, status=1, resultId='null', options=[Options{betItemId='2332075-7-1', teamId='9966', name='NiP', odds='1.01'}, Options{betItemId='2332075-7-2', teamId='3202', name='ViCi', odds='14'}], betType=1, boardNum=0, typeDesc=''}
Bet{betId='7887031-66', matchId='7887031', title='全场获胜', endTime=1554184800000, status=1, resultId='null', options=[Options{betItemId='2332075-11-1', teamId='9966', name='NiP', odds='1.01'}, Options{betItemId='2332075-11-2', teamId='3202', name='ViCi', odds='14'}], betType=1, boardNum=0, typeDesc=''}
Bet{betId='7887031-69', matchId='7887031', title='全场获胜', endTime=1554184800000, status=1, resultId='null', options=[Options{betItemId='2332075-14-1', teamId='9966', name='NiP', odds='1'}, Options{betItemId='2332075-14-2', teamId='3202', name='ViCi', odds='11'}], betType=1, boardNum=0, typeDesc=''}
Bet{betId='7887031-2', matchId='7887031', title='全场获胜', endTime=1554184800000, status=1, resultId='null', options=[Options{betItemId='2332075-6-1', teamId='9966', name='NiP', odds='1.22'}, Options{betItemId='2332075-6-2', teamId='3202', name='ViCi', odds='4'}], betType=1, boardNum=0, typeDesc=''}

你可能感兴趣的:(php,c#,python)