This project is a RESTful API for the REBOUND N-body simulation library. The goal of this API is easily integrate REBOUND into other applications without the need to integrate the C code directly.
- Create and save celestial simulations.
- Add primary and secondary bodies.
- Add bodies using orbital elements.
- Integrate simulations to a specific time.
- Retrieve trajectories over a specified period.
- Python 3.12
- Conda
- Postman (for debugging API endpoints)
-
Clone the repository:
git clone https://github.com/renanklehm/rebound-api.git cd rebound-api
-
Create and activate the Conda environment:
conda create --name rebound python=3.12 conda activate rebound
-
Install required packages:
pip install -r requirements.txt
-
Run the API:
python api.py
The API will be accessible at
http://127.0.0.1:4242
.
To interact with the API you just need to make requests to the endpoints. A Postman collection is provided as a template to help you get started.
-
Import the Postman collection:
- Open Postman.
- Click on
Import
and select theRebound.postman_collection.json
file.
-
Use the endpoints:
Create
: Create a new simulation.Load
: Load an existing simulation.Add primary body
: Add a primary body to the simulation.Add object
: Add a secondary body to the simulation.Add from orbital elements
: Add a body using orbital elements.Integrate
: Integrate the simulation to a specified time.Get trajectory
: Retrieve the trajectory of bodies over a specified period.
To compile the project using PyInstaller:
-
Install PyInstaller:
pip install pyinstaller
-
Create a .spec file:
The
.spec
is different for each project. To create a new one, run (Note that you will need to change the path to the the librebound binaries):pyinstaller api.py --onefile --name Rebound --icon icon.ico --add-binary PATH_TO_CONDA/envs/rebound/Lib/site-packages/librebound.cp312-###.pyd:. --add-data src/:.
The executable will be created in the
dist
directory. For future compilations, you can use the generated.spec
by running:pyinstaller Rebound.spec
REBOUND is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
REBOUND is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with REBOUND. If not, see http://www.gnu.org/licenses/.