虎牙开放平台文档

开放API 协议说明

1.获取礼物素材列表

GET https://open-apiext.huya.com/proxy/index?do=getLiveGiftInfoList
1.1.接口参数
参数名称类型描述
appIdstring开发者的appId
iatintjwt签发时间(unix时间戳),即生成sToken的当前unix时间戳
expintjwt过期时间(unix时间戳),通常exp=iat+600,注意不少于当前时间且不超过当前时间60分钟
sTokenstringjwt鉴权生成的token
1.2.返回(JSON)
返回字段
字段名称类型描述
codeint参考下面的接口返回码
messagestring消息提示
data[]["giftId"]int礼物id
data[]["giftCnName"]string礼物中文名称(全平台属性)
data[]["giftEnName"]string礼物英文名称(全平台属性)
data[]["iconUrl"]string图标url(全平台属性)
data[]["largeIconUrl"]string大图标url(全平台属性)
data[]["gifUrl"]stringgif url(全平台属性)
data[]["prizeYb"]double礼物对应虎牙币价格,注:小于0表示该方式不可用
data[]["prizeGoldbean"]int礼物对应金豆价格,注:小于0表示该方式不可用
data[]["prizeSilverbean"]int礼物对应银豆价格,注:小于0表示该方式不可用
data[]["giftInfoRoom"]stringjson格式,生效直播间属性,表示该礼物所在直播间的特有属性,详见giftInfoRoom字段说明
data[]["giftInfoGame"] stringjson格式,生效品类属性,表示该礼物所在品类的特有属性,详见giftInfoRoom字段说明
giftInfoRoom字段说明
字段名称类型描述
roomIdint生效直播间的房间号
giftCnNamestring生效直播间的礼物名称,表示该礼物在本直播间的礼物名称
iconUrlstring生效直播间的礼物图标url
largeIconUrlstring生效直播间的礼物大图标url
gifUrlstring生效直播间的礼物gif url
giftInfoGame字段说明
字段名称类型描述
gameIdint生效品类的品类id
giftCnNamestring生效品类的礼物名称,表示该礼物在本品类下的礼物名称
iconUrlstring生效品类的礼物图标url
largeIconUrlstring生效品类的礼物大图标url
gifUrlstring生效品类的礼物gif url
接口返回码
返回码描述
200成功
407鉴权失败
500列表不存在
其他失败
1.3.调用例子
curl "https://open-apiext.huya.com/proxy/index?do=getLiveGiftInfoList&appId=xxxxxxxxxxxx&iat=1556188391&exp=1556188991&sToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NTYxODgzOTEsImV4cCI6MTU1NjE4ODk5MSwiYXBwSWQiOiJ4eHh4eHh4eHh4eHgifQ.DFdsMFu_VzPkUUS1eu_Kwyzvc6vSQ-x_HI3wEut72cU"
1.4.接口返回JSON
成功返回
{ code: 200, message: "成功", data: [ { giftId: 4, giftCnName: "虎粮", giftEnName: "huliang", iconUrl: "https://huyaimg.msstatic.com/cdnimage/actprop/4_1__24_1551927228.jpg", largeIconUrl: "https://huyaimg.msstatic.com/cdnimage/actprop/4_1__108_1532944044.jpg", gifUrl: "https://huyaimg.msstatic.com/cdnimage/actprop/4_1__gif_1532944034.gif", prizeYb: 0.1, prizeSilverbean: 1000, prizeGoldbean: 100, giftInfoRoom: [ { roomId: 660002, giftCnName: "稳住 能赢", iconUrl: "https://huyaimg.msstatic.com/cdnimage/actprop/4_4__24_1553832476.jpg", largeIconUrl: "http://huyaimg.msstatic.com/cdnimage/actprop/4_4__108_1511608188.jpg", gifUrl: "http://huyaimg.msstatic.com/cdnimage/actprop/4_4__gif_1511423631.gif", }, { roomId: 11423741, giftCnName: "稳住 能赢", gifUrl: "http://huyaimg.msstatic.com/cdnimage/actprop/4_4__gif_1511423631.gif", iconUrl: "https://huyaimg.msstatic.com/cdnimage/actprop/4_4__24_1553832476.jpg", largeIconUrl: "http://huyaimg.msstatic.com/cdnimage/actprop/4_4__108_1511608188.jpg", }, ... ] }, { giftId: 20206, giftCnName: "荧光棒", giftEnName: "glowstick", iconUrl: "https://huyaimg.msstatic.com/cdnimage/actprop/20206_1__24_1551927372.jpg", largeIconUrl: "https://huyaimg.msstatic.com/cdnimage/actprop/20206_1__108_1550645324.jpg", gifUrl: "https://huyaimg.msstatic.com/cdnimage/actprop/20206_1__gif_1550645314.gif", prizeYb: 0.1, prizeGoldbean: 100, prizeSilverbean: -1 giftInfoGame: [ { gameId: 2793, giftCnName: "平底锅", gifUrl: "https://huyaimg.msstatic.com/cdnimage/actprop/20206_2__gif_1527652163.gif", iconUrl: "https://huyaimg.msstatic.com/cdnimage/actprop/20206_2__24_1554278820.jpg", largeIconUrl: "http://huyaimg.msstatic.com/cdnimage/actprop/20206_2__108_1516198863.jpg", }, { gameId: 3307, giftCnName: "空投箱", gifUrl: "https://huyaimg.msstatic.com/cdnimage/actprop/20206_4__gif_1527652196.gif", iconUrl: "http://huyaimg.msstatic.com/cdnimage/actprop/20206_4__24_1517557684.jpg", largeIconUrl: "http://huyaimg.msstatic.com/cdnimage/actprop/20206_4__108_1517559194.jpg", }, ... ] } { giftId: 12, giftCnName: "藏宝图", giftEnName: "bao", iconUrl: "https://huyaimg.msstatic.com/cdnimage/actprop/12_1__24_1551927570.jpg", largeIconUrl: "https://huyaimg.msstatic.com/cdnimage/actprop/12_1__108_1532944030.jpg", gifUrl: "https://huyaimg.msstatic.com/cdnimage/actprop/12_1__gif_1532944022.gif", prizeYb: 4999, prizeGoldbean: 5000000 prizeSilverbean: -1, } ] }
示例说明

上面的返回值示例中:

  • id为4的礼物,在全平台(指除了giftInfoRoom指定的直播间和giftInfoGame指定品类以外)的中文名称是“虎粮”,iconUrl和gifUrl为对应的全平台属性。在房间号为660002的直播间里面,该礼物的中文名称是“稳住 能赢”,giftInfoRoom['iconUrl']和giftInfoRoom['gifUrl']表示在该直播间的对应属性。
  • id为20206的礼物,在全平台(指除了giftInfoRoom指定的直播间和giftInfoGame指定品类以外)的中文名称是“荧光棒”,iconUrl和gifUrl为对应的全平台属性。在品类id为2793的直播间里面,该礼物的中文名称是“平底锅”,giftInfoGame['iconUrl']giftInfoGame['gifUrl']表示在该直播间的对应属性。
失败返回
{ "code": 500, "message": "列表不存在", "data": null }