forked from axsddlr/vlrggapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
66 lines (51 loc) · 1.47 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import uvicorn
from fastapi import FastAPI
from api.scrape import Vlr
from ratelimit import limits
app = FastAPI(
title="vlrggapi",
description="An Unofficial REST API for [vlr.gg](https://www.vlr.gg/), a site for Valorant Esports match and news "
"coverage. Made by [Rehkloos](https://github.com/Rehkloos)",
version="1.0.3",
docs_url="/",
redoc_url=None,
)
vlr = Vlr()
TEN_MINUTES = 600
@limits(calls=50, period=TEN_MINUTES)
@app.get("/news")
async def VLR_news():
return vlr.vlr_recent()
@limits(calls=50, period=TEN_MINUTES)
@app.get("/match/results")
async def VLR_scores():
return vlr.vlr_score()
@limits(calls=50, period=TEN_MINUTES)
@app.get("/stats/{region}")
async def VLR_stats(region):
return vlr.vlr_stats(region)
@limits(calls=50, period=TEN_MINUTES)
@app.get("/rankings/{region}")
async def VLR_ranks(region):
"""
region shortnames:
"na" -> "north-america",
"eu" -> "europe",
"ap" -> "asia-pacific",
"la" -> "latin-america",
"la-s" -> "la-s",
"la-n" -> "la-n",
"oce" -> "oceania",
"kr" -> "korea",
"mn" -> "mena",
"gc" -> "game-changers",
"br" -> "Brazil",
"ch" -> "china",
"""
return vlr.vlr_rankings(region)
@limits(calls=50, period=TEN_MINUTES)
@app.get("/match/upcoming")
async def VLR_upcoming():
return vlr.vlr_upcoming()
if __name__ == "__main__":
uvicorn.run("main:app", host="0.0.0.0", port=3001)