vessel-api-python 2.0.0__py3-none-any.whl → 2.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.
@@ -45,6 +45,8 @@ from ._models import (
45
45
  PortReference,
46
46
  PortResponse,
47
47
  PortsWithinLocationResponse,
48
+ PositionCheck,
49
+ PreviousPosition,
48
50
  RadioBeacon,
49
51
  RadioBeaconsWithinLocationResponse,
50
52
  ResolutionMeta,
@@ -96,6 +98,8 @@ __all__ = [
96
98
  "VesselResponse",
97
99
  "VesselPosition",
98
100
  "VesselPositionResponse",
101
+ "PositionCheck",
102
+ "PreviousPosition",
99
103
  "VesselPositionsResponse",
100
104
  "MarineCasualty",
101
105
  "MarineCasualtiesResponse",
@@ -1,6 +1,6 @@
1
1
  """Constants for the Vessel API Python SDK."""
2
2
 
3
- VERSION = "2.0.0"
3
+ VERSION = "2.1.0"
4
4
  DEFAULT_BASE_URL = "https://api.vesselapi.com/v1"
5
5
  DEFAULT_USER_AGENT = f"vesselapi-python/{VERSION}"
6
6
  DEFAULT_MAX_RETRIES = 3
@@ -144,10 +144,40 @@ class VesselPosition(_Base):
144
144
  vessel_name: str | None = None
145
145
 
146
146
 
147
+ class PreviousPosition(_Base):
148
+ """The vessel's newest position report before the served one."""
149
+
150
+ latitude: float | None = None
151
+ longitude: float | None = None
152
+ timestamp: str | None = None
153
+
154
+
155
+ class PositionCheck(_Base):
156
+ """How the served position compares with the vessel's previous position report.
157
+
158
+ Only ``lookback_hours`` is present when no previous report falls within it.
159
+ """
160
+
161
+ previous_position: PreviousPosition | None = None
162
+ minutes_since_previous: int | None = None
163
+ distance_nm: float | None = None
164
+ implied_speed_kn: float | None = None
165
+ implied_course: int | None = None
166
+ exceeds_typical_speed: bool | None = None
167
+ identity_match: bool | None = None
168
+ lookback_hours: int | None = None
169
+
170
+
147
171
  class VesselPositionResponse(_Base):
148
- """Response for a single vessel position lookup."""
172
+ """Response for a single vessel position lookup.
173
+
174
+ ``vessel`` and ``vessel_eta`` are ``None`` when the API holds no record for them.
175
+ """
149
176
 
150
177
  vessel_position: VesselPosition | None = Field(default=None, alias="vesselPosition")
178
+ vessel: Vessel | None = None
179
+ vessel_eta: VesselETA | None = Field(default=None, alias="vesselEta")
180
+ position_check: PositionCheck | None = Field(default=None, alias="positionCheck")
151
181
  meta: ResolutionMeta | None = Field(default=None, alias="_meta")
152
182
 
153
183
 
@@ -94,15 +94,32 @@ class VesselsService:
94
94
  return VesselResponse.model_validate(r.json())
95
95
 
96
96
  def position(
97
- self, vessel_id: str, *, filter_id_type: str = "imo", filter_sat: bool | None = None
97
+ self,
98
+ vessel_id: str,
99
+ *,
100
+ filter_id_type: str = "imo",
101
+ filter_sat: bool | None = None,
102
+ filter_sat_lookback_minutes: int | None = None,
103
+ filter_sat_max_age_minutes: int | None = None,
98
104
  ) -> VesselPositionResponse:
99
105
  """Retrieve the latest position for a vessel.
100
106
 
101
107
  ``filter_sat`` enables satellite AIS fallback; the server defaults it to false.
108
+ With ``filter_sat=True``, ``filter_sat_lookback_minutes`` (60 to 4800, default 180)
109
+ sets how old a satellite fix may be and still be returned.
110
+ ``filter_sat_max_age_minutes`` (15 to 4800, default 60, paid plans only) sets how
111
+ old a stored position may be before a satellite lookup is made.
102
112
  """
103
113
  r = self._client.get(
104
114
  f"/vessel/{vessel_id}/position",
105
- params=_strip_none({"filter.idType": filter_id_type, "filter.sat": filter_sat}),
115
+ params=_strip_none(
116
+ {
117
+ "filter.idType": filter_id_type,
118
+ "filter.sat": filter_sat,
119
+ "filter.satLookbackMinutes": filter_sat_lookback_minutes,
120
+ "filter.satMaxAgeMinutes": filter_sat_max_age_minutes,
121
+ }
122
+ ),
106
123
  )
107
124
  error_from_response(r.status_code, r.content)
108
125
  return VesselPositionResponse.model_validate(r.json())
@@ -1561,15 +1578,32 @@ class AsyncVesselsService:
1561
1578
  return VesselResponse.model_validate(r.json())
1562
1579
 
1563
1580
  async def position(
1564
- self, vessel_id: str, *, filter_id_type: str = "imo", filter_sat: bool | None = None
1581
+ self,
1582
+ vessel_id: str,
1583
+ *,
1584
+ filter_id_type: str = "imo",
1585
+ filter_sat: bool | None = None,
1586
+ filter_sat_lookback_minutes: int | None = None,
1587
+ filter_sat_max_age_minutes: int | None = None,
1565
1588
  ) -> VesselPositionResponse:
1566
1589
  """Retrieve the latest position for a vessel.
1567
1590
 
1568
1591
  ``filter_sat`` enables satellite AIS fallback; the server defaults it to false.
1592
+ With ``filter_sat=True``, ``filter_sat_lookback_minutes`` (60 to 4800, default 180)
1593
+ sets how old a satellite fix may be and still be returned.
1594
+ ``filter_sat_max_age_minutes`` (15 to 4800, default 60, paid plans only) sets how
1595
+ old a stored position may be before a satellite lookup is made.
1569
1596
  """
1570
1597
  r = await self._client.get(
1571
1598
  f"/vessel/{vessel_id}/position",
1572
- params=_strip_none({"filter.idType": filter_id_type, "filter.sat": filter_sat}),
1599
+ params=_strip_none(
1600
+ {
1601
+ "filter.idType": filter_id_type,
1602
+ "filter.sat": filter_sat,
1603
+ "filter.satLookbackMinutes": filter_sat_lookback_minutes,
1604
+ "filter.satMaxAgeMinutes": filter_sat_max_age_minutes,
1605
+ }
1606
+ ),
1573
1607
  )
1574
1608
  error_from_response(r.status_code, r.content)
1575
1609
  return VesselPositionResponse.model_validate(r.json())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: vessel-api-python
3
- Version: 2.0.0
3
+ Version: 2.1.0
4
4
  Summary: Python client for the Vessel Tracking API: maritime vessel tracking, port events, emissions, and nautical infrastructure.
5
5
  Project-URL: Documentation, https://vesselapi.com/docs
6
6
  Project-URL: Repository, https://github.com/vessel-api/vesselapi-python
@@ -131,11 +131,12 @@ print(f"{vessel.vessel.name} ({vessel.vessel.vessel_type})")
131
131
  pos = client.vessels.position("232003239", filter_id_type="mmsi")
132
132
  print(f"Position: {pos.vessel_position.latitude}, {pos.vessel_position.longitude}")
133
133
 
134
- # filter_sat=True falls back to satellite AIS when nothing is stored.
134
+ # filter_sat=True falls back to satellite AIS when no recent terrestrial position is stored.
135
135
  # ⚠️ Satellite lookups draw on a prepaid balance and are charged per call.
136
136
  # Omit it unless you need that fallback.
137
137
 
138
- # Find all vessels within 10 km of Rotterdam.
138
+ # Find vessels with an AIS position within 10 km of Rotterdam in the last 2 hours
139
+ # (the default time window, at most 4 hours).
139
140
  nearby = client.location.vessels_radius(latitude=51.9225, longitude=4.47917, radius=10000)
140
141
  for v in nearby.vessels or []:
141
142
  print(f"{v.vessel_name} at {v.latitude}, {v.longitude}")
@@ -0,0 +1,13 @@
1
+ vessel_api_python/__init__.py,sha256=hUlZdyZGgArdYr8XJ30yQibkXXkQPqx3Y9zmVKvi6fc,3200
2
+ vessel_api_python/_client.py,sha256=L7qkzUiATDpPlxWViEKicNpNx7D90gCohas56uCimgA,4919
3
+ vessel_api_python/_constants.py,sha256=rfYu8M4IeUngAqYB6h_N0iwrtVpBA5jDzcT46RjJu7Y,244
4
+ vessel_api_python/_errors.py,sha256=DaiyCjYKJZTo6-6sOqAcJBdOeFaIYgWHE48nsHWGeGA,6414
5
+ vessel_api_python/_iterator.py,sha256=SkgsGSdxLrKtw-ad8fSUPaEDDJCamAKK0PrG_P8HX-4,3198
6
+ vessel_api_python/_models.py,sha256=BizjprJtFxyl7064ovks81m31SFdgfxKi6fg3rXjatk,20773
7
+ vessel_api_python/_services.py,sha256=UOGpajcZAYrt03DfkG86nIR8zyCGwokq_qB4ZYit7BY,109699
8
+ vessel_api_python/_transport.py,sha256=pfRaJwkq_GYpA5Ev8wH7tBdlzN2ykgy29Ag1L3F5K4Y,6956
9
+ vessel_api_python/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ vessel_api_python-2.1.0.dist-info/METADATA,sha256=IGgln4OImtva-TRMJIcFqUgPLX8jQdwJYekDdtZ8HiM,10153
11
+ vessel_api_python-2.1.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
12
+ vessel_api_python-2.1.0.dist-info/licenses/LICENSE,sha256=zoj_abq99mj8cz-Bz71XCnwB-Qv3kU1VzVXeKEntuQU,1067
13
+ vessel_api_python-2.1.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.32.0
2
+ Generator: hatchling 1.32.4
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,13 +0,0 @@
1
- vessel_api_python/__init__.py,sha256=-c0Rq1t5pDN4OY1w_9uNNeHjUI__kovOiyWvvU319jo,3114
2
- vessel_api_python/_client.py,sha256=L7qkzUiATDpPlxWViEKicNpNx7D90gCohas56uCimgA,4919
3
- vessel_api_python/_constants.py,sha256=Im6d9J9HSo5D-Rt4SVIQ35lqqGXIovSxhGsBhNqTVdU,244
4
- vessel_api_python/_errors.py,sha256=DaiyCjYKJZTo6-6sOqAcJBdOeFaIYgWHE48nsHWGeGA,6414
5
- vessel_api_python/_iterator.py,sha256=SkgsGSdxLrKtw-ad8fSUPaEDDJCamAKK0PrG_P8HX-4,3198
6
- vessel_api_python/_models.py,sha256=rJnRaZZ9y-h3xYbn0e-7nRLm6Sr9bSkigLIC6jY_HW0,19739
7
- vessel_api_python/_services.py,sha256=8f6yxKHvzDuIbrQCpN01wT_g4OsByWGHOIhKgDGeaQg,108285
8
- vessel_api_python/_transport.py,sha256=pfRaJwkq_GYpA5Ev8wH7tBdlzN2ykgy29Ag1L3F5K4Y,6956
9
- vessel_api_python/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- vessel_api_python-2.0.0.dist-info/METADATA,sha256=1HWjKevhtZDfUq9F1k4DNZoGZvtfaWnzsJw5dnPOVA0,10048
11
- vessel_api_python-2.0.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
12
- vessel_api_python-2.0.0.dist-info/licenses/LICENSE,sha256=zoj_abq99mj8cz-Bz71XCnwB-Qv3kU1VzVXeKEntuQU,1067
13
- vessel_api_python-2.0.0.dist-info/RECORD,,