python-eveonline 0.1.0__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.
- eveonline/__init__.py +22 -0
- eveonline/auth.py +68 -0
- eveonline/client.py +364 -0
- eveonline/const.py +34 -0
- eveonline/exceptions.py +29 -0
- eveonline/models.py +119 -0
- eveonline/py.typed +0 -0
- python_eveonline-0.1.0.dist-info/METADATA +71 -0
- python_eveonline-0.1.0.dist-info/RECORD +12 -0
- python_eveonline-0.1.0.dist-info/WHEEL +5 -0
- python_eveonline-0.1.0.dist-info/licenses/LICENSE +21 -0
- python_eveonline-0.1.0.dist-info/top_level.txt +1 -0
eveonline/__init__.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""Async Python client for the Eve Online ESI API."""
|
|
2
|
+
|
|
3
|
+
from .auth import AbstractAuth
|
|
4
|
+
from .client import EveOnlineClient
|
|
5
|
+
from .exceptions import (
|
|
6
|
+
EveOnlineAuthenticationError,
|
|
7
|
+
EveOnlineConnectionError,
|
|
8
|
+
EveOnlineError,
|
|
9
|
+
EveOnlineRateLimitError,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
__version__ = "0.1.0"
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"AbstractAuth",
|
|
16
|
+
"EveOnlineAuthenticationError",
|
|
17
|
+
"EveOnlineClient",
|
|
18
|
+
"EveOnlineConnectionError",
|
|
19
|
+
"EveOnlineError",
|
|
20
|
+
"EveOnlineRateLimitError",
|
|
21
|
+
"__version__",
|
|
22
|
+
]
|
eveonline/auth.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"""Abstract authentication for the Eve Online ESI API."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from abc import ABC, abstractmethod
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from aiohttp import ClientResponse, ClientSession
|
|
9
|
+
|
|
10
|
+
from .const import ESI_BASE_URL
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class AbstractAuth(ABC):
|
|
14
|
+
"""Abstract class to make authenticated requests to the ESI API.
|
|
15
|
+
|
|
16
|
+
This follows the Home Assistant API library pattern where the library
|
|
17
|
+
provides an abstract auth class, and the integration (or standalone user)
|
|
18
|
+
provides a concrete implementation that handles token management.
|
|
19
|
+
|
|
20
|
+
Example usage::
|
|
21
|
+
|
|
22
|
+
class MyAuth(AbstractAuth):
|
|
23
|
+
async def async_get_access_token(self) -> str:
|
|
24
|
+
return self._my_token_manager.get_token()
|
|
25
|
+
|
|
26
|
+
auth = MyAuth(session)
|
|
27
|
+
client = EveOnlineClient(auth=auth)
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
def __init__(
|
|
31
|
+
self,
|
|
32
|
+
websession: ClientSession,
|
|
33
|
+
host: str = ESI_BASE_URL,
|
|
34
|
+
) -> None:
|
|
35
|
+
"""Initialize the auth.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
websession: An aiohttp ClientSession for making requests.
|
|
39
|
+
host: The ESI API base URL. Defaults to the official ESI endpoint.
|
|
40
|
+
"""
|
|
41
|
+
self.websession = websession
|
|
42
|
+
self.host = host
|
|
43
|
+
|
|
44
|
+
@abstractmethod
|
|
45
|
+
async def async_get_access_token(self) -> str:
|
|
46
|
+
"""Return a valid access token for the ESI API."""
|
|
47
|
+
|
|
48
|
+
async def request(self, method: str, path: str, **kwargs: Any) -> ClientResponse:
|
|
49
|
+
"""Make an authenticated request to the ESI API.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
method: HTTP method (GET, POST, etc.).
|
|
53
|
+
path: API path (e.g., "characters/12345/wallet/").
|
|
54
|
+
**kwargs: Additional arguments passed to aiohttp request.
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
The aiohttp ClientResponse.
|
|
58
|
+
"""
|
|
59
|
+
headers: dict[str, str] = dict(kwargs.pop("headers", {}) or {})
|
|
60
|
+
access_token = await self.async_get_access_token()
|
|
61
|
+
headers["authorization"] = f"Bearer {access_token}"
|
|
62
|
+
|
|
63
|
+
return await self.websession.request(
|
|
64
|
+
method,
|
|
65
|
+
f"{self.host}/{path}",
|
|
66
|
+
**kwargs,
|
|
67
|
+
headers=headers,
|
|
68
|
+
)
|
eveonline/client.py
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
"""Async client for the Eve Online ESI API."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from aiohttp import ClientSession
|
|
9
|
+
|
|
10
|
+
from .auth import AbstractAuth
|
|
11
|
+
from .const import ESI_BASE_URL, ESI_DATASOURCE
|
|
12
|
+
from .exceptions import (
|
|
13
|
+
EveOnlineAuthenticationError,
|
|
14
|
+
EveOnlineConnectionError,
|
|
15
|
+
EveOnlineError,
|
|
16
|
+
EveOnlineNotFoundError,
|
|
17
|
+
EveOnlineRateLimitError,
|
|
18
|
+
)
|
|
19
|
+
from .models import (
|
|
20
|
+
CharacterLocation,
|
|
21
|
+
CharacterOnlineStatus,
|
|
22
|
+
CharacterPortrait,
|
|
23
|
+
CharacterPublicInfo,
|
|
24
|
+
CharacterShip,
|
|
25
|
+
CorporationPublicInfo,
|
|
26
|
+
ServerStatus,
|
|
27
|
+
SkillQueueEntry,
|
|
28
|
+
UniverseName,
|
|
29
|
+
WalletBalance,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class EveOnlineClient:
|
|
34
|
+
"""Async client for the Eve Online ESI API.
|
|
35
|
+
|
|
36
|
+
This client supports two modes:
|
|
37
|
+
|
|
38
|
+
1. **Unauthenticated**: For public endpoints (server status, character
|
|
39
|
+
public info, corporation info, universe lookups). Only requires an
|
|
40
|
+
aiohttp session.
|
|
41
|
+
|
|
42
|
+
2. **Authenticated**: For character-specific endpoints (online status,
|
|
43
|
+
wallet, location, skills). Requires an ``AbstractAuth`` implementation
|
|
44
|
+
that provides access tokens.
|
|
45
|
+
|
|
46
|
+
Example (unauthenticated)::
|
|
47
|
+
|
|
48
|
+
async with aiohttp.ClientSession() as session:
|
|
49
|
+
client = EveOnlineClient(session=session)
|
|
50
|
+
status = await client.async_get_server_status()
|
|
51
|
+
print(f"Players online: {status.players}")
|
|
52
|
+
|
|
53
|
+
Example (authenticated)::
|
|
54
|
+
|
|
55
|
+
auth = MyAuth(session) # Your AbstractAuth implementation
|
|
56
|
+
client = EveOnlineClient(auth=auth)
|
|
57
|
+
online = await client.async_get_character_online(character_id)
|
|
58
|
+
print(f"Online: {online.online}")
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
def __init__(
|
|
62
|
+
self,
|
|
63
|
+
session: ClientSession | None = None,
|
|
64
|
+
auth: AbstractAuth | None = None,
|
|
65
|
+
host: str = ESI_BASE_URL,
|
|
66
|
+
) -> None:
|
|
67
|
+
"""Initialize the client.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
session: aiohttp session for unauthenticated requests.
|
|
71
|
+
If ``auth`` is provided, its session is used instead.
|
|
72
|
+
auth: Authentication provider for authenticated endpoints.
|
|
73
|
+
host: ESI API base URL. Defaults to the official ESI endpoint.
|
|
74
|
+
"""
|
|
75
|
+
self._auth = auth
|
|
76
|
+
self._host = host
|
|
77
|
+
|
|
78
|
+
if auth is not None:
|
|
79
|
+
self._session = auth.websession
|
|
80
|
+
elif session is not None:
|
|
81
|
+
self._session = session
|
|
82
|
+
else:
|
|
83
|
+
msg = "Either 'session' or 'auth' must be provided"
|
|
84
|
+
raise EveOnlineError(msg)
|
|
85
|
+
|
|
86
|
+
# -------------------------------------------------------------------------
|
|
87
|
+
# Internal helpers
|
|
88
|
+
# -------------------------------------------------------------------------
|
|
89
|
+
|
|
90
|
+
async def _request(self, method: str, path: str, *, authenticated: bool = False, **kwargs: Any) -> Any:
|
|
91
|
+
"""Make a request to the ESI API.
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
method: HTTP method.
|
|
95
|
+
path: API path relative to ESI base URL.
|
|
96
|
+
authenticated: Whether this request requires authentication.
|
|
97
|
+
**kwargs: Additional arguments for the HTTP request.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
Parsed JSON response.
|
|
101
|
+
|
|
102
|
+
Raises:
|
|
103
|
+
EveOnlineAuthenticationError: If auth is required but not provided,
|
|
104
|
+
or if the token is invalid/expired.
|
|
105
|
+
EveOnlineConnectionError: If the ESI API is unreachable.
|
|
106
|
+
EveOnlineRateLimitError: If the rate limit is exceeded.
|
|
107
|
+
EveOnlineNotFoundError: If the resource is not found.
|
|
108
|
+
EveOnlineError: For other ESI API errors.
|
|
109
|
+
"""
|
|
110
|
+
params: dict[str, Any] = dict(kwargs.pop("params", {}) or {})
|
|
111
|
+
params.setdefault("datasource", ESI_DATASOURCE)
|
|
112
|
+
|
|
113
|
+
try:
|
|
114
|
+
if authenticated:
|
|
115
|
+
if self._auth is None:
|
|
116
|
+
msg = "Authentication required but no auth provider configured"
|
|
117
|
+
raise EveOnlineAuthenticationError(msg)
|
|
118
|
+
response = await self._auth.request(method, path, params=params, **kwargs)
|
|
119
|
+
else:
|
|
120
|
+
response = await self._session.request(
|
|
121
|
+
method,
|
|
122
|
+
f"{self._host}/{path}",
|
|
123
|
+
params=params,
|
|
124
|
+
**kwargs,
|
|
125
|
+
)
|
|
126
|
+
except EveOnlineError:
|
|
127
|
+
raise
|
|
128
|
+
except Exception as err:
|
|
129
|
+
msg = f"Failed to connect to ESI API: {err}"
|
|
130
|
+
raise EveOnlineConnectionError(msg) from err
|
|
131
|
+
|
|
132
|
+
if response.status in (401, 403):
|
|
133
|
+
text = await response.text()
|
|
134
|
+
msg = f"Authentication failed ({response.status}): {text}"
|
|
135
|
+
raise EveOnlineAuthenticationError(msg)
|
|
136
|
+
|
|
137
|
+
if response.status == 404:
|
|
138
|
+
msg = f"Resource not found: {path}"
|
|
139
|
+
raise EveOnlineNotFoundError(msg)
|
|
140
|
+
|
|
141
|
+
if response.status in (420, 429):
|
|
142
|
+
retry_after = response.headers.get("Retry-After")
|
|
143
|
+
raise EveOnlineRateLimitError(retry_after=int(retry_after) if retry_after else None)
|
|
144
|
+
|
|
145
|
+
if response.status >= 400:
|
|
146
|
+
text = await response.text()
|
|
147
|
+
msg = f"ESI API error ({response.status}): {text}"
|
|
148
|
+
raise EveOnlineError(msg)
|
|
149
|
+
|
|
150
|
+
return await response.json()
|
|
151
|
+
|
|
152
|
+
@staticmethod
|
|
153
|
+
def _parse_datetime(value: str | None) -> datetime | None:
|
|
154
|
+
"""Parse an ISO8601 datetime string from ESI."""
|
|
155
|
+
if value is None:
|
|
156
|
+
return None
|
|
157
|
+
# ESI returns times like "2025-01-15T12:34:56Z"
|
|
158
|
+
return datetime.fromisoformat(value.replace("Z", "+00:00"))
|
|
159
|
+
|
|
160
|
+
# -------------------------------------------------------------------------
|
|
161
|
+
# Public endpoints (no auth required)
|
|
162
|
+
# -------------------------------------------------------------------------
|
|
163
|
+
|
|
164
|
+
async def async_get_server_status(self) -> ServerStatus:
|
|
165
|
+
"""Get the current Tranquility server status.
|
|
166
|
+
|
|
167
|
+
Returns:
|
|
168
|
+
ServerStatus with player count, version, and start time.
|
|
169
|
+
"""
|
|
170
|
+
data = await self._request("GET", "status/")
|
|
171
|
+
return ServerStatus(
|
|
172
|
+
players=data["players"],
|
|
173
|
+
server_version=data["server_version"],
|
|
174
|
+
start_time=datetime.fromisoformat(data["start_time"].replace("Z", "+00:00")),
|
|
175
|
+
vip=data.get("vip"),
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
async def async_get_character_public(self, character_id: int) -> CharacterPublicInfo:
|
|
179
|
+
"""Get public information about a character.
|
|
180
|
+
|
|
181
|
+
Args:
|
|
182
|
+
character_id: The Eve Online character ID.
|
|
183
|
+
|
|
184
|
+
Returns:
|
|
185
|
+
CharacterPublicInfo with name, corporation, and more.
|
|
186
|
+
"""
|
|
187
|
+
data = await self._request("GET", f"characters/{character_id}/")
|
|
188
|
+
return CharacterPublicInfo(
|
|
189
|
+
character_id=character_id,
|
|
190
|
+
name=data["name"],
|
|
191
|
+
corporation_id=data["corporation_id"],
|
|
192
|
+
birthday=datetime.fromisoformat(data["birthday"].replace("Z", "+00:00")),
|
|
193
|
+
gender=data["gender"],
|
|
194
|
+
race_id=data["race_id"],
|
|
195
|
+
bloodline_id=data["bloodline_id"],
|
|
196
|
+
ancestry_id=data.get("ancestry_id"),
|
|
197
|
+
alliance_id=data.get("alliance_id"),
|
|
198
|
+
faction_id=data.get("faction_id"),
|
|
199
|
+
description=data.get("description"),
|
|
200
|
+
title=data.get("title"),
|
|
201
|
+
security_status=data.get("security_status"),
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
async def async_get_character_portrait(self, character_id: int) -> CharacterPortrait:
|
|
205
|
+
"""Get a character's portrait URLs.
|
|
206
|
+
|
|
207
|
+
Args:
|
|
208
|
+
character_id: The Eve Online character ID.
|
|
209
|
+
|
|
210
|
+
Returns:
|
|
211
|
+
CharacterPortrait with image URLs at various resolutions.
|
|
212
|
+
"""
|
|
213
|
+
data = await self._request("GET", f"characters/{character_id}/portrait/")
|
|
214
|
+
return CharacterPortrait(
|
|
215
|
+
px64x64=data.get("px64x64"),
|
|
216
|
+
px128x128=data.get("px128x128"),
|
|
217
|
+
px256x256=data.get("px256x256"),
|
|
218
|
+
px512x512=data.get("px512x512"),
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
async def async_get_corporation_public(self, corporation_id: int) -> CorporationPublicInfo:
|
|
222
|
+
"""Get public information about a corporation.
|
|
223
|
+
|
|
224
|
+
Args:
|
|
225
|
+
corporation_id: The Eve Online corporation ID.
|
|
226
|
+
|
|
227
|
+
Returns:
|
|
228
|
+
CorporationPublicInfo with name, ticker, member count, and more.
|
|
229
|
+
"""
|
|
230
|
+
data = await self._request("GET", f"corporations/{corporation_id}/")
|
|
231
|
+
return CorporationPublicInfo(
|
|
232
|
+
corporation_id=corporation_id,
|
|
233
|
+
name=data["name"],
|
|
234
|
+
ticker=data["ticker"],
|
|
235
|
+
member_count=data["member_count"],
|
|
236
|
+
ceo_id=data["ceo_id"],
|
|
237
|
+
tax_rate=data["tax_rate"],
|
|
238
|
+
alliance_id=data.get("alliance_id"),
|
|
239
|
+
description=data.get("description"),
|
|
240
|
+
date_founded=self._parse_datetime(data.get("date_founded")),
|
|
241
|
+
url=data.get("url"),
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
async def async_resolve_names(self, ids: list[int]) -> list[UniverseName]:
|
|
245
|
+
"""Resolve a list of IDs to names.
|
|
246
|
+
|
|
247
|
+
Args:
|
|
248
|
+
ids: List of Eve Online entity IDs (characters, corps, etc.).
|
|
249
|
+
|
|
250
|
+
Returns:
|
|
251
|
+
List of UniverseName with id, name, and category.
|
|
252
|
+
"""
|
|
253
|
+
if not ids:
|
|
254
|
+
return []
|
|
255
|
+
|
|
256
|
+
data = await self._request("POST", "universe/names/", json=ids)
|
|
257
|
+
return [
|
|
258
|
+
UniverseName(
|
|
259
|
+
id=entry["id"],
|
|
260
|
+
name=entry["name"],
|
|
261
|
+
category=entry["category"],
|
|
262
|
+
)
|
|
263
|
+
for entry in data
|
|
264
|
+
]
|
|
265
|
+
|
|
266
|
+
# -------------------------------------------------------------------------
|
|
267
|
+
# Authenticated endpoints (auth required)
|
|
268
|
+
# -------------------------------------------------------------------------
|
|
269
|
+
|
|
270
|
+
async def async_get_character_online(self, character_id: int) -> CharacterOnlineStatus:
|
|
271
|
+
"""Get a character's online status.
|
|
272
|
+
|
|
273
|
+
Requires scope: ``esi-location.read_online.v1``
|
|
274
|
+
|
|
275
|
+
Args:
|
|
276
|
+
character_id: The Eve Online character ID.
|
|
277
|
+
|
|
278
|
+
Returns:
|
|
279
|
+
CharacterOnlineStatus with online flag and login/logout times.
|
|
280
|
+
"""
|
|
281
|
+
data = await self._request("GET", f"characters/{character_id}/online/", authenticated=True)
|
|
282
|
+
return CharacterOnlineStatus(
|
|
283
|
+
online=data["online"],
|
|
284
|
+
last_login=self._parse_datetime(data.get("last_login")),
|
|
285
|
+
last_logout=self._parse_datetime(data.get("last_logout")),
|
|
286
|
+
logins=data.get("logins"),
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
async def async_get_character_location(self, character_id: int) -> CharacterLocation:
|
|
290
|
+
"""Get a character's current location.
|
|
291
|
+
|
|
292
|
+
Requires scope: ``esi-location.read_location.v1``
|
|
293
|
+
|
|
294
|
+
Args:
|
|
295
|
+
character_id: The Eve Online character ID.
|
|
296
|
+
|
|
297
|
+
Returns:
|
|
298
|
+
CharacterLocation with solar system, station, or structure ID.
|
|
299
|
+
"""
|
|
300
|
+
data = await self._request("GET", f"characters/{character_id}/location/", authenticated=True)
|
|
301
|
+
return CharacterLocation(
|
|
302
|
+
solar_system_id=data["solar_system_id"],
|
|
303
|
+
station_id=data.get("station_id"),
|
|
304
|
+
structure_id=data.get("structure_id"),
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
async def async_get_character_ship(self, character_id: int) -> CharacterShip:
|
|
308
|
+
"""Get a character's current ship.
|
|
309
|
+
|
|
310
|
+
Requires scope: ``esi-location.read_ship_type.v1``
|
|
311
|
+
|
|
312
|
+
Args:
|
|
313
|
+
character_id: The Eve Online character ID.
|
|
314
|
+
|
|
315
|
+
Returns:
|
|
316
|
+
CharacterShip with ship type, item ID, and name.
|
|
317
|
+
"""
|
|
318
|
+
data = await self._request("GET", f"characters/{character_id}/ship/", authenticated=True)
|
|
319
|
+
return CharacterShip(
|
|
320
|
+
ship_type_id=data["ship_type_id"],
|
|
321
|
+
ship_item_id=data["ship_item_id"],
|
|
322
|
+
ship_name=data["ship_name"],
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
async def async_get_wallet_balance(self, character_id: int) -> WalletBalance:
|
|
326
|
+
"""Get a character's wallet balance.
|
|
327
|
+
|
|
328
|
+
Requires scope: ``esi-wallet.read_character_wallet.v1``
|
|
329
|
+
|
|
330
|
+
Args:
|
|
331
|
+
character_id: The Eve Online character ID.
|
|
332
|
+
|
|
333
|
+
Returns:
|
|
334
|
+
WalletBalance with ISK balance.
|
|
335
|
+
"""
|
|
336
|
+
data = await self._request("GET", f"characters/{character_id}/wallet/", authenticated=True)
|
|
337
|
+
# Wallet endpoint returns a raw float, not a JSON object
|
|
338
|
+
return WalletBalance(balance=float(data))
|
|
339
|
+
|
|
340
|
+
async def async_get_skill_queue(self, character_id: int) -> list[SkillQueueEntry]:
|
|
341
|
+
"""Get a character's skill training queue.
|
|
342
|
+
|
|
343
|
+
Requires scope: ``esi-skills.read_skillqueue.v1``
|
|
344
|
+
|
|
345
|
+
Args:
|
|
346
|
+
character_id: The Eve Online character ID.
|
|
347
|
+
|
|
348
|
+
Returns:
|
|
349
|
+
List of SkillQueueEntry, ordered by queue_position.
|
|
350
|
+
"""
|
|
351
|
+
data = await self._request("GET", f"characters/{character_id}/skillqueue/", authenticated=True)
|
|
352
|
+
return [
|
|
353
|
+
SkillQueueEntry(
|
|
354
|
+
skill_id=entry["skill_id"],
|
|
355
|
+
queue_position=entry["queue_position"],
|
|
356
|
+
finished_level=entry["finished_level"],
|
|
357
|
+
start_date=self._parse_datetime(entry.get("start_date")),
|
|
358
|
+
finish_date=self._parse_datetime(entry.get("finish_date")),
|
|
359
|
+
training_start_sp=entry.get("training_start_sp"),
|
|
360
|
+
level_start_sp=entry.get("level_start_sp"),
|
|
361
|
+
level_end_sp=entry.get("level_end_sp"),
|
|
362
|
+
)
|
|
363
|
+
for entry in data
|
|
364
|
+
]
|
eveonline/const.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Constants for the Eve Online ESI API."""
|
|
2
|
+
|
|
3
|
+
from typing import Final
|
|
4
|
+
|
|
5
|
+
# ESI API
|
|
6
|
+
ESI_BASE_URL: Final = "https://esi.evetech.net/latest"
|
|
7
|
+
ESI_DATASOURCE: Final = "tranquility"
|
|
8
|
+
|
|
9
|
+
# EVE SSO
|
|
10
|
+
SSO_AUTHORIZE_URL: Final = "https://login.eveonline.com/v2/oauth/authorize"
|
|
11
|
+
SSO_TOKEN_URL: Final = "https://login.eveonline.com/v2/oauth/token"
|
|
12
|
+
SSO_JWKS_URL: Final = "https://login.eveonline.com/oauth/jwks"
|
|
13
|
+
|
|
14
|
+
# Scopes
|
|
15
|
+
SCOPE_READ_ONLINE: Final = "esi-location.read_online.v1"
|
|
16
|
+
SCOPE_READ_LOCATION: Final = "esi-location.read_location.v1"
|
|
17
|
+
SCOPE_READ_SHIP_TYPE: Final = "esi-location.read_ship_type.v1"
|
|
18
|
+
SCOPE_READ_WALLET: Final = "esi-wallet.read_character_wallet.v1"
|
|
19
|
+
SCOPE_READ_SKILLS: Final = "esi-skills.read_skills.v1"
|
|
20
|
+
SCOPE_READ_SKILLQUEUE: Final = "esi-skills.read_skillqueue.v1"
|
|
21
|
+
SCOPE_READ_KILLMAILS: Final = "esi-killmails.read_killmails.v1"
|
|
22
|
+
SCOPE_READ_CLONES: Final = "esi-clones.read_clones.v1"
|
|
23
|
+
SCOPE_READ_IMPLANTS: Final = "esi-clones.read_implants.v1"
|
|
24
|
+
SCOPE_READ_NOTIFICATIONS: Final = "esi-characters.read_notifications.v1"
|
|
25
|
+
|
|
26
|
+
# Default scopes for a typical Home Assistant integration
|
|
27
|
+
DEFAULT_SCOPES: Final = [
|
|
28
|
+
SCOPE_READ_ONLINE,
|
|
29
|
+
SCOPE_READ_LOCATION,
|
|
30
|
+
SCOPE_READ_SHIP_TYPE,
|
|
31
|
+
SCOPE_READ_WALLET,
|
|
32
|
+
SCOPE_READ_SKILLS,
|
|
33
|
+
SCOPE_READ_SKILLQUEUE,
|
|
34
|
+
]
|
eveonline/exceptions.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Exceptions for the Eve Online ESI client."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class EveOnlineError(Exception):
|
|
5
|
+
"""Base exception for Eve Online ESI errors."""
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class EveOnlineConnectionError(EveOnlineError):
|
|
9
|
+
"""Exception raised when the ESI API is unreachable."""
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class EveOnlineAuthenticationError(EveOnlineError):
|
|
13
|
+
"""Exception raised when authentication fails or token is invalid."""
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class EveOnlineRateLimitError(EveOnlineError):
|
|
17
|
+
"""Exception raised when the ESI rate limit is exceeded."""
|
|
18
|
+
|
|
19
|
+
def __init__(self, retry_after: int | None = None) -> None:
|
|
20
|
+
"""Initialize the rate limit error."""
|
|
21
|
+
self.retry_after = retry_after
|
|
22
|
+
message = "ESI rate limit exceeded"
|
|
23
|
+
if retry_after is not None:
|
|
24
|
+
message += f", retry after {retry_after}s"
|
|
25
|
+
super().__init__(message)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class EveOnlineNotFoundError(EveOnlineError):
|
|
29
|
+
"""Exception raised when a resource is not found (404)."""
|
eveonline/models.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"""Data models for the Eve Online ESI API."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from datetime import datetime
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass(frozen=True)
|
|
10
|
+
class ServerStatus:
|
|
11
|
+
"""EVE Online server (Tranquility) status."""
|
|
12
|
+
|
|
13
|
+
players: int
|
|
14
|
+
server_version: str
|
|
15
|
+
start_time: datetime
|
|
16
|
+
vip: bool | None = None
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass(frozen=True)
|
|
20
|
+
class CharacterPublicInfo:
|
|
21
|
+
"""Public character information (no auth required)."""
|
|
22
|
+
|
|
23
|
+
character_id: int
|
|
24
|
+
name: str
|
|
25
|
+
corporation_id: int
|
|
26
|
+
birthday: datetime
|
|
27
|
+
gender: str
|
|
28
|
+
race_id: int
|
|
29
|
+
bloodline_id: int
|
|
30
|
+
ancestry_id: int | None = None
|
|
31
|
+
alliance_id: int | None = None
|
|
32
|
+
faction_id: int | None = None
|
|
33
|
+
description: str | None = None
|
|
34
|
+
title: str | None = None
|
|
35
|
+
security_status: float | None = None
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@dataclass(frozen=True)
|
|
39
|
+
class CharacterPortrait:
|
|
40
|
+
"""Character portrait URLs."""
|
|
41
|
+
|
|
42
|
+
px64x64: str | None = None
|
|
43
|
+
px128x128: str | None = None
|
|
44
|
+
px256x256: str | None = None
|
|
45
|
+
px512x512: str | None = None
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclass(frozen=True)
|
|
49
|
+
class CorporationPublicInfo:
|
|
50
|
+
"""Public corporation information (no auth required)."""
|
|
51
|
+
|
|
52
|
+
corporation_id: int
|
|
53
|
+
name: str
|
|
54
|
+
ticker: str
|
|
55
|
+
member_count: int
|
|
56
|
+
ceo_id: int
|
|
57
|
+
tax_rate: float
|
|
58
|
+
alliance_id: int | None = None
|
|
59
|
+
description: str | None = None
|
|
60
|
+
date_founded: datetime | None = None
|
|
61
|
+
url: str | None = None
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@dataclass(frozen=True)
|
|
65
|
+
class CharacterOnlineStatus:
|
|
66
|
+
"""Character online status (requires auth)."""
|
|
67
|
+
|
|
68
|
+
online: bool
|
|
69
|
+
last_login: datetime | None = None
|
|
70
|
+
last_logout: datetime | None = None
|
|
71
|
+
logins: int | None = None
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@dataclass(frozen=True)
|
|
75
|
+
class CharacterLocation:
|
|
76
|
+
"""Character current location (requires auth)."""
|
|
77
|
+
|
|
78
|
+
solar_system_id: int
|
|
79
|
+
station_id: int | None = None
|
|
80
|
+
structure_id: int | None = None
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@dataclass(frozen=True)
|
|
84
|
+
class CharacterShip:
|
|
85
|
+
"""Character current ship (requires auth)."""
|
|
86
|
+
|
|
87
|
+
ship_type_id: int
|
|
88
|
+
ship_item_id: int
|
|
89
|
+
ship_name: str
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@dataclass(frozen=True)
|
|
93
|
+
class WalletBalance:
|
|
94
|
+
"""Character wallet balance (requires auth)."""
|
|
95
|
+
|
|
96
|
+
balance: float
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
@dataclass(frozen=True)
|
|
100
|
+
class SkillQueueEntry:
|
|
101
|
+
"""A single skill in the training queue (requires auth)."""
|
|
102
|
+
|
|
103
|
+
skill_id: int
|
|
104
|
+
queue_position: int
|
|
105
|
+
finished_level: int
|
|
106
|
+
start_date: datetime | None = None
|
|
107
|
+
finish_date: datetime | None = None
|
|
108
|
+
training_start_sp: int | None = None
|
|
109
|
+
level_start_sp: int | None = None
|
|
110
|
+
level_end_sp: int | None = None
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@dataclass(frozen=True)
|
|
114
|
+
class UniverseName:
|
|
115
|
+
"""Resolved ID → name mapping."""
|
|
116
|
+
|
|
117
|
+
id: int
|
|
118
|
+
name: str
|
|
119
|
+
category: str
|
eveonline/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-eveonline
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Async Python client for the Eve Online ESI API
|
|
5
|
+
Author: Ronald van der Meer
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/ronaldvdmeer/python-eveonline
|
|
8
|
+
Project-URL: Repository, https://github.com/ronaldvdmeer/python-eveonline
|
|
9
|
+
Project-URL: Issues, https://github.com/ronaldvdmeer/python-eveonline/issues
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Topic :: Games/Entertainment
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Classifier: Framework :: AsyncIO
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: aiohttp>=3.9.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
|
|
26
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
27
|
+
Requires-Dist: aioresponses>=0.7; extra == "dev"
|
|
28
|
+
Requires-Dist: mypy>=1.8; extra == "dev"
|
|
29
|
+
Requires-Dist: pylint>=3.0; extra == "dev"
|
|
30
|
+
Requires-Dist: ruff>=0.3; extra == "dev"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# python-eveonline
|
|
34
|
+
|
|
35
|
+
Async Python client library for the [Eve Online ESI API](https://esi.evetech.net/ui/).
|
|
36
|
+
|
|
37
|
+
## Features
|
|
38
|
+
|
|
39
|
+
- Fully async (aiohttp)
|
|
40
|
+
- Typed models (frozen dataclasses)
|
|
41
|
+
- Public endpoints: server status, character info, corporation info, portraits, name resolution
|
|
42
|
+
- Authenticated endpoints: online status, location, ship, wallet, skill queue
|
|
43
|
+
- AbstractAuth pattern for Home Assistant OAuth2 integration
|
|
44
|
+
- PEP 561 typed package (py.typed)
|
|
45
|
+
- 100% test coverage
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install python-eveonline
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Quick Start
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
import asyncio
|
|
57
|
+
import aiohttp
|
|
58
|
+
from eveonline import EveOnlineClient
|
|
59
|
+
|
|
60
|
+
async def main():
|
|
61
|
+
async with aiohttp.ClientSession() as session:
|
|
62
|
+
client = EveOnlineClient(session=session)
|
|
63
|
+
status = await client.async_get_server_status()
|
|
64
|
+
print(f"{status.players} players online")
|
|
65
|
+
|
|
66
|
+
asyncio.run(main())
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
MIT
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
eveonline/__init__.py,sha256=QhHLkq-ZtVzCIAsDARWz5WSyoZpBaRq7vXC4EVylDNY,484
|
|
2
|
+
eveonline/auth.py,sha256=V5QvdKKGAa3N5Kf8NCttmoQfkTK6420eaODWnyECuOM,2101
|
|
3
|
+
eveonline/client.py,sha256=TCTV450v3At1Cv81xml3thiFrfwblDp5JWX8d9WdeU0,13197
|
|
4
|
+
eveonline/const.py,sha256=tdAADyKQlE1c8JFx0zf5-ZvBslC39NZeNICd7lU_uM8,1251
|
|
5
|
+
eveonline/exceptions.py,sha256=DO0V9yXDJbpZ8VfPQpRnUfmNpzetkWcKm1NVVLw2Sik,917
|
|
6
|
+
eveonline/models.py,sha256=uJrQW_DWOx3vOFE_5ZE_ED-_hC8i6wKKpbsjOLnwfDc,2601
|
|
7
|
+
eveonline/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
python_eveonline-0.1.0.dist-info/licenses/LICENSE,sha256=8548Af-pnudPfoAyQ7EPBO5cIbk1zQmioaQTeDBLVfA,1076
|
|
9
|
+
python_eveonline-0.1.0.dist-info/METADATA,sha256=EH2u8SwcSQu-vzn1BsY1ZP_EcYfuRQix2L6F0_URxHI,2151
|
|
10
|
+
python_eveonline-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
11
|
+
python_eveonline-0.1.0.dist-info/top_level.txt,sha256=hcD2sMNAD8NE5-bKaUdG9-iwqzKKtqWJcoxeSVOU85M,10
|
|
12
|
+
python_eveonline-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ronald van der Meer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
eveonline
|