https://github.com/xpublish-community/xpublish
Publish Xarray Datasets via a REST API.
https://github.com/xpublish-community/xpublish
fast-api rest-api xarray
Last synced: 26 days ago
JSON representation
Publish Xarray Datasets via a REST API.
- Host: GitHub
- URL: https://github.com/xpublish-community/xpublish
- Owner: xpublish-community
- License: apache-2.0
- Created: 2020-01-23T17:18:17.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2025-10-20T22:33:22.000Z (27 days ago)
- Last Synced: 2025-10-21T19:51:55.931Z (26 days ago)
- Topics: fast-api, rest-api, xarray
- Language: Python
- Homepage: https://xpublish.readthedocs.io
- Size: 375 KB
- Stars: 191
- Watchers: 12
- Forks: 33
- Open Issues: 30
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-zarr - xpublish
README
# Xpublish
Publish Xarray Datasets to the web
[](https://pypi.org/project/xpublish/)
[](https://anaconda.org/conda-forge/xpublish)

[](https://mybinder.org/v2/gh/xpublish-community/xpublish/main)
[](https://github.com/xpublish-community/xpublish/actions/workflows/main.yaml)
[](https://xpublish.readthedocs.io/en/latest/?badge=latest)
[](https://codecov.io/gh/xpublish-community/xpublish)
[](https://results.pre-commit.ci/latest/github/xpublish-community/xpublish/main)
## A quick example
**Serverside: Publish a Xarray Dataset through a rest API**
```python
ds.rest.serve(host="0.0.0.0", port=9000)
```
**Client-side: Connect to a published dataset**
The published datasets can be accessed from various kinds of client applications, e.g., from within Python using Zarr and fsspec.
```python
import xarray as xr
import zarr
from fsspec.implementations.http import HTTPFileSystem
fs = HTTPFileSystem()
http_map = fs.get_mapper("http://0.0.0.0:9000/zarr/")
# open as a zarr group
zg = zarr.open_consolidated(http_map, mode="r")
# or open as another Xarray Dataset
ds = xr.open_zarr(http_map, consolidated=True)
```
Or to explore other access methods, open [http://0.0.0.0:9000/docs](http://0.0.0.0:9000/docs) in a browser.
## Why?
Xpublish lets you serve/share/publish Xarray Datasets via a web application.
The data and/or metadata in the Xarray Datasets can be exposed in various forms through [pluggable REST API endpoints](https://xpublish.readthedocs.io/en/latest/user-guide/plugins.html).
Efficient, on-demand delivery of large datasets may be enabled with Dask on the server-side.
Xpublish's [plugin ecosystem](https://xpublish.readthedocs.io/en/latest/ecosystem/index.html#plugins) has capabilities including:
- publish on-demand or derived data products
- turning xarray objects into streaming services (e.g. OPeNDAP)
## How?
Under the hood, Xpublish is using a web app (FastAPI) that is exposing a
REST-like API with builtin and/or user-defined endpoints.
For example, Xpublish provides by default a minimal Zarr compatible REST-like API with the following endpoints:
- `zarr/.zmetadata`: returns Zarr-formatted metadata keys as json strings.
- `zarr/var/0.0.0`: returns a variable data chunk as a binary string.
Futher endpoints can be added by installing or writing plugins.