alercebroker / alerce_client

🐍 ALeRCE Python Client
https://alerce.readthedocs.io/en/latest/index.html
MIT License
7 stars 1 forks source link

Update client to use API with mongo functionalities #26

Open dirodriguezm opened 1 year ago

dirodriguezm commented 1 year ago

The client must be able to use the new mongo support on the API. An interface should be drafted and proposed to the team.

Interface proposals

1

from alerce.core import Alerce
alerce = Alerce()

query = Alerce.mongoquery(collection='detections')
query =  query.find({'oid' : 'ZTF1'})
query = query.sort('mjd')
query = query.limit(10)

detections = query.execute()

for detection in detections:
    print(detection)
ASHuenchuleo commented 1 year ago

For the interface, I think it's a good idea to just use the same JSON you would use for a curl request for simplicity:

from alerce.core import Alerce
alerce = Alerce()

query = {
"collection": "detections",
"filter": {
"oid": "ZTF1"
},
"sort": { "mjd": 1 },
"limit": 10
}
detections = Alerce.mongo_find(query, pandas=True)
ASHuenchuleo commented 1 year ago

The client must be able to send queries to this API following these steps

Should we validate the input in every verb or just let the program fail?