meteora-py 0.1.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.
- meteora_py-0.1.0/.gitignore +218 -0
- meteora_py-0.1.0/LICENSE +21 -0
- meteora_py-0.1.0/PKG-INFO +149 -0
- meteora_py-0.1.0/README.md +116 -0
- meteora_py-0.1.0/pyproject.toml +81 -0
- meteora_py-0.1.0/src/meteora/__init__.py +41 -0
- meteora_py-0.1.0/src/meteora/_errors.py +39 -0
- meteora_py-0.1.0/src/meteora/_transport.py +76 -0
- meteora_py-0.1.0/src/meteora/client.py +459 -0
- meteora_py-0.1.0/src/meteora/constants.py +18 -0
- meteora_py-0.1.0/src/meteora/models.py +242 -0
- meteora_py-0.1.0/src/meteora/py.typed +0 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
# Temporary file for partial code execution
|
|
204
|
+
tempCodeRunnerFile.py
|
|
205
|
+
|
|
206
|
+
# Ruff stuff:
|
|
207
|
+
.ruff_cache/
|
|
208
|
+
|
|
209
|
+
# PyPI configuration file
|
|
210
|
+
.pypirc
|
|
211
|
+
|
|
212
|
+
# Marimo
|
|
213
|
+
marimo/_static/
|
|
214
|
+
marimo/_lsp/
|
|
215
|
+
__marimo__/
|
|
216
|
+
|
|
217
|
+
# Streamlit
|
|
218
|
+
.streamlit/secrets.toml
|
meteora_py-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Robert Ruben
|
|
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,149 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: meteora-py
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Typed Python client for the Meteora DLMM Data API on Solana (pools, metrics, OHLCV, fees, APR/APY).
|
|
5
|
+
Project-URL: Homepage, https://github.com/robertruben98/meteora-py
|
|
6
|
+
Project-URL: Repository, https://github.com/robertruben98/meteora-py
|
|
7
|
+
Project-URL: Documentation, https://docs.meteora.ag
|
|
8
|
+
Project-URL: Issues, https://github.com/robertruben98/meteora-py/issues
|
|
9
|
+
Author: Robert Ruben
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: amm,apr,apy,defi,dlmm,liquidity,meteora,solana
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Requires-Dist: httpx>=0.24
|
|
25
|
+
Requires-Dist: pydantic>=2.0
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: mypy>=1.8; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: respx>=0.20; extra == 'dev'
|
|
31
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# meteora-py
|
|
35
|
+
|
|
36
|
+
[](https://github.com/robertruben98/meteora-py/actions/workflows/ci.yml)
|
|
37
|
+
[](https://pypi.org/project/meteora-py/)
|
|
38
|
+
[](https://robertruben98.github.io/meteora-py/)
|
|
39
|
+
[](https://pypi.org/project/meteora-py/)
|
|
40
|
+
[](https://opensource.org/licenses/MIT)
|
|
41
|
+
|
|
42
|
+
Typed, read-only Python client for the **[Meteora](https://www.meteora.ag) DLMM Data API** on
|
|
43
|
+
Solana — list liquidity pools, read per-pool metrics (TVL, volume, fees, APR/APY), browse
|
|
44
|
+
token-pair pool groups, and pull OHLCV candles and historical volume. Sync **and** async,
|
|
45
|
+
backed by [`httpx`](https://www.python-httpx.org/) with [`pydantic`](https://docs.pydantic.dev/)
|
|
46
|
+
v2 models.
|
|
47
|
+
|
|
48
|
+
The Meteora DLMM Data API is **public and keyless** (rate-limited to 30 requests/second). This
|
|
49
|
+
library covers the read endpoints; it does **not** build or sign transactions.
|
|
50
|
+
|
|
51
|
+
## Install
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install meteora-py
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Quickstart
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from meteora import MeteoraClient
|
|
61
|
+
|
|
62
|
+
with MeteoraClient() as client:
|
|
63
|
+
# Protocol-wide aggregates
|
|
64
|
+
stats = client.get_protocol_metrics()
|
|
65
|
+
print(f"TVL ${stats.total_tvl:,.0f} across {stats.total_pools:,} pools")
|
|
66
|
+
|
|
67
|
+
# Page through pools (sorted server-side; sort_by is "<field>:<asc|desc>")
|
|
68
|
+
page = client.get_pools(page=1, page_size=10, sort_by="tvl:desc")
|
|
69
|
+
for pool in page.data:
|
|
70
|
+
print(f"{pool.name:16} TVL ${pool.tvl:,.0f} APR {pool.apr:.2%} APY {pool.apy:.0%}")
|
|
71
|
+
|
|
72
|
+
# A single pool by its on-chain address
|
|
73
|
+
sol_usdc = client.get_pool("5rCf1DM8LjKTw4YqhnoLcngyZYeNnQqztScTogYHAS6")
|
|
74
|
+
print(sol_usdc.token_x.symbol, sol_usdc.token_y.symbol, sol_usdc.current_price)
|
|
75
|
+
|
|
76
|
+
# OHLCV candles and historical volume
|
|
77
|
+
candles = client.get_pool_ohlcv(sol_usdc.address)
|
|
78
|
+
history = client.get_pool_volume_history(sol_usdc.address)
|
|
79
|
+
print(candles.data[-1].close, history.data[-1].fees)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Async
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import asyncio
|
|
86
|
+
from meteora import AsyncMeteoraClient
|
|
87
|
+
|
|
88
|
+
async def main() -> None:
|
|
89
|
+
async with AsyncMeteoraClient() as client:
|
|
90
|
+
stats = await client.get_protocol_metrics()
|
|
91
|
+
print(stats.total_pools)
|
|
92
|
+
|
|
93
|
+
asyncio.run(main())
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
See [`examples/`](examples/) for runnable scripts.
|
|
97
|
+
|
|
98
|
+
## Covered endpoints
|
|
99
|
+
|
|
100
|
+
Base URL: `https://dlmm.datapi.meteora.ag` (override via `MeteoraClient(base_url=...)`).
|
|
101
|
+
|
|
102
|
+
| Method | Endpoint | Client method |
|
|
103
|
+
|--------|----------|---------------|
|
|
104
|
+
| `GET` | `/stats/protocol_metrics` | `get_protocol_metrics()` |
|
|
105
|
+
| `GET` | `/pools` | `get_pools(page, page_size, query, sort_by, filter_by)`* |
|
|
106
|
+
| `GET` | `/pools/{address}` | `get_pool(address)` |
|
|
107
|
+
| `GET` | `/pools/groups` | `get_pool_groups(page, page_size)` |
|
|
108
|
+
| `GET` | `/pools/{address}/ohlcv` | `get_pool_ohlcv(address, from_, to, resolution)` |
|
|
109
|
+
| `GET` | `/pools/{address}/volume/history` | `get_pool_volume_history(address)` |
|
|
110
|
+
|
|
111
|
+
*`sort_by` is a `"<field>:<asc|desc>"` expression (e.g. `"tvl:desc"`); a bare field name is
|
|
112
|
+
rejected with HTTP 400. `filter_by` is a `"<field>:<value>"` filter expression passed through
|
|
113
|
+
verbatim. Both were confirmed against the live API.
|
|
114
|
+
|
|
115
|
+
All endpoints were discovered and verified live against the public API. The Meteora docs also
|
|
116
|
+
expose `/portfolio`, `/positions`, `/wallets`, and limit-order endpoints, plus separate DAMM v1/v2
|
|
117
|
+
APIs — these are out of scope for v1 and may follow in a later release.
|
|
118
|
+
|
|
119
|
+
## Error handling
|
|
120
|
+
|
|
121
|
+
Every method raises `MeteoraAPIError` (a subclass of `MeteoraError`) on a non-2xx response.
|
|
122
|
+
Network-level failures propagate as the underlying `httpx` exceptions.
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
from meteora import MeteoraClient, MeteoraAPIError
|
|
126
|
+
|
|
127
|
+
with MeteoraClient() as client:
|
|
128
|
+
try:
|
|
129
|
+
client.get_pool("not-a-real-address")
|
|
130
|
+
except MeteoraAPIError as exc:
|
|
131
|
+
print(exc.status_code, exc.message)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Models are configured with `extra="allow"`, so fields Meteora adds over time are preserved
|
|
135
|
+
rather than rejected.
|
|
136
|
+
|
|
137
|
+
## Development
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
pip install -e ".[dev]"
|
|
141
|
+
ruff check . && ruff format --check .
|
|
142
|
+
mypy
|
|
143
|
+
pytest -q # unit tests (respx-mocked, no network)
|
|
144
|
+
pytest -m integration # one live test against the real API
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# meteora-py
|
|
2
|
+
|
|
3
|
+
[](https://github.com/robertruben98/meteora-py/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/meteora-py/)
|
|
5
|
+
[](https://robertruben98.github.io/meteora-py/)
|
|
6
|
+
[](https://pypi.org/project/meteora-py/)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
Typed, read-only Python client for the **[Meteora](https://www.meteora.ag) DLMM Data API** on
|
|
10
|
+
Solana — list liquidity pools, read per-pool metrics (TVL, volume, fees, APR/APY), browse
|
|
11
|
+
token-pair pool groups, and pull OHLCV candles and historical volume. Sync **and** async,
|
|
12
|
+
backed by [`httpx`](https://www.python-httpx.org/) with [`pydantic`](https://docs.pydantic.dev/)
|
|
13
|
+
v2 models.
|
|
14
|
+
|
|
15
|
+
The Meteora DLMM Data API is **public and keyless** (rate-limited to 30 requests/second). This
|
|
16
|
+
library covers the read endpoints; it does **not** build or sign transactions.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install meteora-py
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quickstart
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from meteora import MeteoraClient
|
|
28
|
+
|
|
29
|
+
with MeteoraClient() as client:
|
|
30
|
+
# Protocol-wide aggregates
|
|
31
|
+
stats = client.get_protocol_metrics()
|
|
32
|
+
print(f"TVL ${stats.total_tvl:,.0f} across {stats.total_pools:,} pools")
|
|
33
|
+
|
|
34
|
+
# Page through pools (sorted server-side; sort_by is "<field>:<asc|desc>")
|
|
35
|
+
page = client.get_pools(page=1, page_size=10, sort_by="tvl:desc")
|
|
36
|
+
for pool in page.data:
|
|
37
|
+
print(f"{pool.name:16} TVL ${pool.tvl:,.0f} APR {pool.apr:.2%} APY {pool.apy:.0%}")
|
|
38
|
+
|
|
39
|
+
# A single pool by its on-chain address
|
|
40
|
+
sol_usdc = client.get_pool("5rCf1DM8LjKTw4YqhnoLcngyZYeNnQqztScTogYHAS6")
|
|
41
|
+
print(sol_usdc.token_x.symbol, sol_usdc.token_y.symbol, sol_usdc.current_price)
|
|
42
|
+
|
|
43
|
+
# OHLCV candles and historical volume
|
|
44
|
+
candles = client.get_pool_ohlcv(sol_usdc.address)
|
|
45
|
+
history = client.get_pool_volume_history(sol_usdc.address)
|
|
46
|
+
print(candles.data[-1].close, history.data[-1].fees)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Async
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import asyncio
|
|
53
|
+
from meteora import AsyncMeteoraClient
|
|
54
|
+
|
|
55
|
+
async def main() -> None:
|
|
56
|
+
async with AsyncMeteoraClient() as client:
|
|
57
|
+
stats = await client.get_protocol_metrics()
|
|
58
|
+
print(stats.total_pools)
|
|
59
|
+
|
|
60
|
+
asyncio.run(main())
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
See [`examples/`](examples/) for runnable scripts.
|
|
64
|
+
|
|
65
|
+
## Covered endpoints
|
|
66
|
+
|
|
67
|
+
Base URL: `https://dlmm.datapi.meteora.ag` (override via `MeteoraClient(base_url=...)`).
|
|
68
|
+
|
|
69
|
+
| Method | Endpoint | Client method |
|
|
70
|
+
|--------|----------|---------------|
|
|
71
|
+
| `GET` | `/stats/protocol_metrics` | `get_protocol_metrics()` |
|
|
72
|
+
| `GET` | `/pools` | `get_pools(page, page_size, query, sort_by, filter_by)`* |
|
|
73
|
+
| `GET` | `/pools/{address}` | `get_pool(address)` |
|
|
74
|
+
| `GET` | `/pools/groups` | `get_pool_groups(page, page_size)` |
|
|
75
|
+
| `GET` | `/pools/{address}/ohlcv` | `get_pool_ohlcv(address, from_, to, resolution)` |
|
|
76
|
+
| `GET` | `/pools/{address}/volume/history` | `get_pool_volume_history(address)` |
|
|
77
|
+
|
|
78
|
+
*`sort_by` is a `"<field>:<asc|desc>"` expression (e.g. `"tvl:desc"`); a bare field name is
|
|
79
|
+
rejected with HTTP 400. `filter_by` is a `"<field>:<value>"` filter expression passed through
|
|
80
|
+
verbatim. Both were confirmed against the live API.
|
|
81
|
+
|
|
82
|
+
All endpoints were discovered and verified live against the public API. The Meteora docs also
|
|
83
|
+
expose `/portfolio`, `/positions`, `/wallets`, and limit-order endpoints, plus separate DAMM v1/v2
|
|
84
|
+
APIs — these are out of scope for v1 and may follow in a later release.
|
|
85
|
+
|
|
86
|
+
## Error handling
|
|
87
|
+
|
|
88
|
+
Every method raises `MeteoraAPIError` (a subclass of `MeteoraError`) on a non-2xx response.
|
|
89
|
+
Network-level failures propagate as the underlying `httpx` exceptions.
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from meteora import MeteoraClient, MeteoraAPIError
|
|
93
|
+
|
|
94
|
+
with MeteoraClient() as client:
|
|
95
|
+
try:
|
|
96
|
+
client.get_pool("not-a-real-address")
|
|
97
|
+
except MeteoraAPIError as exc:
|
|
98
|
+
print(exc.status_code, exc.message)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Models are configured with `extra="allow"`, so fields Meteora adds over time are preserved
|
|
102
|
+
rather than rejected.
|
|
103
|
+
|
|
104
|
+
## Development
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
pip install -e ".[dev]"
|
|
108
|
+
ruff check . && ruff format --check .
|
|
109
|
+
mypy
|
|
110
|
+
pytest -q # unit tests (respx-mocked, no network)
|
|
111
|
+
pytest -m integration # one live test against the real API
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "meteora-py"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Typed Python client for the Meteora DLMM Data API on Solana (pools, metrics, OHLCV, fees, APR/APY)."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Robert Ruben" }]
|
|
13
|
+
keywords = ["meteora", "dlmm", "solana", "liquidity", "defi", "amm", "apy", "apr"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.9",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Typing :: Typed",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"httpx>=0.24",
|
|
28
|
+
"pydantic>=2.0",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
dev = [
|
|
33
|
+
"pytest>=7.0",
|
|
34
|
+
"pytest-asyncio>=0.21",
|
|
35
|
+
"respx>=0.20",
|
|
36
|
+
"mypy>=1.8",
|
|
37
|
+
"ruff>=0.4",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[project.urls]
|
|
41
|
+
Homepage = "https://github.com/robertruben98/meteora-py"
|
|
42
|
+
Repository = "https://github.com/robertruben98/meteora-py"
|
|
43
|
+
Documentation = "https://docs.meteora.ag"
|
|
44
|
+
Issues = "https://github.com/robertruben98/meteora-py/issues"
|
|
45
|
+
|
|
46
|
+
[tool.hatch.build.targets.wheel]
|
|
47
|
+
packages = ["src/meteora"]
|
|
48
|
+
|
|
49
|
+
[tool.hatch.build.targets.sdist]
|
|
50
|
+
include = ["src/meteora", "README.md", "LICENSE"]
|
|
51
|
+
|
|
52
|
+
[tool.ruff]
|
|
53
|
+
line-length = 100
|
|
54
|
+
target-version = "py39"
|
|
55
|
+
src = ["src", "tests"]
|
|
56
|
+
|
|
57
|
+
[tool.ruff.lint]
|
|
58
|
+
select = ["E", "F", "I", "UP", "B", "W", "C4", "SIM"]
|
|
59
|
+
# UP007/UP045 would push to PEP 604 `X | None`, and UP006 to bare `list`/`dict`,
|
|
60
|
+
# in annotations that pydantic re-evaluates at runtime on Python 3.9. Keep
|
|
61
|
+
# typing.Optional/Union/List/Dict so the models build cleanly on 3.9.
|
|
62
|
+
ignore = ["UP006", "UP007", "UP035", "UP045"]
|
|
63
|
+
|
|
64
|
+
[tool.mypy]
|
|
65
|
+
python_version = "3.10"
|
|
66
|
+
strict = true
|
|
67
|
+
warn_unused_ignores = true
|
|
68
|
+
warn_redundant_casts = true
|
|
69
|
+
files = ["src", "tests"]
|
|
70
|
+
|
|
71
|
+
[[tool.mypy.overrides]]
|
|
72
|
+
module = ["respx.*"]
|
|
73
|
+
ignore_missing_imports = true
|
|
74
|
+
|
|
75
|
+
[tool.pytest.ini_options]
|
|
76
|
+
asyncio_mode = "auto"
|
|
77
|
+
testpaths = ["tests"]
|
|
78
|
+
markers = [
|
|
79
|
+
"integration: live network tests against the real Meteora API (deselected by default)",
|
|
80
|
+
]
|
|
81
|
+
addopts = "-m 'not integration'"
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""Typed Python client for the Meteora DLMM Data API on Solana."""
|
|
2
|
+
|
|
3
|
+
from meteora import constants
|
|
4
|
+
from meteora._errors import MeteoraAPIError, MeteoraError
|
|
5
|
+
from meteora.client import AsyncMeteoraClient, MeteoraClient
|
|
6
|
+
from meteora.models import (
|
|
7
|
+
CumulativeMetrics,
|
|
8
|
+
OhlcvCandle,
|
|
9
|
+
OhlcvResponse,
|
|
10
|
+
Pool,
|
|
11
|
+
PoolConfig,
|
|
12
|
+
PoolGroup,
|
|
13
|
+
PoolGroupsPage,
|
|
14
|
+
PoolsPage,
|
|
15
|
+
ProtocolMetrics,
|
|
16
|
+
TokenInfo,
|
|
17
|
+
VolumeHistoryPoint,
|
|
18
|
+
VolumeHistoryResponse,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"AsyncMeteoraClient",
|
|
23
|
+
"CumulativeMetrics",
|
|
24
|
+
"MeteoraAPIError",
|
|
25
|
+
"MeteoraClient",
|
|
26
|
+
"MeteoraError",
|
|
27
|
+
"OhlcvCandle",
|
|
28
|
+
"OhlcvResponse",
|
|
29
|
+
"Pool",
|
|
30
|
+
"PoolConfig",
|
|
31
|
+
"PoolGroup",
|
|
32
|
+
"PoolGroupsPage",
|
|
33
|
+
"PoolsPage",
|
|
34
|
+
"ProtocolMetrics",
|
|
35
|
+
"TokenInfo",
|
|
36
|
+
"VolumeHistoryPoint",
|
|
37
|
+
"VolumeHistoryResponse",
|
|
38
|
+
"constants",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Exception hierarchy for the Meteora client."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class MeteoraError(Exception):
|
|
7
|
+
"""Base class for all errors raised by this library.
|
|
8
|
+
|
|
9
|
+
Catch this to handle any failure originating from ``meteora`` (currently
|
|
10
|
+
just :class:`MeteoraAPIError`). Network-level failures from the underlying
|
|
11
|
+
``httpx`` client propagate as ``httpx`` exceptions and are not wrapped.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class MeteoraAPIError(MeteoraError):
|
|
16
|
+
"""Raised when the Meteora DLMM Data API returns an error response.
|
|
17
|
+
|
|
18
|
+
The API signals errors with a non-2xx HTTP status. The body, when present,
|
|
19
|
+
is surfaced in :attr:`message`; otherwise it falls back to ``"HTTP <status>"``.
|
|
20
|
+
|
|
21
|
+
Attributes:
|
|
22
|
+
message: The error message text, falling back to ``"HTTP <status>"``.
|
|
23
|
+
status_code: The HTTP status code of the response.
|
|
24
|
+
|
|
25
|
+
Example::
|
|
26
|
+
|
|
27
|
+
from meteora import MeteoraClient, MeteoraAPIError
|
|
28
|
+
|
|
29
|
+
with MeteoraClient() as client:
|
|
30
|
+
try:
|
|
31
|
+
client.get_pool("not-a-real-address")
|
|
32
|
+
except MeteoraAPIError as exc:
|
|
33
|
+
print(exc.status_code, exc.message)
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def __init__(self, *, message: str, status_code: int) -> None:
|
|
37
|
+
self.message = message
|
|
38
|
+
self.status_code = status_code
|
|
39
|
+
super().__init__(f"[HTTP {status_code}] {message}")
|