polytoria.py 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ Metadata-Version: 2.4
2
+ Name: polytoria.py
3
+ Version: 0.1.0
4
+ Summary: Wrapper for the Polytoria API
5
+ Requires-Python: >=3.10
6
+ Requires-Dist: curl-cffi
@@ -0,0 +1,34 @@
1
+ <p align="center">
2
+ <img src="/logo.png" alt="Logo" width="200"/>
3
+ </p>
4
+
5
+ <div align="center">
6
+
7
+ # Polytoria.py
8
+
9
+ [Installation](#Installation)
10
+ [Usage](#Usage)
11
+ [license](#License)
12
+ [Credits](#Credits)
13
+
14
+ <p align="center">
15
+ <img src="https://img.shields.io/badge/python-3.7+-blue.svg"/>
16
+ <img src="https://img.shields.io/badge/license-MIT-green.svg"/>
17
+ <img src="https://img.shields.io/github/contributors/Redlavaa/polytoria.py">
18
+ </p>
19
+
20
+ <div align="left">
21
+
22
+ # Introduction
23
+ Polytoria.py is a wrapper that lets you easily use the polytoria api.
24
+
25
+ # Installation
26
+
27
+ place holder
28
+
29
+ # Usage
30
+
31
+ ```python
32
+ polytoria.user(id)
33
+ polytoria.item(id)
34
+ ```
@@ -0,0 +1,14 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "polytoria.py"
7
+ version = "0.1.0"
8
+ description = "Wrapper for the Polytoria API"
9
+ requires-python = ">=3.10"
10
+ dependencies = ["curl-cffi"]
11
+
12
+ [tool.setuptools]
13
+ package-dir = {"" = "src"}
14
+ packages = ["polyapi"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ from .wrapper import Polytoria
2
+
3
+ __all__ = ["Polytoria"]
@@ -0,0 +1,22 @@
1
+ from curl_cffi.requests import AsyncSession
2
+
3
+ class APIClient:
4
+ def __init__(self, browser: str = "chrome", base_url:str = None):
5
+ self.base_url = base_url or "https://api.polytoria.com/v1"
6
+ self.browser = browser
7
+
8
+ async def fetch_data(self, endpoint:str, base_url:str = None, params: dict = None) -> dict:
9
+ url = f"{self.base_url}/{endpoint}"
10
+ print(url)
11
+
12
+ async with AsyncSession(impersonate=self.browser) as session:
13
+ try:
14
+ response = await session.get(
15
+ url,
16
+ params=params,
17
+ )
18
+ response.raise_for_status()
19
+ return response.json()
20
+ except Exception as e:
21
+ print(f"API Request failed: {e}")
22
+ raise
@@ -0,0 +1,112 @@
1
+ from src.api_client import APIClient
2
+
3
+ class User:
4
+ def __init__(self, data:dict, client):
5
+ self.client = client
6
+
7
+ self.id = data.get("id")
8
+ self.username = data.get("username")
9
+ self.description = data.get("description")
10
+ self.thumbnail = data.get("thumbnail")
11
+ if isinstance(self.thumbnail, dict):
12
+ self.avatar = self.thumbnail.get("avatar")
13
+ self.icon = self.thumbnail.get("icon")
14
+ else:
15
+ self.avatar = None
16
+ self.icon = None
17
+ self.playing = data.get("playing")
18
+ self.networth = data.get("netWorth")
19
+ self.placevisits = data.get("placeVisits")
20
+ self.forumposts = data.get("forumPosts")
21
+ self.assetSales = data.get("assetSales")
22
+ self.membershipType = data.get("membershipType")
23
+ self.istaff = data.get("isStaff")
24
+ self.userroleclass = data.get("userRoleClass")
25
+ self.joindate = data.get("registeredAt")
26
+ self.lastseen = data.get("lastSeenAt")
27
+
28
+ def __repr__(self): # used for debugging
29
+ return f"id={self.id} username={self.username} description={self.description}"
30
+
31
+ class Item:
32
+ def __init__(self, data:dict, client):
33
+ self.client = client
34
+
35
+ self.id = data.get("id")
36
+ self.type = data.get("type")
37
+ self.accessorytype = data.get("accessoryType")
38
+ self.name = data.get("name")
39
+ self.description = data.get("description")
40
+ self.tags = data.get("tags", []) or []
41
+ self.creator = data["creator"]["name"]
42
+ self.thumbnail = data.get("thumbnail")
43
+ self.price = data.get("price")
44
+ self.studprice = data.get("priceInStuds")
45
+ self.averageprice = data.get("averagePrice")
46
+ self.version = data.get("version")
47
+ self.sales = data.get("sales")
48
+ self.favorites = data.get("favorites")
49
+
50
+ self._owners = None
51
+
52
+ async def owners(self):
53
+ if self._owners == None:
54
+ self._owners = await self.client.fetch_data(f"store/{self.id}/owners", base_url="https://api.polytoria.com/v1/")
55
+ return self._owners
56
+
57
+
58
+ def __repr__(self):
59
+ return f"id={self.id} name={self.name} description={self.description}"
60
+
61
+ class Place: # /api/places /v1/api/places/{id}
62
+ def __init__(self, data:dict, client):
63
+ self.client = client
64
+
65
+ self.id = data.get("id")
66
+ self.name = data.get("name")
67
+ self.description = data.get("description")
68
+ self.creator = data["creator"]["name"]
69
+ self.thumbnail = data.get("thumbnail")
70
+ self.genre = data.get("genre")
71
+ self.maxplayers = data.get("maxPlayers")
72
+ self.isactive = data.get("isActive")
73
+ self.istoolsenabled = data.get("isToolsEnabled")
74
+ self.iscopyable = data.get("isCopyable")
75
+ self.visits = data.get("visits")
76
+ self.uniquevisits = data.get("uniqueVisits")
77
+ self.playing = data.get("playing")
78
+ self.rating = data.get("rating")
79
+ self.accesstype = data.get("accessType")
80
+ self.accessprice = data.get("accessPrice")
81
+ self.createdat = data.get("createdAt")
82
+ self.updatedat = data.get("updatedAt")
83
+
84
+ def __repr__(self):
85
+ return f""
86
+
87
+ class Guild: # /api/guilds/{id} /v1/guilds/{id}
88
+ def __init__(self, data:dict, client):
89
+ self.client = client
90
+
91
+ self.id = data.get("id")
92
+ self.name = data.get("name")
93
+ self.description = data.get("description")
94
+ self.creator = data["creator"]["name"]
95
+ self.thumbnail = data.get("thumbnail")
96
+ self.banner = data.get("banner")
97
+ self.color = data.get("color")
98
+ self.jointype = data.get("joinType")
99
+ self.membercount = data.get("memberCount")
100
+ self.vaultbalance = data.get("vaultBalance")
101
+ self.isverified = data.get("isVerified")
102
+ self.createdat = data.get("createdAt")
103
+
104
+ def __repr__(self):
105
+ return f""
106
+
107
+ class Forum: # /v1/forum
108
+ def __init__(self, data:dict, client):
109
+ self.client = client
110
+
111
+ def __repr__(self):
112
+ return f""
@@ -0,0 +1,30 @@
1
+ from src.api_client import APIClient
2
+ from src.models import User, Item, Place, Guild
3
+
4
+ class Polytoria:
5
+ def __init__(self, browser: str = "chrome"):
6
+ self._client = APIClient(browser=browser)
7
+
8
+ async def user(self, user_id: int) -> User:
9
+
10
+ raw_data = await self._client.fetch_data(f"users/{user_id}", base_url="https://api.polytoria.com/v1/")
11
+
12
+ return User(raw_data, self._client)
13
+
14
+ async def item(self, item_id: int) -> Item:
15
+
16
+ raw_data = await self._client.fetch_data(f"store/{item_id}", base_url="https://api.polytoria.com/v1/")
17
+
18
+ return Item(raw_data, self._client)
19
+
20
+ async def place(self, place_id: int) -> Place:
21
+
22
+ raw_data = await self._client.fetch_data(f"places/{place_id}", base_url="https://api.polytoria.com/v1/")
23
+
24
+ return Place(raw_data, self._client)
25
+
26
+ async def guild(self, guild_id: int) -> Guild:
27
+
28
+ raw_data = await self._client.fetch_data(f"guilds/{guild_id}", base_url="https://api.polytoria.com/v1/")
29
+
30
+ return Place(raw_data, self._client)
@@ -0,0 +1,6 @@
1
+ Metadata-Version: 2.4
2
+ Name: polytoria.py
3
+ Version: 0.1.0
4
+ Summary: Wrapper for the Polytoria API
5
+ Requires-Python: >=3.10
6
+ Requires-Dist: curl-cffi
@@ -0,0 +1,11 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/polyapi/__init__.py
4
+ src/polyapi/api_client.py
5
+ src/polyapi/models.py
6
+ src/polyapi/wrapper.py
7
+ src/polytoria.py.egg-info/PKG-INFO
8
+ src/polytoria.py.egg-info/SOURCES.txt
9
+ src/polytoria.py.egg-info/dependency_links.txt
10
+ src/polytoria.py.egg-info/requires.txt
11
+ src/polytoria.py.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ curl-cffi