pubg开发人员api的python包装器

pubg-python的Python项目详细描述


发布python

pubg开发人员api的python包装器

PUBG Developer API Official Documentation

安装

要安装包装器,只需使用pip

pip install pubg-python

pipenv

pipenv install pubg-python

用法

指定碎片

pubg api按平台和区域共享数据,因此需要在url中为大多数请求指定一个shard。

frompubg_pythonimportPUBG,Shardapi=PUBG('<api-key>',Shard.PC_NA)

可以找到碎片列表here和包装常量here

样品

匹配的样本可以作为起点进行检索

sample=api.samples().get()formatchinsample.matches:print(match.id)

样本也可以按创建日期进行过滤

sample=api.samples().filter(created_at_start='2018-01-01T00:00:00Z').get()formatchinsample.matches:print(match.id)

玩家

检索单个玩家

player=api.players().get('account.3654e255b77b409e87b10dcb086ab00d')formatchinplayer.matches:match_data=api.matches().get(match.id)

检索按名称筛选的玩家列表

players=api.players().filter(player_names=['Name1','Name2'])forplayerinplayers:player_id=player.id

检索按id

筛选的玩家列表
players=api.players().filter(player_ids=['account.3654e255b77b409e87b10dcb086ab00d'])forplayerinplayers:player_name=player.name

匹配

检索单个匹配项

match=api.matches().get('276f5bcb-a831-4e8c-a610-d2073692069e')

检索按id

筛选的匹配项列表

在api中仍然不可用

match_ids=['276f5bcb-a831-4e8c-a610-d2073692069e','fasf9082-21de-dkle-13ke-qlamd13nab3a',]matches=api.matches().filter(match_ids=match_ids)formatchinmatches:print(match)

遥测

处理匹配遥测数据

match=api.matches().get('276f5bcb-a831-4e8c-a610-d2073692069e')asset=match.assets[0]telemetry=api.telemetry(asset.url)print(len(telemetry.events))>>16871

过滤遥测对象中的特定事件

有时您对一组非常特定的事件感兴趣,因此有一个帮助函数来筛选这些事件:

match=api.matches().get('276f5bcb-a831-4e8c-a610-d2073692069e')asset=match.assets[0]telemetry=api.telemetry(asset.url)player_kill_events=telemetry.events_from_type('LogPlayerKill')player_position_events=telemetry.events_from_type('LogPlayerPosition')

加载本地遥测文件

如果要加载以前下载的遥测文件,有一个助手 方法从中创建遥测对象:

frompubg_pythonimportTelemetrytelemetry=Telemetry.from_json('telemetry.json',shard='pc')

shard默认为pc,但您需要指定是否要加载xbox遥测文件。

匹配

检索单个锦标赛

tournament=api.tournaments().get('na-ppc')

检索锦标赛列表

tournaments=api.tournaments()fortournamentintournaments:print(tournament)

玩弄数据

如何操作数据的示例: 域已全部指定here

players=api.players().filter(player_names=['epickitten'])player=players[0]player.matches>>[<Matchbd6aae34-be05-4094-981c-083285c7e861>,<Match276f5bcb-a831-4e8c-a610-d2073692069e>,..]match=api.matches().get(player.matches[0].id)match.game_mode>>'solo'match.duration>>1899match.rosters>>[<Rosterd542eaee-cd02-4f4e-ad7f-ed5ea71a17cf>,<Rostere9f0962a-ebd4-4d86-b134-95783b713800>,..]roster=match.rosters[0]roster.participants>>[<Participant7cc76d1b-a80e-4997-8eb8-d4b3c1ed4f44>]participant=roster.participans[0]participant.name>>'urdaddyYO'participant.damage_dealt>>291.08participant.kills>>2participant.ride_distance>>3204.53467participant.walk_distance>>2262.81714participant.time_survived>>1367participant.player_id>>account.edb9910f1e9c4f3b9addb87d9329b57cplayer=api.players().get(participant.player_id)player>>account.edb9910f1e9c4f3b9addb87d9329b57cplayer.matches>>[<Matchb3dcd7e8-2270-4fdd-8389-af77acf2d6c2>,<Match2ebb1a9c-ab5e-4264-971f-df77a00918a9>,..]

限值和偏移量

当前已从官方API中禁用

抵消5场比赛并限制10场

matches=api.matches().limit(10).offset(5)

排序

当前已从官方API中禁用

sort默认为升序,您可以使用ascending=False进行降序排序

matches=api.matches().limit(10).sort('createdAt')matches=api.matches().limit(10).sort('createdAt',ascending=False)

过滤

有些端点允许应用筛选器,例如,按名称筛选播放机:

players=api.players().filter(player_names=['Name1','Name2'])

或按ID筛选播放机:

players=api.players().filter(player_ids=['account.3654e255b77b409e87b10dcb086ab00d'])

分页

下一页使用next(),上一页使用prev()

matches=api.matches()next_matches=matches.next()previous_matches=matches.prev()

更改日志

CHANGELOG.md

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
实现接口方法时不允许java@Override   使用BuffereImage加载映像时java高ram使用率   java For循环混乱,为什么不是循环?   java Android网格视图字符串对齐问题   java如何将方法与比较类型的附加功能进行比较?   在Java Swing中放置JSepator后的间隙大小   java如何避免并发访问我的网站中的支付链接   java如何从现有的Unix服务器连接到FTP服务器?   Spring中的java用户相关bean定义   带有scribesjava库的wordpress Woocommerce REST API返回消费者密钥参数缺失错误消息   java我可以自动检测特定设备连接的串行端口吗?   Javafx棋盘游戏   java使用JTextPane显示HTML,支持SVG吗?   SpringBoot如何在java中将映射转换为实体对象?   如何使用java代码对xls文件进行密码保护   Java JPA(EclipseLink)如何在持久化实际实体之前接收下一个生成的值?   Javaservlet启动外部进程