# across-client

<!-- [![Template](https://img.shields.io/badge/Template-LINCC%20Frameworks%20Python%20Project%20Template-brightgreen)](https://lincc-ppt.readthedocs.io/en/latest/)

[![PyPI](https://img.shields.io/pypi/v/across-client?color=blue&logo=pypi&logoColor=white)](https://pypi.org/project/across-client/)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/NASA-ACROSS/across-client/smoke-test.yml)](https://github.com/NASA-ACROSS/across-client/actions/workflows/smoke-test.yml)
[![Codecov](https://codecov.io/gh/NASA-ACROSS/across-client/branch/main/graph/badge.svg)](https://codecov.io/gh/NASA-ACROSS/across-client)
[![Read The Docs](https://img.shields.io/readthedocs/across-client)](https://across-client.readthedocs.io/) -->

The `across-client` is the NASA-ACROSS library used to access and manipulate the [`across-server`](https://github.com/NASA-ACROSS/across-server) data. What separates this package from the autogenerated [sdk](https://github.com/NASA-ACROSS/across-server-openapi-python) is that it also levarages the [`across-tools`](https://github.com/NASA-ACROSS/across-tools) package to give users a single interface for all of their cross-observatory science needs.

## Access

To access our observatory data (telescopes, instruments, schedues, etc) on the [`across-server`](https://github.com/NASA-ACROSS/across-server), users **DO NOT** require any authentication. But if an observatory user-group wants to use the API to publish their planned/completed observing schedules they are required to register, and obtain client credentials through the website.

## Installation

This repository can be installed on python (`version >=3.10`) environments.

```sh
#activate your python environment (conda, mamba, venv... etc)
git clone https://github.com/NASA-ACROSS/across-client.git
cd across-client
python -m pip install .
```

or the latest released version with `pip`

```sh
python -m pip install across-client
```

## Usage

Below is a small example on how to utilize the client to access JWST Nircam performed observations. For more examples on how to access observatory science data or use our observatory tools endpoints, please go to our [examples](https://github.com/NASA-ACROSS/across-client/tree/main/examples) folder.

```python
from datetime import datetime
from across.client import Client

# client credentials are only required for publishing schedules
ACROSS_SERVER_ID: str = "..."
ACROSS_SERVER_SECRET: str = "..."

client = Client(client_id=ACROSS_SERVER_ID, client_secret=ACROSS_SERVER_SECRET)

nircam = client.instrument.get_many(name="nircam")[0]

nircam_observations = client.observation.get_many(
   instrument_ids=[nircam.id],
   status="performed",
   date_range_begin=datetime(...),
   date_range_end=datetime(...),
)
```

## Contributing

Found a bug? Want to make a feature request? Or create a pull request? Navigate to our [Contributing](https://github.com/NASA-ACROSS/across-client/blob/main/CONTRIBUTING.md) document for more instructions!

## Other Links

[Open Science at NASA](https://science.nasa.gov/open-science/)

## Notice

NASA Docket No. GSC-19,469-1, and identified as "Astrophysics Cross-Observatory
Science Support (ACROSS) System

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.“

Copyright © 2025 United States Government as represented by the Administrator
of the National Aeronautics and Space Administration and The Penn State
Research Foundation. All rights reserved. This software is licensed under the
Apache 2.0 License.
