OpenMLBB 4.0.3__py3-none-any.whl

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.
OpenMLBB/__init__.py ADDED
@@ -0,0 +1,21 @@
1
+ from __future__ import annotations
2
+
3
+ from OpenMLBB._version import __version__
4
+ from OpenMLBB.client import (
5
+ AddonClient,
6
+ AcademyClient,
7
+ MlbbClient,
8
+ OpenMLBB,
9
+ OpenMLBBError,
10
+ UserClient,
11
+ )
12
+
13
+ __all__ = [
14
+ "__version__",
15
+ "OpenMLBB",
16
+ "OpenMLBBError",
17
+ "AcademyClient",
18
+ "MlbbClient",
19
+ "UserClient",
20
+ "AddonClient",
21
+ ]
OpenMLBB/_version.py ADDED
@@ -0,0 +1,3 @@
1
+ """Package version for OpenMLBB."""
2
+
3
+ __version__ = "4.0.3"
OpenMLBB/client.py ADDED
@@ -0,0 +1,263 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Any
5
+
6
+ import requests
7
+
8
+
9
+ DEFAULT_BASE_URL = "https://mlbb.rone.dev/api"
10
+ DEFAULT_TIMEOUT = 30
11
+ DEFAULT_USER_AGENT = "RoneAI-OpenMLBB-Python-SDK"
12
+
13
+
14
+ class OpenMLBBError(Exception):
15
+ """Raised when an OpenMLBB request fails."""
16
+
17
+ def __init__(self, message: str, status_code: int | None = None, payload: Any = None) -> None:
18
+ super().__init__(message)
19
+ self.status_code = status_code
20
+ self.payload = payload
21
+
22
+
23
+ @dataclass(slots=True)
24
+ class _Transport:
25
+ base_url: str
26
+ timeout: int
27
+ user_agent: str
28
+ session: requests.Session
29
+
30
+ def request(
31
+ self,
32
+ method: str,
33
+ path: str,
34
+ *,
35
+ params: dict[str, Any] | None = None,
36
+ json_body: dict[str, Any] | None = None,
37
+ jwt: str | None = None,
38
+ ) -> dict[str, Any]:
39
+ url = f"{self.base_url.rstrip('/')}/{path.lstrip('/')}"
40
+ headers: dict[str, str] = {
41
+ "User-Agent": self.user_agent,
42
+ "Accept": "application/json",
43
+ }
44
+ if jwt:
45
+ headers["Authorization"] = f"Bearer {jwt}"
46
+
47
+ try:
48
+ response = self.session.request(
49
+ method=method.upper(),
50
+ url=url,
51
+ params=params,
52
+ json=json_body,
53
+ headers=headers,
54
+ timeout=self.timeout,
55
+ )
56
+ except requests.RequestException as exc:
57
+ raise OpenMLBBError(f"Request failed: {exc}") from exc
58
+
59
+ try:
60
+ payload: Any = response.json()
61
+ except ValueError:
62
+ payload = {"raw": response.text}
63
+
64
+ if not response.ok:
65
+ raise OpenMLBBError(
66
+ message=f"OpenMLBB API request failed with status {response.status_code}",
67
+ status_code=response.status_code,
68
+ payload=payload,
69
+ )
70
+
71
+ if isinstance(payload, dict):
72
+ return payload
73
+
74
+ return {"data": payload}
75
+
76
+
77
+ class AcademyClient:
78
+ def __init__(self, transport: _Transport) -> None:
79
+ self._transport = transport
80
+
81
+ def meta_version(self, **params: Any) -> dict[str, Any]:
82
+ return self._transport.request("GET", "/academy/meta/version", params=params)
83
+
84
+ def heroes_catalog(self, **params: Any) -> dict[str, Any]:
85
+ return self._transport.request("GET", "/academy/heroes/catalog", params=params)
86
+
87
+ def roles(self, **params: Any) -> dict[str, Any]:
88
+ return self._transport.request("GET", "/academy/roles", params=params)
89
+
90
+ def equipment(self, **params: Any) -> dict[str, Any]:
91
+ return self._transport.request("GET", "/academy/equipment", params=params)
92
+
93
+ def equipment_expanded(self, **params: Any) -> dict[str, Any]:
94
+ return self._transport.request("GET", "/academy/equipment/expanded", params=params)
95
+
96
+ def spells(self, **params: Any) -> dict[str, Any]:
97
+ return self._transport.request("GET", "/academy/spells", params=params)
98
+
99
+ def emblems(self, **params: Any) -> dict[str, Any]:
100
+ return self._transport.request("GET", "/academy/emblems", params=params)
101
+
102
+ def ranks(self, **params: Any) -> dict[str, Any]:
103
+ return self._transport.request("GET", "/academy/ranks", params=params)
104
+
105
+ def rank_by_id(self, rank_id: str | int, **params: Any) -> dict[str, Any]:
106
+ return self._transport.request("GET", f"/academy/ranks/{rank_id}", params=params)
107
+
108
+ def recommended(self, **params: Any) -> dict[str, Any]:
109
+ return self._transport.request("GET", "/academy/recommended", params=params)
110
+
111
+ def recommended_by_id(self, recommended_id: str | int, **params: Any) -> dict[str, Any]:
112
+ return self._transport.request("GET", f"/academy/recommended/{recommended_id}", params=params)
113
+
114
+ def heroes(self, **params: Any) -> dict[str, Any]:
115
+ return self._transport.request("GET", "/academy/heroes", params=params)
116
+
117
+ def hero_stats(self, hero_identifier: str | int, **params: Any) -> dict[str, Any]:
118
+ return self._transport.request("GET", f"/academy/heroes/{hero_identifier}/stats", params=params)
119
+
120
+ def hero_lane(self, hero_identifier: str | int, **params: Any) -> dict[str, Any]:
121
+ return self._transport.request("GET", f"/academy/heroes/{hero_identifier}/lane", params=params)
122
+
123
+ def hero_win_rate_timeline(self, hero_identifier: str | int, **params: Any) -> dict[str, Any]:
124
+ return self._transport.request("GET", f"/academy/heroes/{hero_identifier}/win-rate/timeline", params=params)
125
+
126
+ def hero_builds(self, hero_identifier: str | int, **params: Any) -> dict[str, Any]:
127
+ return self._transport.request("GET", f"/academy/heroes/{hero_identifier}/builds", params=params)
128
+
129
+ def hero_counters(self, hero_identifier: str | int, **params: Any) -> dict[str, Any]:
130
+ return self._transport.request("GET", f"/academy/heroes/{hero_identifier}/counters", params=params)
131
+
132
+ def hero_teammates(self, hero_identifier: str | int, **params: Any) -> dict[str, Any]:
133
+ return self._transport.request("GET", f"/academy/heroes/{hero_identifier}/teammates", params=params)
134
+
135
+ def hero_trends(self, hero_identifier: str | int, **params: Any) -> dict[str, Any]:
136
+ return self._transport.request("GET", f"/academy/heroes/{hero_identifier}/trends", params=params)
137
+
138
+ def hero_recommended(self, hero_identifier: str | int, **params: Any) -> dict[str, Any]:
139
+ return self._transport.request("GET", f"/academy/heroes/{hero_identifier}/recommended", params=params)
140
+
141
+ def heroes_ratings(self, **params: Any) -> dict[str, Any]:
142
+ return self._transport.request("GET", "/academy/heroes/ratings", params=params)
143
+
144
+
145
+ class MlbbClient:
146
+ def __init__(self, transport: _Transport) -> None:
147
+ self._transport = transport
148
+
149
+ def heroes(self, **params: Any) -> dict[str, Any]:
150
+ return self._transport.request("GET", "/heroes", params=params)
151
+
152
+ def heroes_rank(self, **params: Any) -> dict[str, Any]:
153
+ return self._transport.request("GET", "/heroes/rank", params=params)
154
+
155
+ def heroes_positions(self, **params: Any) -> dict[str, Any]:
156
+ return self._transport.request("GET", "/heroes/positions", params=params)
157
+
158
+ def hero_detail(self, hero_identifier: str | int, **params: Any) -> dict[str, Any]:
159
+ return self._transport.request("GET", f"/heroes/{hero_identifier}", params=params)
160
+
161
+ def hero_stats(self, hero_identifier: str | int, **params: Any) -> dict[str, Any]:
162
+ return self._transport.request("GET", f"/heroes/{hero_identifier}/stats", params=params)
163
+
164
+ def hero_skill_combos(self, hero_identifier: str | int, **params: Any) -> dict[str, Any]:
165
+ return self._transport.request("GET", f"/heroes/{hero_identifier}/skill-combos", params=params)
166
+
167
+ def hero_trends(self, hero_identifier: str | int, **params: Any) -> dict[str, Any]:
168
+ return self._transport.request("GET", f"/heroes/{hero_identifier}/trends", params=params)
169
+
170
+ def hero_relations(self, hero_identifier: str | int, **params: Any) -> dict[str, Any]:
171
+ return self._transport.request("GET", f"/heroes/{hero_identifier}/relations", params=params)
172
+
173
+ def hero_counters(self, hero_identifier: str | int, **params: Any) -> dict[str, Any]:
174
+ return self._transport.request("GET", f"/heroes/{hero_identifier}/counters", params=params)
175
+
176
+ def hero_compatibility(self, hero_identifier: str | int, **params: Any) -> dict[str, Any]:
177
+ return self._transport.request("GET", f"/heroes/{hero_identifier}/compatibility", params=params)
178
+
179
+
180
+ class UserClient:
181
+ def __init__(self, transport: _Transport) -> None:
182
+ self._transport = transport
183
+
184
+ def send_vc(self, role_id: int, zone_id: int) -> dict[str, Any]:
185
+ body = {"role_id": role_id, "zone_id": zone_id}
186
+ return self._transport.request("POST", "/user/auth/send-vc", json_body=body)
187
+
188
+ def login(self, role_id: int, zone_id: int, vc: str) -> dict[str, Any]:
189
+ body = {"role_id": role_id, "zone_id": zone_id, "vc": vc}
190
+ return self._transport.request("POST", "/user/auth/login", json_body=body)
191
+
192
+ def logout(self, jwt: str) -> dict[str, Any]:
193
+ return self._transport.request("POST", "/user/auth/logout", jwt=jwt)
194
+
195
+ def info(self, jwt: str, **params: Any) -> dict[str, Any]:
196
+ return self._transport.request("GET", "/user/info", params=params, jwt=jwt)
197
+
198
+ def stats(self, jwt: str, **params: Any) -> dict[str, Any]:
199
+ return self._transport.request("GET", "/user/stats", params=params, jwt=jwt)
200
+
201
+ def privacy_settings(self, jwt: str, **params: Any) -> dict[str, Any]:
202
+ return self._transport.request("GET", "/user/privacy/settings", params=params, jwt=jwt)
203
+
204
+ def update_privacy_settings(self, jwt: str, body: dict[str, Any], **params: Any) -> dict[str, Any]:
205
+ return self._transport.request("POST", "/user/privacy/settings", params=params, json_body=body, jwt=jwt)
206
+
207
+ def season(self, jwt: str, **params: Any) -> dict[str, Any]:
208
+ return self._transport.request("GET", "/user/season", params=params, jwt=jwt)
209
+
210
+ def matches(self, jwt: str, **params: Any) -> dict[str, Any]:
211
+ return self._transport.request("GET", "/user/matches", params=params, jwt=jwt)
212
+
213
+ def match_detail(self, match_id: str | int, jwt: str, **params: Any) -> dict[str, Any]:
214
+ return self._transport.request("GET", f"/user/matches/{match_id}", params=params, jwt=jwt)
215
+
216
+ def heroes_frequent(self, jwt: str, **params: Any) -> dict[str, Any]:
217
+ return self._transport.request("GET", "/user/heroes/frequent", params=params, jwt=jwt)
218
+
219
+ def matches_by_hero(self, hero_identifier: str | int, jwt: str, **params: Any) -> dict[str, Any]:
220
+ return self._transport.request("GET", f"/user/matches/hero/{hero_identifier}", params=params, jwt=jwt)
221
+
222
+ def friends(self, jwt: str, **params: Any) -> dict[str, Any]:
223
+ return self._transport.request("GET", "/user/friends", params=params, jwt=jwt)
224
+
225
+
226
+ class AddonClient:
227
+ def __init__(self, transport: _Transport) -> None:
228
+ self._transport = transport
229
+
230
+ def win_rate_calculator(self, match_now: int, wr_now: float, wr_future: float) -> dict[str, Any]:
231
+ params = {
232
+ "match-now": match_now,
233
+ "wr-now": wr_now,
234
+ "wr-future": wr_future,
235
+ }
236
+ return self._transport.request("GET", "/addon/win-rate-calculator", params=params)
237
+
238
+ def ip(self) -> dict[str, Any]:
239
+ return self._transport.request("GET", "/addon/ip")
240
+
241
+
242
+ class OpenMLBB:
243
+ """Python SDK for https://mlbb.rone.dev/api."""
244
+
245
+ def __init__(
246
+ self,
247
+ base_url: str = DEFAULT_BASE_URL,
248
+ timeout: int = DEFAULT_TIMEOUT,
249
+ user_agent: str = DEFAULT_USER_AGENT,
250
+ session: requests.Session | None = None,
251
+ ) -> None:
252
+ active_session = session or requests.Session()
253
+ self._transport = _Transport(
254
+ base_url=base_url,
255
+ timeout=timeout,
256
+ user_agent=user_agent,
257
+ session=active_session,
258
+ )
259
+
260
+ self.academy = AcademyClient(self._transport)
261
+ self.mlbb = MlbbClient(self._transport)
262
+ self.user = UserClient(self._transport)
263
+ self.addon = AddonClient(self._transport)
@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.4
2
+ Name: OpenMLBB
3
+ Version: 4.0.3
4
+ Summary: Official Python SDK for the MLBB Public Data API
5
+ Author: ridwaanhall
6
+ License: BSD-3-Clause
7
+ Project-URL: Homepage, https://mlbb.rone.dev
8
+ Project-URL: Documentation, https://mlbb.rone.dev/api/docs
9
+ Project-URL: Repository, https://github.com/ridwaanhall/api-mobilelegends
10
+ Project-URL: Issues, https://github.com/ridwaanhall/api-mobilelegends/issues
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: fastapi[standard]>=0.135.2
15
+ Requires-Dist: requests<3,>=2.32.0
16
+ Requires-Dist: cryptography==46.0.7
17
+ Dynamic: license-file
18
+
19
+ # OpenMLBB Python SDK
20
+
21
+ OpenMLBB is the official Python SDK for `https://mlbb.rone.dev/api`.
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ pip install OpenMLBB
27
+ ```
28
+
29
+ ## Quick Start
30
+
31
+ ```python
32
+ from OpenMLBB import OpenMLBB
33
+
34
+ client = OpenMLBB()
35
+
36
+ heroes = client.mlbb.heroes(size=5, index=1, order="desc", lang="en")
37
+ academy_roles = client.academy.roles(lang="en")
38
+ win_rate = client.addon.win_rate_calculator(match_now=100, wr_now=50, wr_future=60)
39
+
40
+ print(heroes)
41
+ print(academy_roles)
42
+ print(win_rate)
43
+ ```
44
+
45
+ Every SDK method returns API JSON as a Python dictionary.
46
+
47
+ ## User-Agent
48
+
49
+ The default `User-Agent` is:
50
+
51
+ `RoneAI-OpenMLBB-Python-SDK`
52
+
53
+ You can override it by passing `user_agent=` to `OpenMLBB(...)`.
@@ -0,0 +1,8 @@
1
+ OpenMLBB/__init__.py,sha256=d6vZrUiNIqcYn1mrt0g7jD9QC9xJlJooOcYsEq60XFA,358
2
+ OpenMLBB/_version.py,sha256=3bPx_fWwryxaejLsrik-kDIPsiwlha5q_tkZReKQ2A4,59
3
+ OpenMLBB/client.py,sha256=MyPRVpNK5dJA-ucWgC6fT5ihIo0LPgflEfcsrnrhAsI,11191
4
+ openmlbb-4.0.3.dist-info/licenses/LICENSE,sha256=GskHpiJ6sklHXbO_AdAkjz2WXsGDJ59MEUXeX8sbU00,1512
5
+ openmlbb-4.0.3.dist-info/METADATA,sha256=Yka-Mu_L_2LFiz_pLcl2Tao-_43ObJAPWeL-1TYCu_w,1304
6
+ openmlbb-4.0.3.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
7
+ openmlbb-4.0.3.dist-info/top_level.txt,sha256=7gjgn8GO0McwvGRwRh5a-0OvL65dvgAQzZTfvxKgntc,9
8
+ openmlbb-4.0.3.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2024-2026, ridwaanhall / RoneAI
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1 @@
1
+ OpenMLBB