narwhalapi 0.2.0__tar.gz → 0.3.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.
Files changed (25) hide show
  1. narwhalapi-0.3.0/CHANGELOG.md +49 -0
  2. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/PKG-INFO +1 -1
  3. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/pyproject.toml +1 -1
  4. narwhalapi-0.3.0/src/narwhalapi/_generated/__init__.py +3 -0
  5. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/src/narwhalapi/_generated/models.py +250 -2
  6. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/src/narwhalapi/_generated/operations.py +561 -11
  7. narwhalapi-0.3.0/src/narwhalapi/_version.py +1 -0
  8. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/src/narwhalapi/codes.py +9 -0
  9. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/src/narwhalapi/models.py +22 -2
  10. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/src/narwhalapi/webhooks.py +3 -3
  11. narwhalapi-0.2.0/CHANGELOG.md +0 -24
  12. narwhalapi-0.2.0/src/narwhalapi/_generated/__init__.py +0 -3
  13. narwhalapi-0.2.0/src/narwhalapi/_version.py +0 -1
  14. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/LICENSE +0 -0
  15. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/README.md +0 -0
  16. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/hatch_build.py +0 -0
  17. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/src/narwhalapi/__init__.py +0 -0
  18. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/src/narwhalapi/_client.py +0 -0
  19. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/src/narwhalapi/_deadline.py +0 -0
  20. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/src/narwhalapi/_decode.py +0 -0
  21. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/src/narwhalapi/_meta.py +0 -0
  22. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/src/narwhalapi/_pagination.py +0 -0
  23. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/src/narwhalapi/_transport.py +0 -0
  24. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/src/narwhalapi/errors.py +0 -0
  25. {narwhalapi-0.2.0 → narwhalapi-0.3.0}/src/narwhalapi/py.typed +0 -0
@@ -0,0 +1,49 @@
1
+ # Changelog
2
+
3
+ ## 0.3.0 — 2026-10-18
4
+
5
+ - Breaking: `webhooks.verify` now returns a `WebhookEvent`, read from the delivery bodies the
6
+ API documents. 0.2.0 read deliveries as the REST `DeliveryEvent`, which needs an `event_type`
7
+ field that webhook bodies never carry, so it rejected real deliveries with `invalid_body`.
8
+ `WebhookEvent` reads economics, release calendar and holiday events, prediction events
9
+ (`prediction`, with the event status and venue settlements) and test deliveries (`is_test`,
10
+ no `cursor`). Unknown event types still decode, with the type kept as a string.
11
+ - `economics.read_series_observations(series_id, ...)` reads the observations of one economic
12
+ series by its id, with a page iterator (`read_series_observations_iter`).
13
+ - Prediction history (`binary_history`, `scalar_history`, `extreme_history`, `timing_history`)
14
+ now comes in pages of about 5,000 bars with a `next_cursor`. Pass `cursor`, or use the new
15
+ `…_iter` iterators, to read a whole window; each page repeats the series keys with the next
16
+ slice of bars. The API pages these responses for every version, so 0.2.0 sees only the first
17
+ page of a wide window.
18
+ - Webhook destinations carry `disabled_reason`: `customer` (switched off by the account),
19
+ `plan_limit` (paused because the plan no longer includes it) or none.
20
+ - New code constants for the documented errors: `SNAPSHOT_UNAVAILABLE`, `REQUEST_TOO_LARGE`,
21
+ `RIGHTS_STATE_CHANGING`, `COMMAND_UNAVAILABLE`, `PHYSICAL_SERIES_NOT_FOUND`,
22
+ `PHYSICAL_REFERENCE_UNAVAILABLE`, `EVENT_NOT_FOUND`, `PREDICTIONS_UNAVAILABLE` and
23
+ `LIMIT_REACHED`.
24
+ - No change on the wire: the contract now names the palm oil price unions and the shared
25
+ problem response, and documents `400` instead of `422` for webhook and calendar subscription
26
+ validation errors, which is what the API always returned.
27
+
28
+ ## 0.2.0 — 2026-10-12
29
+
30
+ - Breaking: economic calendar releases now carry Narwhal's English `name`, a permanent
31
+ `series_id`, a `topic` and a `stage` beside the publisher's `title`, and each schedule
32
+ carries its `local_date`. The API lists releases compactly by default; the SDK always asks
33
+ for the full release (`view=full`), so every field stays typed. Research articles are no
34
+ longer listed.
35
+ - `CALENDAR_NOT_PUBLISHED` for the 404 returned when a holiday calendar year is not published.
36
+ - FX bars publish their five fields again in the contract (no wire change).
37
+
38
+ ## 0.1.0 — 2026-10-09
39
+
40
+ - Initial typed synchronous and asynchronous clients for the stable API: economics,
41
+ FX, calendars, physical palm oil, spot prices (`commodities.spot_price`), events,
42
+ webhook destinations and calendar subscriptions.
43
+ - `nw.unstable` holds operations not yet in the live API; it is empty in this release.
44
+ - Exact decimals, typed errors, bounded retries, page iterators, response metadata,
45
+ and local webhook signature verification.
46
+ - `codes.PLAN_UPGRADE_REQUIRED` for the 403 returned when a request reaches before the
47
+ plan's history window.
48
+ - The release also covers prediction market reads, FX and commodity bar history, and physical commodity reference price series.
49
+ - Spot `bid` and `ask` are optional because the API may omit them.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: narwhalapi
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Typed clients for the Narwhal API
5
5
  Project-URL: Homepage, https://narwhalapi.com
6
6
  Author-email: Narwhal API Team <support@narwhalapi.com>
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "narwhalapi"
7
- version = "0.2.0"
7
+ version = "0.3.0"
8
8
  description = "Typed clients for the Narwhal API"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -0,0 +1,3 @@
1
+ # Generated from spec/live/openapi.json sha256 a8f87a3ac708cc35c7a08fa69c5bf4c3edeea4259ff31a8cc7a3f6ded6b553a8. Do not edit.
2
+ # Generated from spec/next/openapi.json sha256 a8f87a3ac708cc35c7a08fa69c5bf4c3edeea4259ff31a8cc7a3f6ded6b553a8. Do not edit.
3
+ """Generated contract surface."""
@@ -1,5 +1,5 @@
1
- # Generated from spec/live/openapi.json sha256 549d8458a8dcfbbccea3ea4b23f7d9163c6525ce932e4c5f6657fdd9b728985c. Do not edit.
2
- # Generated from spec/next/openapi.json sha256 549d8458a8dcfbbccea3ea4b23f7d9163c6525ce932e4c5f6657fdd9b728985c. Do not edit.
1
+ # Generated from spec/live/openapi.json sha256 a8f87a3ac708cc35c7a08fa69c5bf4c3edeea4259ff31a8cc7a3f6ded6b553a8. Do not edit.
2
+ # Generated from spec/next/openapi.json sha256 a8f87a3ac708cc35c7a08fa69c5bf4c3edeea4259ff31a8cc7a3f6ded6b553a8. Do not edit.
3
3
  from __future__ import annotations
4
4
 
5
5
  from dataclasses import dataclass, field
@@ -301,6 +301,14 @@ class PredictionShape:
301
301
  TIMING: Literal["timing"] = "timing"
302
302
 
303
303
 
304
+ class PredictionWebhookStatus:
305
+ """Known values; response fields also accept future strings."""
306
+
307
+ CLOSED: Literal["closed"] = "closed"
308
+ SETTLED: Literal["settled"] = "settled"
309
+ VOID: Literal["void"] = "void"
310
+
311
+
304
312
  class ProducerArrangement:
305
313
  """Known values; response fields also accept future strings."""
306
314
 
@@ -388,6 +396,32 @@ class ResolutionKind:
388
396
  RELEASE: Literal["release"] = "release"
389
397
 
390
398
 
399
+ class ResourceObservationStatus:
400
+ """Known values; response fields also accept future strings."""
401
+
402
+ BREAK_IN_SERIES: Literal["break_in_series"] = "break_in_series"
403
+ BREAK_IN_SERIES_AND_DEFINITION_DIFFERS: Literal[
404
+ "break_in_series_and_definition_differs"
405
+ ] = "break_in_series_and_definition_differs"
406
+ DEFINITION_DIFFERS: Literal["definition_differs"] = "definition_differs"
407
+ ESTIMATED: Literal["estimated"] = "estimated"
408
+ PROVISIONAL: Literal["provisional"] = "provisional"
409
+
410
+
411
+ class ResourceUnit:
412
+ """Known values; response fields also accept future strings."""
413
+
414
+ CURRENCY: Literal["currency"] = "currency"
415
+ CURRENCY_PER_HOUR: Literal["currency_per_hour"] = "currency_per_hour"
416
+ CURRENCY_PER_MONTH: Literal["currency_per_month"] = "currency_per_month"
417
+ CURRENCY_PER_WEEK: Literal["currency_per_week"] = "currency_per_week"
418
+ CURRENCY_PER_YEAR: Literal["currency_per_year"] = "currency_per_year"
419
+ INDEX: Literal["index"] = "index"
420
+ JOB: Literal["job"] = "job"
421
+ PERCENT: Literal["percent"] = "percent"
422
+ PERSON: Literal["person"] = "person"
423
+
424
+
391
425
  class SchedulePrecision:
392
426
  """Known values; response fields also accept future strings."""
393
427
 
@@ -503,6 +537,36 @@ class WebhookDeliveryState:
503
537
  SUCCEEDED: Literal["succeeded"] = "succeeded"
504
538
 
505
539
 
540
+ class WebhookDisabledReason:
541
+ """Known values; response fields also accept future strings."""
542
+
543
+ CUSTOMER: Literal["customer"] = "customer"
544
+ PLAN_LIMIT: Literal["plan_limit"] = "plan_limit"
545
+
546
+
547
+ class WebhookEventType:
548
+ """Known values; response fields also accept future strings."""
549
+
550
+ DATASET_PUBLISHED: Literal["dataset.published"] = "dataset.published"
551
+ DATASET_REVISED: Literal["dataset.revised"] = "dataset.revised"
552
+ HOLIDAY_CALENDAR_REVISED: Literal["holiday.calendar.revised"] = (
553
+ "holiday.calendar.revised"
554
+ )
555
+ PREDICTION_EVENT_CLOSED: Literal["prediction.event.closed"] = (
556
+ "prediction.event.closed"
557
+ )
558
+ PREDICTION_EVENT_SETTLED: Literal["prediction.event.settled"] = (
559
+ "prediction.event.settled"
560
+ )
561
+ RELEASE_CANCELLED: Literal["release.cancelled"] = "release.cancelled"
562
+ RELEASE_RESCHEDULED: Literal["release.rescheduled"] = "release.rescheduled"
563
+ RELEASE_SCHEDULED: Literal["release.scheduled"] = "release.scheduled"
564
+ RELEASE_UPDATED: Literal["release.updated"] = "release.updated"
565
+ WEBHOOK_TEST: Literal["webhook.test"] = "webhook.test"
566
+ YIELD_CURVE_PUBLISHED: Literal["yield_curve.published"] = "yield_curve.published"
567
+ YIELD_CURVE_REVISED: Literal["yield_curve.revised"] = "yield_curve.revised"
568
+
569
+
506
570
  class WebhookFamily:
507
571
  """Known values; response fields also accept future strings."""
508
572
 
@@ -1303,6 +1367,7 @@ class PredictionHistory:
1303
1367
  end: str
1304
1368
  event_id: str
1305
1369
  interval: str
1370
+ next_cursor: str | None = None
1306
1371
  series: list[PredictionSeries]
1307
1372
  shape: str
1308
1373
  start: str
@@ -1383,6 +1448,24 @@ class PredictionVenue:
1383
1448
  weight: str | None = None
1384
1449
 
1385
1450
 
1451
+ @dataclass(frozen=True, slots=True, kw_only=True)
1452
+ class PredictionWebhookEvent:
1453
+ closes_at: str | None = None
1454
+ event_id: str
1455
+ release_id: str | None = None
1456
+ resolves_at: str | None = None
1457
+ settlements: list[PredictionWebhookSettlement]
1458
+ shape: str
1459
+ status: str
1460
+ topic_id: str
1461
+
1462
+
1463
+ @dataclass(frozen=True, slots=True, kw_only=True)
1464
+ class PredictionWebhookSettlement:
1465
+ status: str
1466
+ venue: str
1467
+
1468
+
1386
1469
  @dataclass(frozen=True, slots=True, kw_only=True)
1387
1470
  class Problem:
1388
1471
  code: str
@@ -1403,6 +1486,26 @@ class Quote:
1403
1486
  venue: str
1404
1487
 
1405
1488
 
1489
+ @dataclass(frozen=True, slots=True, kw_only=True)
1490
+ class ResourceHistory:
1491
+ country: str
1492
+ currency: str | None = None
1493
+ next_cursor: str | None = None
1494
+ observations: list[ResourceObservation]
1495
+ series_id: str
1496
+ source: SeriesSource | None = None
1497
+ unit: str
1498
+ meta: ResponseMeta = field(default_factory=ResponseMeta, compare=False)
1499
+
1500
+
1501
+ @dataclass(frozen=True, slots=True, kw_only=True)
1502
+ class ResourceObservation:
1503
+ period: str
1504
+ released_on: str | None = None
1505
+ status: str | None = None
1506
+ value: Decimal
1507
+
1508
+
1406
1509
  @dataclass(frozen=True, slots=True, kw_only=True)
1407
1510
  class ScalarBody:
1408
1511
  outcomes: list[ScalarOutcome]
@@ -1626,6 +1729,7 @@ class WebhookDestinationCreated:
1626
1729
  countries: list[str]
1627
1730
  created_at: str
1628
1731
  destination_id: str
1732
+ disabled_reason: str | None = None
1629
1733
  enabled: bool
1630
1734
  families: list[str]
1631
1735
  secret: str
@@ -1656,6 +1760,7 @@ class WebhookDestinationResponse:
1656
1760
  countries: list[str]
1657
1761
  created_at: str
1658
1762
  destination_id: str
1763
+ disabled_reason: str | None = None
1659
1764
  enabled: bool
1660
1765
  families: list[str]
1661
1766
  secret_version: int
@@ -1664,6 +1769,26 @@ class WebhookDestinationResponse:
1664
1769
  meta: ResponseMeta = field(default_factory=ResponseMeta, compare=False)
1665
1770
 
1666
1771
 
1772
+ @dataclass(frozen=True, slots=True, kw_only=True)
1773
+ class WebhookEvent:
1774
+ country: str | None = None
1775
+ cursor: str | None = None
1776
+ event_id: str
1777
+ family: str | None = None
1778
+ holiday_country: str | None = None
1779
+ holiday_generation: int | None = None
1780
+ holiday_year: int | None = None
1781
+ is_test: bool | None = None
1782
+ prediction: PredictionWebhookEvent | None = None
1783
+ publication_id: str | None = None
1784
+ recorded_at: str
1785
+ release_id: str | None = None
1786
+ resource_id: str | None = None
1787
+ resource_version: str | None = None
1788
+ schema_version: str
1789
+ type: str
1790
+
1791
+
1667
1792
  @dataclass(frozen=True, slots=True, kw_only=True)
1668
1793
  class WebhookHistoryResponse:
1669
1794
  history: list[WebhookConfigurationHistory]
@@ -3019,6 +3144,9 @@ def decode_PredictionHistory(
3019
3144
  end=read_str(data["end"]),
3020
3145
  event_id=read_str(data["event_id"]),
3021
3146
  interval=read_str(data["interval"]),
3147
+ next_cursor=read_cursor(data["next_cursor"])
3148
+ if data.get("next_cursor") is not None
3149
+ else None,
3022
3150
  series=[decode_PredictionSeries(item0) for item0 in read_list(data["series"])],
3023
3151
  shape=read_str(data["shape"]),
3024
3152
  start=read_str(data["start"]),
@@ -3158,6 +3286,41 @@ def decode_PredictionVenue(
3158
3286
  )
3159
3287
 
3160
3288
 
3289
+ def decode_PredictionWebhookEvent(
3290
+ value: object, meta: ResponseMeta | None = None, raw_body: bytes = b""
3291
+ ) -> PredictionWebhookEvent:
3292
+ data = read_object(value)
3293
+ return PredictionWebhookEvent(
3294
+ closes_at=read_str(data["closes_at"])
3295
+ if data.get("closes_at") is not None
3296
+ else None,
3297
+ event_id=read_str(data["event_id"]),
3298
+ release_id=read_str(data["release_id"])
3299
+ if data.get("release_id") is not None
3300
+ else None,
3301
+ resolves_at=read_str(data["resolves_at"])
3302
+ if data.get("resolves_at") is not None
3303
+ else None,
3304
+ settlements=[
3305
+ decode_PredictionWebhookSettlement(item0)
3306
+ for item0 in read_list(data["settlements"])
3307
+ ],
3308
+ shape=read_str(data["shape"]),
3309
+ status=read_str(data["status"]),
3310
+ topic_id=read_str(data["topic_id"]),
3311
+ )
3312
+
3313
+
3314
+ def decode_PredictionWebhookSettlement(
3315
+ value: object, meta: ResponseMeta | None = None, raw_body: bytes = b""
3316
+ ) -> PredictionWebhookSettlement:
3317
+ data = read_object(value)
3318
+ return PredictionWebhookSettlement(
3319
+ status=read_str(data["status"]),
3320
+ venue=read_str(data["venue"]),
3321
+ )
3322
+
3323
+
3161
3324
  def decode_Problem(
3162
3325
  value: object, meta: ResponseMeta | None = None, raw_body: bytes = b""
3163
3326
  ) -> Problem:
@@ -3188,6 +3351,45 @@ def decode_Quote(
3188
3351
  )
3189
3352
 
3190
3353
 
3354
+ def decode_ResourceHistory(
3355
+ value: object, meta: ResponseMeta | None = None, raw_body: bytes = b""
3356
+ ) -> ResourceHistory:
3357
+ data = read_object(value)
3358
+ return ResourceHistory(
3359
+ country=read_str(data["country"]),
3360
+ currency=read_str(data["currency"])
3361
+ if data.get("currency") is not None
3362
+ else None,
3363
+ next_cursor=read_cursor(data["next_cursor"])
3364
+ if data.get("next_cursor") is not None
3365
+ else None,
3366
+ observations=[
3367
+ decode_ResourceObservation(item0)
3368
+ for item0 in read_list(data["observations"])
3369
+ ],
3370
+ series_id=read_str(data["series_id"]),
3371
+ source=decode_SeriesSource(data["source"])
3372
+ if data.get("source") is not None
3373
+ else None,
3374
+ unit=read_str(data["unit"]),
3375
+ meta=meta if meta is not None else ResponseMeta(),
3376
+ )
3377
+
3378
+
3379
+ def decode_ResourceObservation(
3380
+ value: object, meta: ResponseMeta | None = None, raw_body: bytes = b""
3381
+ ) -> ResourceObservation:
3382
+ data = read_object(value)
3383
+ return ResourceObservation(
3384
+ period=read_str(data["period"]),
3385
+ released_on=read_str(data["released_on"])
3386
+ if data.get("released_on") is not None
3387
+ else None,
3388
+ status=read_str(data["status"]) if data.get("status") is not None else None,
3389
+ value=read_decimal(data["value"]),
3390
+ )
3391
+
3392
+
3191
3393
  def decode_ScalarBody(
3192
3394
  value: object, meta: ResponseMeta | None = None, raw_body: bytes = b""
3193
3395
  ) -> ScalarBody:
@@ -3542,6 +3744,9 @@ def decode_WebhookDestinationCreated(
3542
3744
  countries=[read_str(item0) for item0 in read_list(data["countries"])],
3543
3745
  created_at=read_str(data["created_at"]),
3544
3746
  destination_id=read_str(data["destination_id"]),
3747
+ disabled_reason=read_str(data["disabled_reason"])
3748
+ if data.get("disabled_reason") is not None
3749
+ else None,
3545
3750
  enabled=read_bool(data["enabled"]),
3546
3751
  families=[read_str(item0) for item0 in read_list(data["families"])],
3547
3752
  secret=read_str(data["secret"]),
@@ -3587,6 +3792,9 @@ def decode_WebhookDestinationResponse(
3587
3792
  countries=[read_str(item0) for item0 in read_list(data["countries"])],
3588
3793
  created_at=read_str(data["created_at"]),
3589
3794
  destination_id=read_str(data["destination_id"]),
3795
+ disabled_reason=read_str(data["disabled_reason"])
3796
+ if data.get("disabled_reason") is not None
3797
+ else None,
3590
3798
  enabled=read_bool(data["enabled"]),
3591
3799
  families=[read_str(item0) for item0 in read_list(data["families"])],
3592
3800
  secret_version=read_int(data["secret_version"]),
@@ -3596,6 +3804,46 @@ def decode_WebhookDestinationResponse(
3596
3804
  )
3597
3805
 
3598
3806
 
3807
+ def decode_WebhookEvent(
3808
+ value: object, meta: ResponseMeta | None = None, raw_body: bytes = b""
3809
+ ) -> WebhookEvent:
3810
+ data = read_object(value)
3811
+ return WebhookEvent(
3812
+ country=read_str(data["country"]) if data.get("country") is not None else None,
3813
+ cursor=read_str(data["cursor"]) if data.get("cursor") is not None else None,
3814
+ event_id=read_str(data["event_id"]),
3815
+ family=read_str(data["family"]) if data.get("family") is not None else None,
3816
+ holiday_country=read_str(data["holiday_country"])
3817
+ if data.get("holiday_country") is not None
3818
+ else None,
3819
+ holiday_generation=read_int(data["holiday_generation"])
3820
+ if data.get("holiday_generation") is not None
3821
+ else None,
3822
+ holiday_year=read_int(data["holiday_year"])
3823
+ if data.get("holiday_year") is not None
3824
+ else None,
3825
+ is_test=read_bool(data["is_test"]) if data.get("is_test") is not None else None,
3826
+ prediction=decode_PredictionWebhookEvent(data["prediction"])
3827
+ if data.get("prediction") is not None
3828
+ else None,
3829
+ publication_id=read_str(data["publication_id"])
3830
+ if data.get("publication_id") is not None
3831
+ else None,
3832
+ recorded_at=read_str(data["recorded_at"]),
3833
+ release_id=read_str(data["release_id"])
3834
+ if data.get("release_id") is not None
3835
+ else None,
3836
+ resource_id=read_str(data["resource_id"])
3837
+ if data.get("resource_id") is not None
3838
+ else None,
3839
+ resource_version=read_str(data["resource_version"])
3840
+ if data.get("resource_version") is not None
3841
+ else None,
3842
+ schema_version=read_str(data["schema_version"]),
3843
+ type=read_str(data["type"]),
3844
+ )
3845
+
3846
+
3599
3847
  def decode_WebhookHistoryResponse(
3600
3848
  value: object, meta: ResponseMeta | None = None, raw_body: bytes = b""
3601
3849
  ) -> WebhookHistoryResponse: