{"id":23835341,"url":"https://github.com/amirreza-jabbari/astronomy-api","last_synced_at":"2026-05-17T16:30:13.199Z","repository":{"id":267266383,"uuid":"900714145","full_name":"Amirreza-Jabbari/Astronomy-API","owner":"Amirreza-Jabbari","description":"The Astronomy API provides endpoints to retrieve data about celestial objects based on user-defined locations and date ranges. It leverages the Skyfield library for astronomical calculations.","archived":false,"fork":false,"pushed_at":"2025-01-26T10:16:20.000Z","size":30383,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T11:20:41.223Z","etag":null,"topics":["api-rest","astronomy-api","django-rest-framework"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Amirreza-Jabbari.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-09T10:37:41.000Z","updated_at":"2025-01-26T10:16:23.000Z","dependencies_parsed_at":"2025-01-26T11:30:18.395Z","dependency_job_id":null,"html_url":"https://github.com/Amirreza-Jabbari/Astronomy-API","commit_stats":null,"previous_names":["amirreza-jabbari/astronomy_api","amirreza-jabbari/astronomy-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amirreza-Jabbari%2FAstronomy-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amirreza-Jabbari%2FAstronomy-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amirreza-Jabbari%2FAstronomy-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amirreza-Jabbari%2FAstronomy-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Amirreza-Jabbari","download_url":"https://codeload.github.com/Amirreza-Jabbari/Astronomy-API/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240122574,"owners_count":19751142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-rest","astronomy-api","django-rest-framework"],"created_at":"2025-01-02T15:48:06.204Z","updated_at":"2026-05-17T16:30:13.155Z","avatar_url":"https://github.com/Amirreza-Jabbari.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\r\n---\r\n\r\n# Astronomy API Documentation\r\n\r\n## Table of Contents\r\n1. [Overview](#overview)\r\n2. [Installation](#installation)\r\n3. [API Endpoints](#api-endpoints)  \r\n   - [POST /api/astronomy/](#post-apiastronomy)  \r\n4. [Serializers](#serializers)\r\n5. [Views](#views)\r\n6. [Calculations](#calculations)\r\n7. [Example of Use](#example-of-use)\r\n8. [License](#license)\r\n9. [Get Location](#get-location)\r\n---\r\n\r\n## Overview\r\nThe Astronomy API provides endpoints to retrieve data about celestial objects based on user-defined locations and date ranges. It leverages the Skyfield library for astronomical calculations.\r\n\r\n---\r\n\r\n## Installation\r\nTo install the required packages, run:\r\n\r\n```bash\r\npip install -r requirements.txt\r\n```\r\n\r\n---\r\n\r\n## API Endpoints\r\n\r\n### POST `/api/astronomy/`\r\nRetrieve celestial object data based on JSON payload.\r\n\r\n**Request Body:**\r\n```json\r\n{\r\n  \"location\": {\r\n    \"latitude\": 38.775867,\r\n    \"longitude\": -84.39733,\r\n    \"elevation\": 0\r\n  },\r\n  \"date_range\": {\r\n    \"start_date\": \"2020-12-20T09:00:00-05:00\",\r\n    \"end_date\": \"2020-12-23T09:00:00-05:00\"\r\n  }\r\n}\r\n```\r\n\r\n---\r\n\r\n## Serializers\r\nThe serializers handle the validation and transformation of request and response data.\r\n\r\n### CelestialBodySerializer\r\n```python\r\nclass CelestialBodySerializer(serializers.ModelSerializer):\r\n    observations = ObservationSerializer(many=True)\r\n\r\n    class Meta:\r\n        model = CelestialBody\r\n        fields = ['id', 'name', 'observations']\r\n```\r\n\r\n### ObservationSerializer\r\n```python\r\nclass ObservationSerializer(serializers.ModelSerializer):\r\n    class Meta:\r\n        model = Observation\r\n        fields = ['date', 'distance_au', 'distance_km', 'altitude_degrees', 'azimuth_degrees', 'right_ascension_hours', 'declination_degrees', 'magnitude', 'elongation']\r\n```\r\n\r\n### ConstellationSerializer\r\n```python\r\nclass ConstellationSerializer(serializers.ModelSerializer):\r\n    class Meta:\r\n        model = Constellation\r\n        fields = ['id', 'name', 'short']\r\n```\r\n\r\n---\r\n\r\n## Views\r\nThe views handle incoming requests and return responses.\r\n\r\n```python\r\nclass AstronomyDataView(APIView):\r\n    permission_classes = [AllowAny]\r\n\r\n    def get(self, request):\r\n        # Handle GET request\r\n        pass\r\n\r\n    def post(self, request):\r\n        # Handle POST request\r\n        pass\r\n```\r\n\r\n---\r\n\r\n## Calculations\r\nThe calculations module uses Skyfield to compute celestial data.\r\n\r\n```python\r\nclass CelestialCalculator:\r\n    def __init__(self, latitude, longitude, elevation=0):\r\n        \"\"\"\r\n        Initialize Celestial Calculator with geographical location\r\n        \"\"\"\r\n        pass\r\n\r\n    def get_celestial_objects_data(self, start_date, end_date):\r\n        \"\"\"\r\n        Retrieve celestial object data for a given date range\r\n        \"\"\"\r\n        pass\r\n\r\n    def _calculate_object_details(self, obj_id, obj_data, dates):\r\n        \"\"\"\r\n        Calculate detailed observations for a celestial object\r\n        \"\"\"\r\n        pass\r\n\r\n    def get_constellation(self, ra, dec):\r\n        \"\"\"\r\n        Determine the constellation for given coordinates\r\n        \r\n        :param ra: Right Ascension in degrees\r\n        :param dec: Declination in degrees\r\n        :return: Constellation dictionary\r\n        \"\"\"\r\n        pass\r\n\r\n    def _calculate_moon_phase(self, t):\r\n        \"\"\"\r\n        Calculate the moon phase for a given time\r\n        \"\"\"\r\n        pass\r\n\r\n    def _ensure_timezone(self, date):\r\n        \"\"\"\r\n        Ensure the date is timezone-aware\r\n        \"\"\"\r\n        pass\r\n\r\n    def _generate_dates(self, start_date, end_date):\r\n        \"\"\"\r\n        Generate a list of dates from start to end\r\n        \"\"\"\r\n        pass\r\n```\r\n\r\n---\r\n\r\n## Example of Use\r\n\r\n### Example Request\r\n```bash\r\ncurl -X POST http://127.0.0.1:8000/api/astronomy/ \\\r\n-H \"Content-Type: application/json\" \\\r\n-d '{\r\n    \"location\": {\r\n        \"latitude\": 35.6824,\r\n        \"longitude\": 51.4158,\r\n        \"elevation\": 1156\r\n    },\r\n    \"date_range\": {\r\n        \"start_date\": \"2024-12-09\",\r\n        \"end_date\": \"2024-12-09\"\r\n    }\r\n}\r\n```\r\n\r\n### Example Response\r\n```json\r\n{\r\n    \"metadata\": {\r\n        \"dates\": {\r\n            \"from\": \"2024-12-09T00:00:00+00:00\",\r\n            \"to\": \"2024-12-09T00:00:00+00:00\"\r\n        },\r\n        \"observer\": {\r\n            \"location\": {\r\n                \"latitude\": 35.6824,\r\n                \"longitude\": 51.4158,\r\n                \"elevation\": 1156.0\r\n            }\r\n        }\r\n    },\r\n    \"celestial_objects\": [\r\n        {\r\n            \"id\": \"sun\",\r\n            \"name\": \"Sun\",\r\n            \"observations\": [\r\n                {\r\n                    \"date\": \"2024-12-09T00:00:00+00:00\",\r\n                    \"distance\": {\r\n                        \"au\": 0.9849299530333308,\r\n                        \"km\": 147343423.76243728\r\n                    },\r\n                    \"position\": {\r\n                        \"equatorial\": {\r\n                            \"right_ascension\": 17.062160011274038,\r\n                            \"declination\": -22.806012396742435\r\n                        },\r\n                        \"horizontal\": {\r\n                            \"altitude\": -42.331561819639916,\r\n                            \"azimuth\": 89.56092204488478\r\n                        }\r\n                    },\r\n                    \"constellation\": {\r\n                        \"id\": \"sco\",\r\n                        \"short\": \"Sco\",\r\n                        \"name\": \"Scorpius\"\r\n                    }\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"id\": \"moon\",\r\n            \"name\": \"Moon\",\r\n            \"observations\": [\r\n                {\r\n                    \"date\": \"2024-12-09T00:00:00+00:00\",\r\n                    \"distance\": {\r\n                        \"au\": 0.0024823007514765427,\r\n                        \"km\": 371346.9068579006\r\n                    },\r\n                    \"position\": {\r\n                        \"equatorial\": {\r\n                            \"right_ascension\": 23.51645870095422,\r\n                            \"declination\": -4.233145426825709\r\n                        },\r\n                        \"horizontal\": {\r\n                            \"altitude\": -39.812473857261594,\r\n                            \"azimuth\": 298.0038835352312\r\n                        }\r\n                    },\r\n                    \"constellation\": {\r\n                        \"id\": \"aqr\",\r\n                        \"short\": \"Aqr\",\r\n                        \"name\": \"Aquarius\"\r\n                    },\r\n                    \"moon_phase\": {\r\n                        \"moon_phase\": {\r\n                            \"phase\": \"First Quarter\",\r\n                            \"angle\": 94.60931385482792,\r\n                            \"percentage\": 8.036095708407135\r\n                        }\r\n                    }\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"id\": \"mercury\",\r\n            \"name\": \"Mercury\",\r\n            \"observations\": [\r\n                {\r\n                    \"date\": \"2024-12-09T00:00:00+00:00\",\r\n                    \"distance\": {\r\n                        \"au\": 0.6930993705301217,\r\n                        \"km\": 103686190.01481654\r\n                    },\r\n                    \"position\": {\r\n                        \"equatorial\": {\r\n                            \"right_ascension\": 16.59945872902403,\r\n                            \"declination\": -19.827801372608217\r\n                        }\r\n                    },\r\n                    \"constellation\": {\r\n                        \"id\": \"sco\",\r\n                        \"short\": \"Sco\",\r\n                        \"name\": \"Scorpius\"\r\n                    }\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"id\": \"venus\",\r\n            \"name\": \"Venus\",\r\n            \"observations\": [\r\n                {\r\n                    \"date\": \"2024-12-09T00:00:00+00:00\",\r\n                    \"distance\": {\r\n                        \"au\": 0.9178243142371275,\r\n                        \"km\": 137304563.08656195\r\n                    },\r\n                    \"position\": {\r\n                        \"equatorial\": {\r\n                            \"right_ascension\": 20.298309566164523,\r\n                            \"declination\": -22.102228101020504\r\n                        }\r\n                    },\r\n                    \"constellation\": {\r\n                        \"id\": \"cap\",\r\n                        \"short\": \"Cap\",\r\n                        \"name\": \"Capricornus\"\r\n                    }\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"id\": \"mars\",\r\n            \"name\": \"Mars\",\r\n            \"observations\": [\r\n                {\r\n                    \"date\": \"2024-12-09T00:00:00+00:00\",\r\n                    \"distance\": {\r\n                        \"au\": 0.7565068605161593,\r\n                        \"km\": 113171815.50315933\r\n                    },\r\n                    \"position\": {\r\n                        \"equatorial\": {\r\n                            \"right_ascension\": 8.595719041799386,\r\n                            \"declination\": 21.644016435122452\r\n                        }\r\n                    },\r\n                    \"constellation\": {\r\n                        \"id\": \"cnc\",\r\n                        \"short\": \"Cnc\",\r\n                        \"name\": \"Cancer\"\r\n                    }\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"id\": \"jupiter\",\r\n            \"name\": \"Jupiter\",\r\n            \"observations\": [\r\n                {\r\n                    \"date\": \"2024-12-09T00:00:00+00:00\",\r\n                    \"distance\": {\r\n                        \"au\": 4.090419171635449,\r\n                        \"km\": 611917998.3471209\r\n                    },\r\n                    \"position\": {\r\n                        \"equatorial\": {\r\n                            \"right_ascension\": 4.9739276965380546,\r\n                            \"declination\": 22.0109297809184\r\n                        }\r\n                    },\r\n                    \"constellation\": {\r\n                        \"id\": \"tau\",\r\n                        \"short\": \"Tau\",\r\n                        \"name\": \"Taurus\"\r\n                    }\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"id\": \"saturn\",\r\n            \"name\": \"Saturn\",\r\n            \"observations\": [\r\n                {\r\n                    \"date\": \"2024-12-09T00:00:00+00:00\",\r\n                    \"distance\": {\r\n                        \"au\": 9.659854141176211,\r\n                        \"km\": 1445093610.7925384\r\n                    },\r\n                    \"position\": {\r\n                        \"equatorial\": {\r\n                            \"right_ascension\": 22.997041813567634,\r\n                            \"declination\": -8.62474072674412\r\n                        }\r\n                    },\r\n                    \"constellation\": {\r\n                        \"id\": \"aqr\",\r\n                        \"short\": \"Aqr\",\r\n                        \"name\": \"Aquarius\"\r\n                    }\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"id\": \"uranus\",\r\n            \"name\": \"Uranus\",\r\n            \"observations\": [\r\n                {\r\n                    \"date\": \"2024-12-09T00:00:00+00:00\",\r\n                    \"distance\": {\r\n                        \"au\": 18.64708314086849,\r\n                        \"km\": 2789563932.639794\r\n                    },\r\n                    \"position\": {\r\n                        \"equatorial\": {\r\n                            \"right_ascension\": 3.4470254554384665,\r\n                            \"declination\": 18.52131616078166\r\n                        }\r\n                    },\r\n                    \"constellation\": {\r\n                        \"id\": \"tau\",\r\n                        \"short\": \"Tau\",\r\n                        \"name\": \"Taurus\"\r\n                    }\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"id\": \"neptune\",\r\n            \"name\": \"Neptune\",\r\n            \"observations\": [\r\n                {\r\n                    \"date\": \"2024-12-09T00:00:00+00:00\",\r\n                    \"distance\": {\r\n                        \"au\": 29.7128088481803,\r\n                        \"km\": 4444972936.203892\r\n                    },\r\n                    \"position\": {\r\n                        \"equatorial\": {\r\n                            \"right_ascension\": 23.83766552241007,\r\n                            \"declination\": -2.4717175903446402\r\n                        }\r\n                    },\r\n                    \"constellation\": {\r\n                        \"id\": \"aqr\",\r\n                        \"short\": \"Aqr\",\r\n                        \"name\": \"Aquarius\"\r\n                    }\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"id\": \"pluto\",\r\n            \"name\": \"Pluto\",\r\n            \"observations\": [\r\n                {\r\n                    \"date\": \"2024-12-09T00:00:00+00:00\",\r\n                    \"distance\": {\r\n                        \"au\": 35.867929168949665,\r\n                        \"km\": 5365765830.09329\r\n                    },\r\n                    \"position\": {\r\n                        \"equatorial\": {\r\n                            \"right_ascension\": 20.200341071055174,\r\n                            \"declination\": -23.3188836195693\r\n                        }\r\n                    },\r\n                    \"constellation\": {\r\n                        \"id\": \"cap\",\r\n                        \"short\": \"Cap\",\r\n                        \"name\": \"Capricornus\"\r\n                    }\r\n                }\r\n            ]\r\n        }\r\n    ]\r\n}\r\n```\r\n## License\r\n```markdown\r\nMIT License\r\n\r\nCopyright (c) 2024 Amirreza Jabbari\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n```\r\n## Get Location\r\nYou can get your  location information by using get_location.py in location folder.\r\n```bash\r\npip install -r location/requirements.txt\r\npython location/get_location.py\r\n```\r\n---\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famirreza-jabbari%2Fastronomy-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famirreza-jabbari%2Fastronomy-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famirreza-jabbari%2Fastronomy-api/lists"}