periplus-python-sdk 0.2.0__tar.gz → 0.4.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 (17) hide show
  1. periplus_python_sdk-0.4.0/LICENSE +202 -0
  2. periplus_python_sdk-0.4.0/NOTICE +2 -0
  3. {periplus_python_sdk-0.2.0 → periplus_python_sdk-0.4.0}/PKG-INFO +40 -10
  4. {periplus_python_sdk-0.2.0 → periplus_python_sdk-0.4.0}/README.md +35 -9
  5. {periplus_python_sdk-0.2.0 → periplus_python_sdk-0.4.0}/pyproject.toml +3 -1
  6. {periplus_python_sdk-0.2.0 → periplus_python_sdk-0.4.0}/src/periplus_python_sdk.egg-info/PKG-INFO +40 -10
  7. {periplus_python_sdk-0.2.0 → periplus_python_sdk-0.4.0}/src/periplus_python_sdk.egg-info/SOURCES.txt +2 -0
  8. {periplus_python_sdk-0.2.0 → periplus_python_sdk-0.4.0}/src/periplus_sdk/client.py +21 -15
  9. {periplus_python_sdk-0.2.0 → periplus_python_sdk-0.4.0}/src/periplus_sdk/types.py +6 -0
  10. {periplus_python_sdk-0.2.0 → periplus_python_sdk-0.4.0}/tests/test_client.py +33 -9
  11. {periplus_python_sdk-0.2.0 → periplus_python_sdk-0.4.0}/setup.cfg +0 -0
  12. {periplus_python_sdk-0.2.0 → periplus_python_sdk-0.4.0}/src/periplus_python_sdk.egg-info/dependency_links.txt +0 -0
  13. {periplus_python_sdk-0.2.0 → periplus_python_sdk-0.4.0}/src/periplus_python_sdk.egg-info/requires.txt +0 -0
  14. {periplus_python_sdk-0.2.0 → periplus_python_sdk-0.4.0}/src/periplus_python_sdk.egg-info/top_level.txt +0 -0
  15. {periplus_python_sdk-0.2.0 → periplus_python_sdk-0.4.0}/src/periplus_sdk/__init__.py +0 -0
  16. {periplus_python_sdk-0.2.0 → periplus_python_sdk-0.4.0}/src/periplus_sdk/errors.py +0 -0
  17. {periplus_python_sdk-0.2.0 → periplus_python_sdk-0.4.0}/src/periplus_sdk/py.typed +0 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ Periplus
2
+ Copyright (c) 2026 Ekku Leivonen (elei.io)
@@ -1,13 +1,17 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: periplus-python-sdk
3
- Version: 0.2.0
3
+ Version: 0.4.0
4
4
  Summary: Read-only Python client for the public Periplus query API
5
+ License-Expression: Apache-2.0
5
6
  Project-URL: Repository, https://github.com/elei-io/periplus
6
7
  Project-URL: Issues, https://github.com/elei-io/periplus/issues
7
8
  Requires-Python: >=3.11
8
9
  Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ License-File: NOTICE
9
12
  Requires-Dist: httpx>=0.28
10
13
  Requires-Dist: pydantic<3,>=2.12
14
+ Dynamic: license-file
11
15
 
12
16
  # Periplus Python SDK
13
17
 
@@ -20,7 +24,7 @@ from periplus_sdk import Client
20
24
 
21
25
  with Client("http://localhost:8080") as client:
22
26
  result = client.execute(
23
- "SELECT observation_id FROM web.observation LIMIT ?", [10]
27
+ "SELECT capture_id FROM public_v1.capture LIMIT ?", [10]
24
28
  )
25
29
  print(result.columns, result.types)
26
30
  print(result.rows)
@@ -31,11 +35,26 @@ For a hosted deployment, replace the URL with its public HTTPS origin. Alternati
31
35
  `PERIPLUS_PUBLIC_URL` and use `Client()`. An optional URL path prefix is preserved.
32
36
  The client reuses HTTP connections; close it with a context manager or `close()`.
33
37
 
38
+ ## Stable and experimental APIs
39
+
40
+ Both clients accept `mode="stable"` (the default) or `mode="experimental"` at initialization:
41
+
42
+ ```python
43
+ with Client("https://periplus.dev", mode="experimental") as client:
44
+ result = client.execute("SELECT capture_id FROM public_v1.capture LIMIT 1")
45
+ print(result.query_mode, result.compiler_version, result.optimizations)
46
+ ```
47
+
48
+ The selected mode applies to preparation, execution, and helper discovery. Experimental
49
+ requests use the public application's `/api/query/experimental/` routes. There is no
50
+ automatic fallback to stable if the experimental service is unavailable.
51
+ `AsyncClient` accepts the same option. Invalid modes raise `ConfigurationError`.
52
+
34
53
  ## Preparation and helpers
35
54
 
36
55
  ```python
37
56
  with Client("http://localhost:8080") as client:
38
- prepared = client.prepare("SELECT observation_id FROM web.observation LIMIT ?", [10])
57
+ prepared = client.prepare("SELECT capture_id FROM public_v1.capture LIMIT ?", [10])
39
58
  print(prepared.diagnostics, prepared.plan)
40
59
  result = client.execute(prepared.sql, prepared.parameters)
41
60
  helpers = client.helpers()
@@ -53,7 +72,7 @@ from periplus_sdk import AsyncClient
53
72
 
54
73
  async def observations():
55
74
  async with AsyncClient("http://localhost:8080") as client:
56
- return await client.execute("SELECT observation_id FROM web.observation LIMIT 10")
75
+ return await client.execute("SELECT capture_id FROM public_v1.capture LIMIT 10")
57
76
  ```
58
77
 
59
78
  Use `aclose()` when managing an async client's lifetime explicitly.
@@ -78,13 +97,14 @@ Use `aclose()` when managing an async client's lifetime explicitly.
78
97
 
79
98
  ## Installation and verification
80
99
 
81
- Install from PyPI:
100
+ Install the public-v1 client from PyPI:
82
101
 
83
102
  ```sh
84
- python -m pip install periplus-python-sdk==0.2.0
103
+ python -m pip install "periplus-python-sdk>=0.4.0"
85
104
  ```
86
105
 
87
- For local development: `python -m pip install ./packages/periplus-python-sdk`.
106
+ Version 0.4.0 supports the current public-v1 contract. For production, configure
107
+ `PERIPLUS_PUBLIC_URL=https://periplus.dev`; no API token is required.
88
108
  Run the installed package against an available public app:
89
109
 
90
110
  ```sh
@@ -95,14 +115,24 @@ PERIPLUS_PUBLIC_URL=http://localhost:8080 python packages/periplus-python-sdk/ex
95
115
 
96
116
  Repository CI publishes immutable releases from tags named
97
117
  `periplus-python-sdk-v<version>`. The tag must exactly match the static version
98
- in `pyproject.toml`; for example, version `0.2.0` is released with:
118
+ in `pyproject.toml`; for example, version `0.4.0` is released with:
99
119
 
100
120
  ```sh
101
- git tag periplus-python-sdk-v0.2.0
102
- git push origin periplus-python-sdk-v0.2.0
121
+ git tag periplus-python-sdk-v0.4.0
122
+ git push origin periplus-python-sdk-v0.4.0
103
123
  ```
104
124
 
105
125
  PyPI publishing uses Trusted Publishing rather than a stored API token. The
106
126
  PyPI publisher must be configured for GitHub owner `elei-io`, repository
107
127
  `periplus`, workflow `python-sdk-release.yml`, and environment `pypi`. Protect
108
128
  that GitHub environment with required reviewers before the first release.
129
+
130
+ ## Public v1
131
+
132
+ Install the updated SDK from PyPI with `python -m pip install "periplus-python-sdk>=0.4.0"`. The previously published 0.2.0 release predates this contract. `prepare` and `execute` accept keyword-only `schema_version="public_v1"` (the default); responses preserve `schema_version` separately from `source_snapshot`. Unavailable versions are rejected by the server.
133
+
134
+ ## License
135
+
136
+ Copyright (c) 2026 Ekku Leivonen (elei.io). Licensed under [Apache-2.0](LICENSE);
137
+ see [NOTICE](NOTICE). The server and other repository packages have separate
138
+ licensing described in the root LICENSING.md.
@@ -9,7 +9,7 @@ from periplus_sdk import Client
9
9
 
10
10
  with Client("http://localhost:8080") as client:
11
11
  result = client.execute(
12
- "SELECT observation_id FROM web.observation LIMIT ?", [10]
12
+ "SELECT capture_id FROM public_v1.capture LIMIT ?", [10]
13
13
  )
14
14
  print(result.columns, result.types)
15
15
  print(result.rows)
@@ -20,11 +20,26 @@ For a hosted deployment, replace the URL with its public HTTPS origin. Alternati
20
20
  `PERIPLUS_PUBLIC_URL` and use `Client()`. An optional URL path prefix is preserved.
21
21
  The client reuses HTTP connections; close it with a context manager or `close()`.
22
22
 
23
+ ## Stable and experimental APIs
24
+
25
+ Both clients accept `mode="stable"` (the default) or `mode="experimental"` at initialization:
26
+
27
+ ```python
28
+ with Client("https://periplus.dev", mode="experimental") as client:
29
+ result = client.execute("SELECT capture_id FROM public_v1.capture LIMIT 1")
30
+ print(result.query_mode, result.compiler_version, result.optimizations)
31
+ ```
32
+
33
+ The selected mode applies to preparation, execution, and helper discovery. Experimental
34
+ requests use the public application's `/api/query/experimental/` routes. There is no
35
+ automatic fallback to stable if the experimental service is unavailable.
36
+ `AsyncClient` accepts the same option. Invalid modes raise `ConfigurationError`.
37
+
23
38
  ## Preparation and helpers
24
39
 
25
40
  ```python
26
41
  with Client("http://localhost:8080") as client:
27
- prepared = client.prepare("SELECT observation_id FROM web.observation LIMIT ?", [10])
42
+ prepared = client.prepare("SELECT capture_id FROM public_v1.capture LIMIT ?", [10])
28
43
  print(prepared.diagnostics, prepared.plan)
29
44
  result = client.execute(prepared.sql, prepared.parameters)
30
45
  helpers = client.helpers()
@@ -42,7 +57,7 @@ from periplus_sdk import AsyncClient
42
57
 
43
58
  async def observations():
44
59
  async with AsyncClient("http://localhost:8080") as client:
45
- return await client.execute("SELECT observation_id FROM web.observation LIMIT 10")
60
+ return await client.execute("SELECT capture_id FROM public_v1.capture LIMIT 10")
46
61
  ```
47
62
 
48
63
  Use `aclose()` when managing an async client's lifetime explicitly.
@@ -67,13 +82,14 @@ Use `aclose()` when managing an async client's lifetime explicitly.
67
82
 
68
83
  ## Installation and verification
69
84
 
70
- Install from PyPI:
85
+ Install the public-v1 client from PyPI:
71
86
 
72
87
  ```sh
73
- python -m pip install periplus-python-sdk==0.2.0
88
+ python -m pip install "periplus-python-sdk>=0.4.0"
74
89
  ```
75
90
 
76
- For local development: `python -m pip install ./packages/periplus-python-sdk`.
91
+ Version 0.4.0 supports the current public-v1 contract. For production, configure
92
+ `PERIPLUS_PUBLIC_URL=https://periplus.dev`; no API token is required.
77
93
  Run the installed package against an available public app:
78
94
 
79
95
  ```sh
@@ -84,14 +100,24 @@ PERIPLUS_PUBLIC_URL=http://localhost:8080 python packages/periplus-python-sdk/ex
84
100
 
85
101
  Repository CI publishes immutable releases from tags named
86
102
  `periplus-python-sdk-v<version>`. The tag must exactly match the static version
87
- in `pyproject.toml`; for example, version `0.2.0` is released with:
103
+ in `pyproject.toml`; for example, version `0.4.0` is released with:
88
104
 
89
105
  ```sh
90
- git tag periplus-python-sdk-v0.2.0
91
- git push origin periplus-python-sdk-v0.2.0
106
+ git tag periplus-python-sdk-v0.4.0
107
+ git push origin periplus-python-sdk-v0.4.0
92
108
  ```
93
109
 
94
110
  PyPI publishing uses Trusted Publishing rather than a stored API token. The
95
111
  PyPI publisher must be configured for GitHub owner `elei-io`, repository
96
112
  `periplus`, workflow `python-sdk-release.yml`, and environment `pypi`. Protect
97
113
  that GitHub environment with required reviewers before the first release.
114
+
115
+ ## Public v1
116
+
117
+ Install the updated SDK from PyPI with `python -m pip install "periplus-python-sdk>=0.4.0"`. The previously published 0.2.0 release predates this contract. `prepare` and `execute` accept keyword-only `schema_version="public_v1"` (the default); responses preserve `schema_version` separately from `source_snapshot`. Unavailable versions are rejected by the server.
118
+
119
+ ## License
120
+
121
+ Copyright (c) 2026 Ekku Leivonen (elei.io). Licensed under [Apache-2.0](LICENSE);
122
+ see [NOTICE](NOTICE). The server and other repository packages have separate
123
+ licensing described in the root LICENSING.md.
@@ -1,6 +1,8 @@
1
1
  [project]
2
+ license = "Apache-2.0"
3
+ license-files = ["LICENSE", "NOTICE"]
2
4
  name = "periplus-python-sdk"
3
- version = "0.2.0"
5
+ version = "0.4.0"
4
6
  description = "Read-only Python client for the public Periplus query API"
5
7
  readme = "README.md"
6
8
  requires-python = ">=3.11"
@@ -1,13 +1,17 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: periplus-python-sdk
3
- Version: 0.2.0
3
+ Version: 0.4.0
4
4
  Summary: Read-only Python client for the public Periplus query API
5
+ License-Expression: Apache-2.0
5
6
  Project-URL: Repository, https://github.com/elei-io/periplus
6
7
  Project-URL: Issues, https://github.com/elei-io/periplus/issues
7
8
  Requires-Python: >=3.11
8
9
  Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ License-File: NOTICE
9
12
  Requires-Dist: httpx>=0.28
10
13
  Requires-Dist: pydantic<3,>=2.12
14
+ Dynamic: license-file
11
15
 
12
16
  # Periplus Python SDK
13
17
 
@@ -20,7 +24,7 @@ from periplus_sdk import Client
20
24
 
21
25
  with Client("http://localhost:8080") as client:
22
26
  result = client.execute(
23
- "SELECT observation_id FROM web.observation LIMIT ?", [10]
27
+ "SELECT capture_id FROM public_v1.capture LIMIT ?", [10]
24
28
  )
25
29
  print(result.columns, result.types)
26
30
  print(result.rows)
@@ -31,11 +35,26 @@ For a hosted deployment, replace the URL with its public HTTPS origin. Alternati
31
35
  `PERIPLUS_PUBLIC_URL` and use `Client()`. An optional URL path prefix is preserved.
32
36
  The client reuses HTTP connections; close it with a context manager or `close()`.
33
37
 
38
+ ## Stable and experimental APIs
39
+
40
+ Both clients accept `mode="stable"` (the default) or `mode="experimental"` at initialization:
41
+
42
+ ```python
43
+ with Client("https://periplus.dev", mode="experimental") as client:
44
+ result = client.execute("SELECT capture_id FROM public_v1.capture LIMIT 1")
45
+ print(result.query_mode, result.compiler_version, result.optimizations)
46
+ ```
47
+
48
+ The selected mode applies to preparation, execution, and helper discovery. Experimental
49
+ requests use the public application's `/api/query/experimental/` routes. There is no
50
+ automatic fallback to stable if the experimental service is unavailable.
51
+ `AsyncClient` accepts the same option. Invalid modes raise `ConfigurationError`.
52
+
34
53
  ## Preparation and helpers
35
54
 
36
55
  ```python
37
56
  with Client("http://localhost:8080") as client:
38
- prepared = client.prepare("SELECT observation_id FROM web.observation LIMIT ?", [10])
57
+ prepared = client.prepare("SELECT capture_id FROM public_v1.capture LIMIT ?", [10])
39
58
  print(prepared.diagnostics, prepared.plan)
40
59
  result = client.execute(prepared.sql, prepared.parameters)
41
60
  helpers = client.helpers()
@@ -53,7 +72,7 @@ from periplus_sdk import AsyncClient
53
72
 
54
73
  async def observations():
55
74
  async with AsyncClient("http://localhost:8080") as client:
56
- return await client.execute("SELECT observation_id FROM web.observation LIMIT 10")
75
+ return await client.execute("SELECT capture_id FROM public_v1.capture LIMIT 10")
57
76
  ```
58
77
 
59
78
  Use `aclose()` when managing an async client's lifetime explicitly.
@@ -78,13 +97,14 @@ Use `aclose()` when managing an async client's lifetime explicitly.
78
97
 
79
98
  ## Installation and verification
80
99
 
81
- Install from PyPI:
100
+ Install the public-v1 client from PyPI:
82
101
 
83
102
  ```sh
84
- python -m pip install periplus-python-sdk==0.2.0
103
+ python -m pip install "periplus-python-sdk>=0.4.0"
85
104
  ```
86
105
 
87
- For local development: `python -m pip install ./packages/periplus-python-sdk`.
106
+ Version 0.4.0 supports the current public-v1 contract. For production, configure
107
+ `PERIPLUS_PUBLIC_URL=https://periplus.dev`; no API token is required.
88
108
  Run the installed package against an available public app:
89
109
 
90
110
  ```sh
@@ -95,14 +115,24 @@ PERIPLUS_PUBLIC_URL=http://localhost:8080 python packages/periplus-python-sdk/ex
95
115
 
96
116
  Repository CI publishes immutable releases from tags named
97
117
  `periplus-python-sdk-v<version>`. The tag must exactly match the static version
98
- in `pyproject.toml`; for example, version `0.2.0` is released with:
118
+ in `pyproject.toml`; for example, version `0.4.0` is released with:
99
119
 
100
120
  ```sh
101
- git tag periplus-python-sdk-v0.2.0
102
- git push origin periplus-python-sdk-v0.2.0
121
+ git tag periplus-python-sdk-v0.4.0
122
+ git push origin periplus-python-sdk-v0.4.0
103
123
  ```
104
124
 
105
125
  PyPI publishing uses Trusted Publishing rather than a stored API token. The
106
126
  PyPI publisher must be configured for GitHub owner `elei-io`, repository
107
127
  `periplus`, workflow `python-sdk-release.yml`, and environment `pypi`. Protect
108
128
  that GitHub environment with required reviewers before the first release.
129
+
130
+ ## Public v1
131
+
132
+ Install the updated SDK from PyPI with `python -m pip install "periplus-python-sdk>=0.4.0"`. The previously published 0.2.0 release predates this contract. `prepare` and `execute` accept keyword-only `schema_version="public_v1"` (the default); responses preserve `schema_version` separately from `source_snapshot`. Unavailable versions are rejected by the server.
133
+
134
+ ## License
135
+
136
+ Copyright (c) 2026 Ekku Leivonen (elei.io). Licensed under [Apache-2.0](LICENSE);
137
+ see [NOTICE](NOTICE). The server and other repository packages have separate
138
+ licensing described in the root LICENSING.md.
@@ -1,3 +1,5 @@
1
+ LICENSE
2
+ NOTICE
1
3
  README.md
2
4
  pyproject.toml
3
5
  src/periplus_python_sdk.egg-info/PKG-INFO
@@ -6,7 +6,7 @@ from datetime import UTC, datetime
6
6
  from email.utils import parsedate_to_datetime
7
7
  import math
8
8
  import os
9
- from typing import TypeVar
9
+ from typing import Literal, TypeVar
10
10
 
11
11
  import httpx
12
12
  from pydantic import BaseModel, JsonValue, ValidationError
@@ -71,15 +71,18 @@ def _decode(response: httpx.Response, model: type[Model]) -> Model:
71
71
  raise ResponseError("Public query response did not match the expected contract.") from None
72
72
 
73
73
 
74
- def _payload(sql: str, parameters: Sequence[JsonValue] | None) -> dict:
74
+ def _payload(sql: str, parameters: Sequence[JsonValue] | None, schema_version: str) -> dict:
75
75
  # Server owns SQL validation, linting, preparation and optimization.
76
- return {"sql": sql, "parameters": list(parameters) if parameters is not None else []}
76
+ return {"schema_version": schema_version, "sql": sql, "parameters": list(parameters) if parameters is not None else []}
77
77
 
78
78
 
79
79
  class Client:
80
80
  """Reusable synchronous public query client. Close it or use a with block."""
81
81
 
82
- def __init__(self, base_url: str | None = None, *, timeout: float = 140):
82
+ def __init__(self, base_url: str | None = None, *, timeout: float = 140, mode: Literal["stable", "experimental"] = "stable"):
83
+ if mode not in {"stable", "experimental"}:
84
+ raise ConfigurationError("mode must be stable or experimental.")
85
+ self._query_path = "api/query/experimental/" if mode == "experimental" else "api/query/"
83
86
  self._http = httpx.Client(**_options(base_url, timeout))
84
87
 
85
88
  def __enter__(self) -> Client:
@@ -93,16 +96,16 @@ class Client:
93
96
 
94
97
  def _request(self, method: str, path: str, model: type[Model], **kwargs) -> Model:
95
98
  try:
96
- response = self._http.request(method, "api/query/" + path, **kwargs)
99
+ response = self._http.request(method, self._query_path + path, **kwargs)
97
100
  except httpx.RequestError:
98
101
  raise TransportError("Could not complete the public query request.") from None
99
102
  return _decode(response, model)
100
103
 
101
- def prepare(self, sql: str, parameters: Sequence[JsonValue] | None = None) -> PreparedQuery:
102
- return self._request("POST", "prep", PreparedQuery, json=_payload(sql, parameters))
104
+ def prepare(self, sql: str, parameters: Sequence[JsonValue] | None = None, *, schema_version: str = "public_v1") -> PreparedQuery:
105
+ return self._request("POST", "prep", PreparedQuery, json=_payload(sql, parameters, schema_version))
103
106
 
104
- def execute(self, sql: str, parameters: Sequence[JsonValue] | None = None) -> QueryResult:
105
- return self._request("POST", "exec", QueryResult, json=_payload(sql, parameters))
107
+ def execute(self, sql: str, parameters: Sequence[JsonValue] | None = None, *, schema_version: str = "public_v1") -> QueryResult:
108
+ return self._request("POST", "exec", QueryResult, json=_payload(sql, parameters, schema_version))
106
109
 
107
110
  def helpers(self) -> QueryHelpers:
108
111
  return self._request("GET", "helpers", QueryHelpers)
@@ -111,7 +114,10 @@ class Client:
111
114
  class AsyncClient:
112
115
  """Reusable asynchronous public query client. Use an async with block."""
113
116
 
114
- def __init__(self, base_url: str | None = None, *, timeout: float = 140):
117
+ def __init__(self, base_url: str | None = None, *, timeout: float = 140, mode: Literal["stable", "experimental"] = "stable"):
118
+ if mode not in {"stable", "experimental"}:
119
+ raise ConfigurationError("mode must be stable or experimental.")
120
+ self._query_path = "api/query/experimental/" if mode == "experimental" else "api/query/"
115
121
  self._http = httpx.AsyncClient(**_options(base_url, timeout))
116
122
 
117
123
  async def __aenter__(self) -> AsyncClient:
@@ -125,16 +131,16 @@ class AsyncClient:
125
131
 
126
132
  async def _request(self, method: str, path: str, model: type[Model], **kwargs) -> Model:
127
133
  try:
128
- response = await self._http.request(method, "api/query/" + path, **kwargs)
134
+ response = await self._http.request(method, self._query_path + path, **kwargs)
129
135
  except httpx.RequestError:
130
136
  raise TransportError("Could not complete the public query request.") from None
131
137
  return _decode(response, model)
132
138
 
133
- async def prepare(self, sql: str, parameters: Sequence[JsonValue] | None = None) -> PreparedQuery:
134
- return await self._request("POST", "prep", PreparedQuery, json=_payload(sql, parameters))
139
+ async def prepare(self, sql: str, parameters: Sequence[JsonValue] | None = None, *, schema_version: str = "public_v1") -> PreparedQuery:
140
+ return await self._request("POST", "prep", PreparedQuery, json=_payload(sql, parameters, schema_version))
135
141
 
136
- async def execute(self, sql: str, parameters: Sequence[JsonValue] | None = None) -> QueryResult:
137
- return await self._request("POST", "exec", QueryResult, json=_payload(sql, parameters))
142
+ async def execute(self, sql: str, parameters: Sequence[JsonValue] | None = None, *, schema_version: str = "public_v1") -> QueryResult:
143
+ return await self._request("POST", "exec", QueryResult, json=_payload(sql, parameters, schema_version))
138
144
 
139
145
  async def helpers(self) -> QueryHelpers:
140
146
  return await self._request("GET", "helpers", QueryHelpers)
@@ -1,4 +1,6 @@
1
1
  """Public query wire types; SQL types and JSON values are preserved."""
2
+ from typing import Literal
3
+
2
4
  from pydantic import BaseModel, Field, JsonValue
3
5
 
4
6
 
@@ -9,6 +11,10 @@ class Diagnostic(BaseModel):
9
11
 
10
12
 
11
13
  class PreparedQuery(BaseModel):
14
+ query_mode: Literal["stable", "experimental"]
15
+ compiler_version: str
16
+ optimizations: list[str]
17
+ schema_version: str
12
18
  query_id: str
13
19
  sql: str
14
20
  parameters: list[JsonValue]
@@ -7,17 +7,17 @@ import httpx
7
7
 
8
8
  from periplus_sdk import AsyncClient, Client, ApiError, ConfigurationError, ResponseError, TransportError
9
9
 
10
- PREP = dict(query_id='q', sql='SELECT ? AS n', parameters=[1], diagnostics=[], plan='plan')
10
+ PREP = dict(query_mode='stable', compiler_version='public-query-v8:stable', optimizations=[], schema_version='public_v1', query_id='q', sql='SELECT ? AS n', parameters=[1], diagnostics=[], plan='plan')
11
11
  RESULT = dict(**PREP, columns=['n', 'n'], types=['BIGINT', 'DECIMAL(20,2)'],
12
12
  rows=[['9007199254740993', '123.45']], truncated=True, elapsed_ms=1.2, source_snapshot=4)
13
13
 
14
14
 
15
15
  class ClientTests(unittest.TestCase):
16
- def client(self, handler):
16
+ def client(self, handler, **options):
17
17
  factory = httpx.Client
18
18
  with patch('periplus_sdk.client.httpx.Client', side_effect=lambda **kw:
19
19
  factory(**kw, transport=httpx.MockTransport(handler))):
20
- client = Client('https://public.example/prefix/')
20
+ client = Client('https://public.example/prefix/', **options)
21
21
  self.addCleanup(client.close)
22
22
  return client
23
23
 
@@ -28,8 +28,8 @@ class ClientTests(unittest.TestCase):
28
28
  self.assertNotIn('authorization', request.headers)
29
29
  self.assertEqual(request.headers['x-periplus-query-source'], 'sdk')
30
30
  if request.url.path.endswith('helpers'):
31
- return httpx.Response(200, json={'catalogue_version': '3.0.0', 'helpers': []})
32
- self.assertEqual(json.loads(request.content), {'sql': PREP['sql'], 'parameters': [1]})
31
+ return httpx.Response(200, json={'catalogue_version': '1.0.0', 'helpers': []})
32
+ self.assertEqual(json.loads(request.content), {'sql': PREP['sql'], 'parameters': [1], 'schema_version': 'public_v1'})
33
33
  return httpx.Response(200, json=RESULT if request.url.path.endswith('exec') else PREP)
34
34
  with patch.dict(os.environ, {'PERIPLUS_QUERY_API_TOKEN': 'secret', 'PERIPLUS_API_TOKEN': 'admin'}):
35
35
  client = self.client(handler)
@@ -39,9 +39,32 @@ class ClientTests(unittest.TestCase):
39
39
  self.assertEqual(result.columns, ['n', 'n'])
40
40
  self.assertTrue(result.truncated)
41
41
  self.assertEqual(result.source_snapshot, 4)
42
- self.assertEqual(client.helpers().catalogue_version, '3.0.0')
42
+ self.assertEqual(client.helpers().catalogue_version, '1.0.0')
43
43
  self.assertEqual([r.url.path for r in requests], ['/prefix/api/query/prep', '/prefix/api/query/exec', '/prefix/api/query/helpers'])
44
44
 
45
+ def test_experimental_routes_and_metadata(self):
46
+ paths = []
47
+ def handler(request):
48
+ paths.append(request.url.path)
49
+ if request.url.path.endswith('helpers'):
50
+ return httpx.Response(200, json={'catalogue_version': '1.0.0', 'helpers': []})
51
+ payload = dict(RESULT if request.url.path.endswith('exec') else PREP,
52
+ query_mode='experimental', compiler_version='public-query-v8:experimental',
53
+ optimizations=['content_scope'])
54
+ return httpx.Response(200, json=payload)
55
+ with self.client(handler, mode='experimental') as client:
56
+ prepared = client.prepare('SELECT 1')
57
+ self.assertEqual(prepared.query_mode, 'experimental')
58
+ self.assertEqual(prepared.compiler_version, 'public-query-v8:experimental')
59
+ self.assertEqual(client.execute('SELECT 1').optimizations, ['content_scope'])
60
+ client.helpers()
61
+ self.assertEqual(paths, ['/prefix/api/query/experimental/' + p for p in ['prep', 'exec', 'helpers']])
62
+
63
+ def test_invalid_mode(self):
64
+ for factory in (Client, AsyncClient):
65
+ with self.assertRaises(ConfigurationError):
66
+ factory('https://public.example', mode='unknown')
67
+
45
68
  def test_errors_preserve_categories_and_never_retry(self):
46
69
  for status, body, code in [(429, {'code': 'service_busy', 'detail': 'Busy'}, 'service_busy'),
47
70
  (403, {'code': 'feature_disabled', 'detail': 'Disabled'}, 'feature_disabled'),
@@ -97,14 +120,15 @@ class AsyncClientTests(unittest.IsolatedAsyncioTestCase):
97
120
  def handler(request):
98
121
  calls.append(request)
99
122
  if request.url.path.endswith('helpers'):
100
- return httpx.Response(200, json={'catalogue_version': '3.0.0', 'helpers': []})
123
+ return httpx.Response(200, json={'catalogue_version': '1.0.0', 'helpers': []})
101
124
  return httpx.Response(200, json=RESULT if request.url.path.endswith('exec') else PREP)
102
125
  with patch('periplus_sdk.client.httpx.AsyncClient', side_effect=lambda **kw:
103
126
  factory(**kw, transport=httpx.MockTransport(handler))):
104
- async with AsyncClient('https://public.example') as client:
127
+ async with AsyncClient('https://public.example/prefix/', mode='experimental') as client:
105
128
  self.assertEqual((await client.prepare('SELECT ?', [1])).parameters, [1])
106
129
  self.assertEqual((await client.execute('SELECT ?', [1])).rows, RESULT['rows'])
107
- self.assertEqual((await client.helpers()).catalogue_version, '3.0.0')
130
+ self.assertEqual((await client.helpers()).catalogue_version, '1.0.0')
108
131
  self.assertTrue(client._http.is_closed)
109
132
  self.assertEqual(len(calls), 3)
133
+ self.assertEqual([r.url.path for r in calls], ['/prefix/api/query/experimental/' + p for p in ['prep', 'exec', 'helpers']])
110
134
  self.assertTrue(all(r.headers['x-periplus-query-source'] == 'sdk' for r in calls))