Skip to content

Commit 402f199

Browse files
committed
MOD: Rename API version to v0
- Define `API_VERSION` constant for Python client library
1 parent 6dc0c69 commit 402f199

File tree

11 files changed

+88
-37
lines changed

11 files changed

+88
-37
lines changed

databento/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Optional
22

33
from databento.common.bento import Bento, FileBento, MemoryBento
4+
from databento.historical.api import API_VERSION
45
from databento.historical.client import Historical
56

67

@@ -9,8 +10,8 @@
910
"FileBento",
1011
"MemoryBento",
1112
"Historical",
13+
"API_VERSION",
1214
]
1315

14-
1516
# Set to either 'DEBUG' or 'INFO', controls console logging
1617
log: Optional[str] = None
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
API_VERSION = 0

databento/historical/api/batch.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
)
1515
from databento.common.parsing import maybe_datetime_to_string
1616
from databento.common.validation import validate_enum
17+
from databento.historical.api import API_VERSION
1718
from databento.historical.http import BentoHttpAPI
1819

1920

@@ -24,7 +25,7 @@ class BatchHttpAPI(BentoHttpAPI):
2425

2526
def __init__(self, key, gateway):
2627
super().__init__(key=key, gateway=gateway)
27-
self._base_url = gateway + "/v1/batch"
28+
self._base_url = gateway + f"/v{API_VERSION}/batch"
2829

2930
def timeseries_submit(
3031
self,
@@ -46,7 +47,7 @@ def timeseries_submit(
4647
"""
4748
Submit a timeseries batch data job to the Databento backend.
4849
49-
`POST /v1/batch.timeseries_submit` HTTP API endpoint.
50+
`POST /v0/batch.timeseries_submit` HTTP API endpoint.
5051
5152
Parameters
5253
----------
@@ -142,7 +143,7 @@ def list_jobs(
142143
Request all batch data jobs associated with the client access key with
143144
the optional query filters.
144145
145-
`GET /v1/batch.list_jobs` HTTP API endpoint.
146+
`GET /v0/batch.list_jobs` HTTP API endpoint.
146147
147148
Parameters
148149
----------

databento/historical/api/metadata.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
maybe_symbols_list_to_string,
1111
)
1212
from databento.common.validation import validate_enum, validate_maybe_enum
13+
from databento.historical.api import API_VERSION
1314
from databento.historical.http import BentoHttpAPI
1415
from requests import Response
1516

@@ -21,7 +22,7 @@ class MetadataHttpAPI(BentoHttpAPI):
2122

2223
def __init__(self, key, gateway):
2324
super().__init__(key=key, gateway=gateway)
24-
self._base_url = gateway + "/v1/metadata"
25+
self._base_url = gateway + f"/v{API_VERSION}/metadata"
2526

2627
def list_datasets(
2728
self,
@@ -31,7 +32,7 @@ def list_datasets(
3132
"""
3233
Request the available datasets from the API server.
3334
34-
`GET /v1/metadata.list_datasets` HTTP API endpoint.
35+
`GET /v0/metadata.list_datasets` HTTP API endpoint.
3536
3637
Parameters
3738
----------
@@ -71,7 +72,7 @@ def list_schemas(
7172
"""
7273
Request the available record schemas from the API server.
7374
74-
`GET /v1/metadata.list_schemas` HTTP API endpoint.
75+
`GET /v0/metadata.list_schemas` HTTP API endpoint.
7576
7677
Parameters
7778
----------
@@ -115,7 +116,7 @@ def list_fields(
115116
"""
116117
Request the data record fields from the API server.
117118
118-
`GET /v1/metadata.list_fields` HTTP API endpoint.
119+
`GET /v0/metadata.list_fields` HTTP API endpoint.
119120
120121
Parameters
121122
----------
@@ -156,7 +157,7 @@ def list_encodings(self) -> List[str]:
156157
"""
157158
Request the available encoding options from the API server.
158159
159-
`GET /v1/metadata.list_encodings` HTTP API endpoint.
160+
`GET /v0/metadata.list_encodings` HTTP API endpoint.
160161
161162
Returns
162163
-------
@@ -173,7 +174,7 @@ def list_compressions(self) -> List[str]:
173174
"""
174175
Request the available compression options from the API server.
175176
176-
`GET /v1/metadata.list_compressions` HTTP API endpoint.
177+
`GET /v0/metadata.list_compressions` HTTP API endpoint.
177178
178179
Returns
179180
-------
@@ -195,7 +196,7 @@ def list_unit_prices(
195196
"""
196197
Request the data prices per unit GB from the API server.
197198
198-
`GET /v1/metadata.list_unit_prices` HTTP API endpoint.
199+
`GET /v0/metadata.list_unit_prices` HTTP API endpoint.
199200
200201
Parameters
201202
----------
@@ -246,7 +247,7 @@ def get_shape(
246247
"""
247248
Request the shape of the timeseries data as a rows and columns tuple.
248249
249-
GET `/v1/metadata.get_shape` HTTP API endpoint.
250+
GET `/v0/metadata.get_shape` HTTP API endpoint.
250251
251252
Parameters
252253
----------
@@ -320,7 +321,7 @@ def get_billable_size(
320321
"""
321322
Request the uncompressed binary size of the data stream (used for billing).
322323
323-
GET `/v1/metadata.get_billable_size` HTTP API endpoint.
324+
GET `/v0/metadata.get_billable_size` HTTP API endpoint.
324325
325326
Parameters
326327
----------
@@ -385,7 +386,7 @@ def get_cost(
385386
"""
386387
Request the expected total cost of the data stream.
387388
388-
`GET /v1/metadata.get_cost` HTTP API endpoint.
389+
`GET /v0/metadata.get_cost` HTTP API endpoint.
389390
390391
Parameters
391392
----------

databento/historical/api/symbology.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pandas as pd
55
from databento.common.enums import SType
66
from databento.common.parsing import enum_or_str_lowercase, maybe_symbols_list_to_string
7+
from databento.historical.api import API_VERSION
78
from databento.historical.http import BentoHttpAPI
89
from requests import Response
910

@@ -15,7 +16,7 @@ class SymbologyHttpAPI(BentoHttpAPI):
1516

1617
def __init__(self, key, gateway):
1718
super().__init__(key=key, gateway=gateway)
18-
self._base_url = gateway + "/v1/symbology"
19+
self._base_url = gateway + f"/v{API_VERSION}/symbology"
1920

2021
def resolve(
2122
self,
@@ -30,7 +31,7 @@ def resolve(
3031
"""
3132
Request symbology resolution.
3233
33-
`GET /v1/symbology.resolve` HTTP API endpoint.
34+
`GET /v0/symbology.resolve` HTTP API endpoint.
3435
3536
Parameters
3637
----------

databento/historical/api/timeseries.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from databento.common.enums import Compression, Dataset, Encoding, Schema, SType
88
from databento.common.logging import log_debug
99
from databento.common.validation import validate_enum
10+
from databento.historical.api import API_VERSION
1011
from databento.historical.http import BentoHttpAPI
1112
from requests import Response
1213

@@ -21,7 +22,7 @@ class TimeSeriesHttpAPI(BentoHttpAPI):
2122

2223
def __init__(self, key, gateway):
2324
super().__init__(key=key, gateway=gateway)
24-
self._base_url = gateway + "/v1/timeseries"
25+
self._base_url = gateway + f"/v{API_VERSION}/timeseries"
2526

2627
def stream(
2728
self,
@@ -38,7 +39,7 @@ def stream(
3839
"""
3940
Request a historical time series stream from the Databento API servers.
4041
41-
`GET /v1/timeseries.stream` HTTP API endpoint.
42+
`GET /v0/timeseries.stream` HTTP API endpoint.
4243
4344
Parameters
4445
----------
@@ -131,7 +132,7 @@ async def stream_async(
131132
Request a historical time series stream from the Databento API servers
132133
asynchronously.
133134
134-
`GET /v1/timeseries.stream` HTTP API endpoint.
135+
`GET /v0/timeseries.stream` HTTP API endpoint.
135136
136137
Parameters
137138
----------
@@ -233,7 +234,7 @@ def _pre_check_data_size(
233234
"request...",
234235
)
235236
response: Response = self._get(
236-
url=self._gateway + "/v1/metadata.get_size_estimation",
237+
url=self._gateway + "/v0/metadata.get_size_estimation",
237238
params=params,
238239
basic_auth=True,
239240
)

databento/historical/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def request_symbology(self, data: Bento) -> Dict[str, Dict[str, Any]]:
8585
"""
8686
Request symbology resolution based on the metadata properties.
8787
88-
`GET /v1/symbology.resolve` HTTP API endpoint.
88+
`GET /v0/symbology.resolve` HTTP API endpoint.
8989
9090
Current symbology mappings from the metadata are also available by
9191
calling the `.symbology` or `.mappings` properties.
@@ -118,7 +118,7 @@ def request_full_definitions(
118118
"""
119119
Request full instrument definitions based on the metadata properties.
120120
121-
`GET /v1/timeseries.stream` HTTP API endpoint.
121+
`GET /v0/timeseries.stream` HTTP API endpoint.
122122
123123
Parameters
124124
----------

tests/test_historical_batch.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ def test_batch_timeseries_submit_sends_expected_request(self, mocker) -> None:
7070

7171
# Assert
7272
call = mocked_get.call_args.kwargs
73-
assert call["url"] == "https://hist.databento.com/v1/batch.timeseries_submit"
73+
assert (
74+
call["url"]
75+
== f"https://hist.databento.com/v{db.API_VERSION}/batch.timeseries_submit"
76+
)
7477
assert call["headers"] == {"accept": "application/json"}
7578
assert call["params"] == [
7679
("dataset", "glbx.mdp3"),
@@ -100,7 +103,10 @@ def test_batch_list_jobs_sends_expected_request(self, mocker) -> None:
100103

101104
# Assert
102105
call = mocked_get.call_args.kwargs
103-
assert call["url"] == "https://hist.databento.com/v1/batch.list_jobs"
106+
assert (
107+
call["url"]
108+
== f"https://hist.databento.com/v{db.API_VERSION}/batch.list_jobs"
109+
)
104110
assert call["headers"] == {"accept": "application/json"}
105111
assert call["params"] == [
106112
("states", "queued,processing,done"),

tests/test_historical_client.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ def test_re_request_symbology_makes_expected_request(self, mocker) -> None:
7171

7272
# Assert
7373
call = mocked_get.call_args.kwargs
74-
assert call["url"] == "https://hist.databento.com/v1/symbology.resolve"
74+
assert (
75+
call["url"]
76+
== f"https://hist.databento.com/v{db.API_VERSION}/symbology.resolve"
77+
)
7578
assert call["params"] == [
7679
("dataset", "glbx.mdp3"),
7780
("symbols", "ESH1"),
@@ -100,7 +103,10 @@ def test_request_full_definitions_expected_request(self, mocker) -> None:
100103

101104
# Assert
102105
call = mocked_get.call_args.kwargs
103-
assert call["url"] == "https://hist.databento.com/v1/timeseries.stream"
106+
assert (
107+
call["url"]
108+
== f"https://hist.databento.com/v{db.API_VERSION}/timeseries.stream"
109+
)
104110
assert call["params"] == [
105111
("dataset", "glbx.mdp3"),
106112
("symbols", "ESH1"),

tests/test_historical_metadata.py

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ def test_list_datasets_sends_expected_request(self, mocker) -> None:
2121

2222
# Assert
2323
call = mocked_get.call_args.kwargs
24-
assert call["url"] == "https://hist.databento.com/v1/metadata.list_datasets"
24+
assert (
25+
call["url"]
26+
== f"https://hist.databento.com/v{db.API_VERSION}/metadata.list_datasets"
27+
)
2528
assert ("start", "2018-01-01T00:00:00") in call["params"]
2629
assert ("end", "2020-01-01T00:00:00") in call["params"]
2730
assert call["headers"] == {"accept": "application/json"}
@@ -42,7 +45,10 @@ def test_list_schemas_sends_expected_request(self, mocker) -> None:
4245

4346
# Assert
4447
call = mocked_get.call_args.kwargs
45-
assert call["url"] == "https://hist.databento.com/v1/metadata.list_schemas"
48+
assert (
49+
call["url"]
50+
== f"https://hist.databento.com/v{db.API_VERSION}/metadata.list_schemas"
51+
)
4652
assert ("start", "2018-01-01T00:00:00") in call["params"]
4753
assert ("end", "2021-01-01T00:00:00") in call["params"]
4854
assert call["headers"] == {"accept": "application/json"}
@@ -63,7 +69,10 @@ def test_list_fields_sends_expected_request(self, mocker) -> None:
6369

6470
# Assert
6571
call = mocked_get.call_args.kwargs
66-
assert call["url"] == "https://hist.databento.com/v1/metadata.list_fields"
72+
assert (
73+
call["url"]
74+
== f"https://hist.databento.com/v{db.API_VERSION}/metadata.list_fields"
75+
)
6776
assert ("schema", "mbo") in call["params"]
6877
assert ("encoding", "dbz") in call["params"]
6978
assert call["headers"] == {"accept": "application/json"}
@@ -80,7 +89,10 @@ def test_list_encodings_sends_expected_request(self, mocker) -> None:
8089

8190
# Assert
8291
call = mocked_get.call_args.kwargs
83-
assert call["url"] == "https://hist.databento.com/v1/metadata.list_encodings"
92+
assert (
93+
call["url"]
94+
== f"https://hist.databento.com/v{db.API_VERSION}/metadata.list_encodings"
95+
)
8496
assert call["headers"] == {"accept": "application/json"}
8597
assert call["timeout"] == (100, 100)
8698
assert isinstance(call["auth"], requests.auth.HTTPBasicAuth)
@@ -95,7 +107,10 @@ def test_list_compressions_sends_expected_request(self, mocker) -> None:
95107

96108
# Assert
97109
call = mocked_get.call_args.kwargs
98-
assert call["url"] == "https://hist.databento.com/v1/metadata.list_compressions"
110+
assert (
111+
call["url"]
112+
== f"https://hist.databento.com/v{db.API_VERSION}/metadata.list_compressions" # noqa
113+
)
99114
assert call["headers"] == {"accept": "application/json"}
100115
assert call["timeout"] == (100, 100)
101116
assert isinstance(call["auth"], requests.auth.HTTPBasicAuth)
@@ -123,7 +138,10 @@ def test_list_unit_price_sends_expected_request(
123138

124139
# Assert
125140
call = mocked_get.call_args.kwargs
126-
assert call["url"] == "https://hist.databento.com/v1/metadata.list_unit_prices"
141+
assert (
142+
call["url"]
143+
== f"https://hist.databento.com/v{db.API_VERSION}/metadata.list_unit_prices"
144+
)
127145
assert call["headers"] == {"accept": "application/json"}
128146
assert call["params"] == [
129147
("dataset", "glbx.mdp3"),
@@ -150,7 +168,10 @@ def test_get_shape_sends_expected_request(self, mocker) -> None:
150168

151169
# Assert
152170
call = mocked_get.call_args.kwargs
153-
assert call["url"] == "https://hist.databento.com/v1/metadata.get_shape"
171+
assert (
172+
call["url"]
173+
== f"https://hist.databento.com/v{db.API_VERSION}/metadata.get_shape"
174+
)
154175
assert call["headers"] == {"accept": "application/json"}
155176
assert call["params"] == [
156177
("dataset", "glbx.mdp3"),
@@ -182,7 +203,10 @@ def test_get_billable_size_sends_expected_request(self, mocker) -> None:
182203

183204
# Assert
184205
call = mocked_get.call_args.kwargs
185-
assert call["url"] == "https://hist.databento.com/v1/metadata.get_billable_size"
206+
assert (
207+
call["url"]
208+
== f"https://hist.databento.com/v{db.API_VERSION}/metadata.get_billable_size" # noqa
209+
)
186210
assert call["headers"] == {"accept": "application/json"}
187211
assert call["params"] == [
188212
("dataset", "glbx.mdp3"),
@@ -214,7 +238,10 @@ def test_cost_sends_expected_request(self, mocker) -> None:
214238

215239
# Assert
216240
call = mocked_get.call_args.kwargs
217-
assert call["url"] == "https://hist.databento.com/v1/metadata.get_cost"
241+
assert (
242+
call["url"]
243+
== f"https://hist.databento.com/v{db.API_VERSION}/metadata.get_cost"
244+
)
218245
assert call["headers"] == {"accept": "application/json"}
219246
assert call["params"] == [
220247
("dataset", "glbx.mdp3"),

0 commit comments

Comments
 (0)