电竞资讯
请求Header:
| 名称 | 值 | |
|---|---|---|
| Content-Type | application/x-www-form-urlencoded |
请求参数说明:
| 名称 | 必填 | 类型 | 说明 | |
|---|---|---|---|---|
| key | 是 | string | 您在聚合平台申请的接口凭证(可在个人中心进行查看) | |
| num | 否 | int | 返回数量1-50,默认10 | |
| page | 否 | int | 翻页 | |
| rand | 否 | int | 随机获取,默认:0,0:否,1:是 | |
| word | 否 | string | 检索关键词 |
请求代码示例:
curl -k -i "https://apis.juhe.cn/fapigx/esports/query?key=key&num =&page =&rand =&word ="
<?php
/**
* 1785-电竞资讯 - 代码参考(根据实际业务情况修改)
*/
// 基本参数配置
$apiUrl = "https://apis.juhe.cn/fapigx/esports/query"; // 接口请求URL
$method = "GET"; // 接口请求方式
$headers = ["Content-Type: application/x-www-form-urlencoded"]; // 接口请求header
$apiKey = "您申请的调用APIkey"; // 在个人中心->我的数据,接口名称上方查看
// 接口请求入参配置
$requestParams = [
'key' => $apiKey,
'num '=> '',
'page '=> '',
'rand '=> '',
'word '=> '',
];
$requestParamsStr = http_build_query($requestParams);
// 发起接口网络请求
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $apiUrl . '?' . $requestParamsStr);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
if (1 == strpos("$" . $apiUrl, "https://")) {
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
$response = curl_exec($curl);
$httpInfo = curl_getinfo($curl);
curl_close($curl);
// 解析响应结果
$responseResult = json_decode($response, true);
if ($responseResult) {
// 网络请求成功。可依据业务逻辑和接口文档说明自行处理。
var_dump($responseResult);
} else {
// 网络异常等因素,解析结果异常。可依据业务逻辑自行处理。
// var_dump($httpInfo);
var_dump("请求异常");
}
import requests
# 1785-电竞资讯 - 代码参考(根据实际业务情况修改)
# 基本参数配置
apiUrl = 'https://apis.juhe.cn/fapigx/esports/query' # 接口请求URL
apiKey = '您申请的调用APIkey' # 在个人中心->我的数据,接口名称上方查看
# 接口请求入参配置
requestParams = {
'key': apiKey,
'num ': '',
'page ': '',
'rand ': '',
'word ': '',
}
# 发起接口网络请求
response = requests.get(apiUrl, params=requestParams)
# 解析响应结果
if response.status_code == 200:
responseResult = response.json()
# 网络请求成功。可依据业务逻辑和接口文档说明自行处理。
print(responseResult)
else:
# 网络异常等因素,解析结果异常。可依据业务逻辑自行处理。
print('请求异常')
package main
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
)
func main() {
// 基本参数配置
apiUrl := "https://apis.juhe.cn/fapigx/esports/query"
apiKey := "您申请的调用APIkey"
// 接口请求入参配置
requestParams := url.Values{}
requestParams.Set("key", apiKey)
requestParams.Set("num ", "")
requestParams.Set("page ", "")
requestParams.Set("rand ", "")
requestParams.Set("word ", "")
// 发起接口网络请求
resp, err := http.Get(apiUrl + "?" + requestParams.Encode())
if err != nil {
fmt.Println("网络请求异常:", err)
return
}
defer resp.Body.Close()
var responseResult map[string]interface{}
err = json.NewDecoder(resp.Body).Decode(&responseResult)
if err != nil {
fmt.Println("解析响应结果异常:", err)
return
}
fmt.Println(responseResult)
}
using System;
using System.Net;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
namespace Common_API_Test.Test_Demo
{
class Csharp_get
{
static void Main(string[] args)
{
string url = "https://apis.juhe.cn/fapigx/esports/query";
string apiKey = "您申请的调用APIkey";
Dictionary<string, string> data = new Dictionary<string, string>();
data.Add("key", apiKey);
data.Add( "num ", "");
data.Add( "page ", "");
data.Add( "rand ", "");
data.Add( "word ", "");
using (WebClient client = new WebClient())
{
string fullUrl = url + "?" + string.Join("&", data.Select(x => x.Key + "=" + x.Value));
try
{
string responseContent = client.DownloadString(fullUrl);
dynamic responseData = JsonConvert.DeserializeObject(responseContent);
if (responseData != null)
{
Console.WriteLine("Return Code: " + responseData["error_code"]);
Console.WriteLine("Return Message: " + responseData["reason"]);
}
else
{
Console.WriteLine("json解析异常!");
}
}
catch (Exception)
{
Console.WriteLine("请检查其它错误");
}
}
}
}
}
const axios = require('axios'); // npm install axios
// 基本参数配置
const apiUrl = 'https://apis.juhe.cn/fapigx/esports/query'; // 接口请求URL
const apiKey = '您申请的调用APIkey'; // 在个人中心->我的数据,接口名称上方查看
// 接口请求入参配置
const requestParams = {
key: apiKey,
num : '',
page : '',
rand : '',
word : '',
};
// 发起接口网络请求
axios.get(apiUrl, {params: requestParams})
.then(response => {
// 解析响应结果
if (response.status === 200) {
const responseResult = response.data;
// 网络请求成功。可依据业务逻辑和接口文档说明自行处理。
console.log(responseResult);
} else {
// 网络异常等因素,解析结果异常。可依据业务逻辑自行处理。
console.log('请求异常');
}
})
.catch(error => {
// 网络请求失败,可以根据实际情况进行处理
console.log('网络请求失败:', error);
});
package cn.juhe.test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
public class JavaGet {
public static void main(String[] args) throws Exception {
String apiKey = "你申请的key";
String apiUrl = "https://apis.juhe.cn/fapigx/esports/query";
HashMap<String, String> map = new HashMap<>();
map.put("key", apiKey);
map.put("num ", "");
map.put("page ", "");
map.put("rand ", "");
map.put("word ", "");
URL url = new URL(String.format("%s?%s", apiUrl, params(map)));
BufferedReader in = new BufferedReader(new InputStreamReader((url.openConnection()).getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response);
}
public static String params(Map<String, String> map) {
return map.entrySet().stream()
.map(entry -> {
try {
return entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8.toString());
} catch (Exception e) {
e.printStackTrace();
return entry.getKey() + "=" + entry.getValue();
}
})
.collect(Collectors.joining("&"));
}
}
// 基本参数配置
NSString *apiUrl = @"https://apis.juhe.cn/fapigx/esports/query"; // 接口请求URL
NSString *apiKey = @"您申请的调用APIkey"; // 在个人中心->我的数据,接口名称上方查看
// 接口请求入参配置
NSDictionary *requestParams = @{
@"key": apiKey,
@"num ": @"",
@"page ": @"",
@"rand ": @"",
@"word ": @"",
};
// 发起接口网络请求
NSURLComponents *components = [NSURLComponents componentsWithString:apiUrl];
NSMutableArray *queryItems = [NSMutableArray array];
[requestParams enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSString *value, BOOL *stop) {
[queryItems addObject:[NSURLQueryItem queryItemWithName:key value:value]];
}];
components.queryItems = queryItems;
NSURL *url = components.URL;
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
// 网络请求异常处理
NSLog(@"请求异常");
} else {
NSError *jsonError;
NSDictionary *responseResult = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError];
if (!jsonError) {
// 网络请求成功处理
// NSLog(@"%@", [responseResult objectForKey:@"error_code"]);
NSLog(@"%@", responseResult);
} else {
// 解析结果异常处理
NSLog(@"解析结果异常");
}
}
}];
[task resume];
返回参数说明:
| 名称 | 类型 | 说明 | |
|---|---|---|---|
| error_code | int | 返回状态码 | |
| reason | string | 返回原因 | |
| result | object | 结果对象 | |
| curpage | int | 当前页 | |
| allnum | int | 结果数 | |
| id | string | 新闻唯一ID | |
| ctime | Date | 发布时间 | |
| title | string | 文章标题 | |
| description | string | 文章描述 | |
| source | string | 文章来源 | |
| picUrl | string | 封面图片 | |
| url | string | 文章地址 |
JSON返回示例:JSON在线格式化工具 >
{
"reason": "success",
"result": {
"curpage": 1,
"allnum": 10,
"newslist": [
{
"id": "3aa790a9ed5737f61d3966d89aa00a96",
"ctime": "2022-11-28 19:00",
"title": "腾讯入亚项目测试赛即将开启 涉及《LOL》等四个项目",
"description": "今日TGA腾讯电竞运动会官方宣布,腾讯入亚项目测试赛暨2022TGA冬季总决赛-拱墅区亚运倒计时300天系列活动即将开始。涉及《英雄联...",
"source": "新浪电竞",
"picUrl": "https://n.sinaimg.cn/games/639/w400h239/20221128/63c1-6c04f7adf11a10d93959ea9569070c01.jpg",
"url": "//dj.sina.com.cn/article/mqmmthc6307350.shtml"
},
{
"id": "2971b2f528df7a511bfa8464508bcc97",
"ctime": "2022-09-23 23:00",
"title": "腾讯自研射击手游《暗区突围》今日10:00正式公测!海量新内容亮相",
"description": "《暗区突围》已于今日10:00正式开启公测,全新活动、全新角色,全新枪械等海量新内容均已亮相,先锋们需要升级至新版本才能体验,安卓玩家...",
"source": "新浪电竞",
"picUrl": "https://n.sinaimg.cn/games/639/w400h239/20220923/15b1-f45725573bb1730ebde6410123e5517a.png",
"url": "//dj.sina.com.cn/article/mqqsmrp0269141.shtml"
},
{
"id": "ec43c953616fe812829bb059e5f17924",
"ctime": "2022-09-05 10:00",
"title": "腾讯先锋云游戏总经理荆彦青:云游戏共创超级数字生态",
"description": "荆彦青先生首先分析了数字产业未来的发展趋势,并表示腾讯先锋将依托自身的云互动技术积累,从行业、应用、内容、产品、硬件及终端等维度全方位...",
"source": "新浪电竞",
"picUrl": "//n.sinaimg.cn/games/transform/639/w400h239/20220905/fb00-20dfba50a9af87b25bc215deb0936035.png",
"url": "//dj.sina.com.cn/article/mizmscv9144703.shtml"
},
{
"id": "5626f10ff02c935ff1f4e7fcd3515a24",
"ctime": "2022-09-01 12:00",
"title": "腾讯游戏开发首个虚拟探索空间《代号:Spark》,“内测”版本亮相ChinaJoy",
"description": "作为全球数字娱乐领域最具知名度和影响力的年度盛会之一,2022年的ChinaJoy成为国内首个试水元宇宙的游戏展。",
"source": "新浪电竞",
"picUrl": "https://n.sinaimg.cn/games/639/w400h239/20220901/8282-5653d26cbc43296528e80e0cb1c11689.png",
"url": "//dj.sina.com.cn/article/mizmscv8639660.shtml"
},
{
"id": "8a05c6a7575ad60f9611a1ef2a516cb9",
"ctime": "2022-08-14 15:00",
"title": "腾讯夏琳:激发游戏创新活力,助力产业可持续发展",
"description": "8月14日,由腾讯游戏学堂举办的2022腾讯游戏开发者大会(TencentGameDevelopersConference,以下...",
"source": "新浪电竞",
"picUrl": "https://n.sinaimg.cn/games/639/w400h239/20220814/0443-90c03a934140e30ea5f3ee36444ec03a.png",
"url": "//dj.sina.com.cn/article/mizirav8103464.shtml"
},
{
"id": "613789731cb68cc9b010de3d4a8a8023",
"ctime": "2022-07-28 11:00",
"title": "腾讯称未来电竞人才缺口将达200万 涵盖直播、运营等多个行业",
"description": "腾讯游戏副总裁、腾讯电竞总经理侯淼在采访中表示,按照电竞行业目前的发展速度,未来三四年时间内的人才缺口将达到200万,甚至更多。",
"source": "新浪电竞",
"picUrl": "https://n.sinaimg.cn/games/639/w400h239/20220728/60a8-6c5c5aa83880dd3438242e00ac56935e.jpg",
"url": "//dj.sina.com.cn/article/mizirav5728020.shtml"
},
{
"id": "628e149dccb37c580828675be51a6def",
"ctime": "2022-06-15 13:00",
"title": "腾讯游戏增加腾讯天游运营主体,官方:不参与游戏开发",
"description": "近日,腾讯游戏通过官方微博发布公告,称将新增腾讯天游作为运营主体,目前,公司已完成多款游戏的变更调整,后续《王者荣耀》《英雄联盟手游》...",
"source": "新浪电竞",
"picUrl": "//n.sinaimg.cn/games/transform/639/w400h239/20220615/b242-400c43bb232f9bb8310d29e1e0cb11b3.jpg",
"url": "//dj.sina.com.cn/article/mizmscu6921806.shtml"
},
{
"id": "70b228d1c524a1b65a921c89ef6b095b",
"ctime": "2022-05-30 12:00",
"title": "腾讯加速器已退出群聊,这两款加速器可供选择",
"description": "野豹加速器相对于来说是一款电竞级的加速器,支持PC端、移动端和主机端加速,并且对于一些锁区的外服游戏也推出了独享IP的功能。野豹加速器...",
"source": "新浪电竞",
"picUrl": "//n.sinaimg.cn/games/transform/639/w400h239/20220530/3682-a364bd2889fbcf45e92afd56384168c7.png",
"url": "//dj.sina.com.cn/article/mizirau5578242.shtml"
},
{
"id": "6bcc037323b90d2b91e2f09e05c2ce80",
"ctime": "2022-05-27 19:00",
"title": "腾讯加速器已退出什么加速器值得选择/免费or实用",
"description": "腾讯加速器终究还是退出了”群聊”那么,在后腾讯时代,我们应该选择什么样的加速器呢?",
"source": "新浪电竞",
"picUrl": "//n.sinaimg.cn/games/transform/639/w400h239/20220527/4dd7-c2ce704d0789feb65530dd0e4d64f86a.png",
"url": "//dj.sina.com.cn/article/mizirau5149179.shtml"
},
{
"id": "49e4f44ae29be5d65b2625135de10458",
"ctime": "2022-04-15 12:00",
"title": "腾讯加速器调整?外服加速还有野豹加速器备选!",
"description": "腾讯加速器官方最近发布了一则消息,内容大致为腾讯加速器因业务调整,自2022年5月22日起将不再提供外服游戏加速,仅支持国内游戏加速,...",
"source": "新浪电竞",
"picUrl": "//n.sinaimg.cn/games/639/w400h239/20220415/5add-e330d226a325c689ddc4b4558890fd0d.png",
"url": "//dj.sina.com.cn/article/mcwipii4416083.shtml"
}
]
},
"error_code": 0
}
服务级错误码参照(error_code):
| 错误码 | 说明 | |
|---|---|---|
| 273200 | 网络超时,请稍后重试 | |
| 273201 | 关键字不能超过100字 | |
| 273202 | 数据异常 | |
| 273203 | 其他错误,具体看描述 |
系统级错误码参照:
| 错误码 | 说明 | 旧版本(resultcode) | |
|---|---|---|---|
| 10001 | 错误的请求KEY | 101 | |
| 10002 | 该KEY无请求权限 | 102 | |
| 10003 | KEY过期 | 103 | |
| 10004 | 错误的OPENID | 104 | |
| 10005 | 应用未审核超时,请提交认证 | 105 | |
| 10007 | 未知的请求源 | 107 | |
| 10008 | 被禁止的IP | 108 | |
| 10009 | 被禁止的KEY | 109 | |
| 10011 | 当前IP请求超过限制 | 111 | |
| 10012 | 请求超过次数限制 | 112 | |
| 10013 | 测试KEY超过请求限制 | 113 | |
| 10014 | 系统内部异常(调用充值类业务时,请务必联系客服或通过订单查询接口检测订单,避免造成损失) | 114 | |
| 10020 | 接口维护 | 120 | |
| 10021 | 接口停用 | 121 |
错误码格式说明(示例:200201):
| 2 | 002 | 01 | |
|---|---|---|---|
| 服务级错误(1为系统级错误) | 服务模块代码(即数据ID) | 具体错误代码 |
接口文档下载
苏公网安备 32059002001776号