# sedbuilder

The **sedbuilder** package implements a Python interface to the ASI Space Science Data Center's SED Builder REST API.

## Overview

This package provides programmatic access to multi-wavelength spectral energy distribution (SED) data from catalogs, surveys, and archival observations across the electromagnetic spectrum.
It is based on [SED Builder](https://tools.ssdc.asi.it/SED/), a software developed at the ASI-SSDC to produce and display the SED data over the web.

## Installation

```bash
pip install ssdc-sedbuilder
```

## Quick Start

You can fetch data querying a source name or its coordinates.

```python
from sedbuilder import get_data

# By coordinates
response = get_data(ra=244.9795, dec=-15.64022)
# By name
response = get_data(name="Sco X-1")

# Access data in different formats
table = response.to_astropy()     # Astropy Table
data_dict = response.to_dict()    # Python dictionary
jt = response.to_jetset(z=0.034)  # Jetset table
json_str = response.to_json()     # JSON string
df = response.to_pandas()         # Pandas DataFrame (requires pandas)
```

When calling `get_data` by name, `resolve_name` queries the SSDC server — which checks SSDC, SIMBAD, and NED — falling back to the CDS Sesame resolver via astropy if no match is found.

```python
from sedbuilder import resolve_name

(ra, dec), db = resolve_name("Crab Nebula")
```

Resolving a source name takes time. We suggest querying on coordinates when available.


## Development

```bash
git clone https://github.com/peppedilillo/sedbuilder.git
cd sedbuilder
pip install -e ".[dev]"
pre-commit install
# next line will route queries to test server. 
# use only on SSDC internal network 
source dev.env 
pytest
```

To build and serve the documentation locally:

```bash
pip install -e ".[docs]"
mkdocs serve
mkdocs build
```

To publish the documentation to GitHub Pages:

```bash
mkdocs gh-deploy
```

## Requests

Need a new feature? Don't hesitate to ask in our [discussion section](https://github.com/peppedilillo/sedbuilder/discussions).


## Documentation

Check out our [API reference](https://peppedilillo.github.io/sedbuilder/api/).
