This API provides endpoints to fetch and manage data on exoplanets and stars. It allows querying exoplanets and nearby stars using the Gaia catalog, with responses including calculated 3D positions and intensities. The application uses FastAPI for creating RESTful endpoints and Redis for caching data.
-
Backend Framework: FastAPI
-
Data Source for Exoplanets: IPAC Exoplanet Archive
-
Data Source for Stars: Hipparcos
-
Caching: Redis
-
Data Processing: Numpy for mathematical computations
-
API Documentation: (Swagger) Auto-generated by FastAPI
-
app/api/
: Contains endpoints for handling exoplanet and star data. -
app/schemas.py
: Defines Pydantic models for request and response validation. -
.env
: Environment variables for configuration. -
main.py
: Entry point for running the FastAPI application.
docker compose up -d
This will start the server at http://127.0.0.1:8000
.
The following prerequisites are required and must be installed manually:
- Python 3.10 or higher
- Poetry
- Redis Either locally or in the cloud
- Insomnia or Postman for API testing (optional)
-
Clone the Repository
git clone https://github.com/integrityofstellar/exosky-backend.git cd exosky-backend-nasa-d
-
Create and Activate a Virtual Environment using Poetry
poetry shell
-
Install Dependencies
poetry install
-
Set Up Environment Variables
Create a
.env
file in the root directory by copying theexample.env
file and replace content if needed:cp example.env .env
To start the FastAPI application, run:
uvicorn main:app --reload
This will start the server at http://127.0.0.1:8000
.
For more details follow the server at http://127.0.0.1:8000/docs
(or your other server ip:port) to access Swagger
documentation
-
URL:
/api/exoplanets/
-
Method:
GET
-
Query Parameters:
use_local_dataset
(optional, default:True
): Use local file or fetch from the remote API.limit
(optional, default:20
): Number of records to return.offset
(optional, default:0
): Pagination offset.
-
Response:
data
: List of exoplanets.metadata
: Information about pagination.
-
URL:
/api/stars/
-
Method:
POST
-
Request Body (JSON):
{ "ra": 123.456, "dec": 78.910 }
-
Query Parameters:
radius
(optional, default:5
): Radius for the search area around the coordinates.limit
(optional, default:3000
): Number of records to return.force_skip_cache
(optional, default:False
): Skip cache and fetch fresh data.
-
Response:
data
: List of stars with 3D positions and intensity.metadata
: Information about total amount of stars.
-
Updating Dependencies
To update project dependencies, modify
pyproject.toml
and run:poetry install
OR
poetry add PACKAGE
-
Caching Configuration
Redis configuration can be updated in the
.env
file to match your Redis setup. -
Data Source Updates
The data sources for exoplanets and stars are queried from external APIs. Ensure that these sources are available and update the API endpoints if necessary.
-
Logs and Monitoring
- Implement logging and monitoring for production environments to track application performance and errors.
Contributions are welcome! Please fork the repository and submit a pull request with your changes. Ensure that your changes include tests and adhere to the project's coding standards.
This project is licensed under the MIT License. See the LICENSE file for details.