GaiaAPIClient/gaiaapiclient/cone_search.py
2024-09-18 14:46:53 +03:00

26 lines
858 B
Python

# gaiaapiclient/cone_search.py
# send an api request with the coordinates and search radius in decimal degrees
# to the GaiaDBInterface server to fetch the GAIA sources
import requests
def query(ra, dec, radius):
url = "http://localhost:8000/gaiadb/cone_search"
params = {
'ra' : ra,
'dec' : dec,
'radius' : radius
}
response = requests.get(url, params=params)
try:
response.raise_for_status() # Ensure this is a method call
print(response.text) # Print the raw response text
return response.text # Return the raw response text
except requests.exceptions.HTTPError as http_err:
print(f"HTTP error occurred: {http_err}")
return None
except requests.exceptions.RequestException as req_err:
print(f"Request error occurred: {req_err}")
return None