Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] allow searching for a list of object ID #291

Closed
JulienPeloton opened this issue Mar 21, 2022 · 0 comments · Fixed by #292
Closed

[API] allow searching for a list of object ID #291

JulienPeloton opened this issue Mar 21, 2022 · 0 comments · Fixed by #292

Comments

@JulienPeloton
Copy link
Member

The objects API only allows to query for one object at a time:

import requests
import pandas as pd

# get data for ZTF21aaxtctv
r = requests.post(
  'https://fink-portal.org/api/v1/objects',
  json={
    'objectId': 'ZTF21aaxtctv',
    'output-format': 'json'
  }
)

# Format output in a DataFrame
pdf = pd.read_json(r.content)

When we want to search for many candidates, we loop over on the client side. But this is inefficient (many communications between the client and the server), and it would be better to group all objectId in one query:

import requests
import pandas as pd

mylist = ['ZTF21aaxtctv', 'ZTF21abfmbix', 'ZTF21abfaohe']

# get data for many objects
r = requests.post(
  'https://fink-portal.org/api/v1/objects',
  json={
    'objectId': ','.join(mylist),
    'output-format': 'json'
  }
)

# Format output in a DataFrame
pdf = pd.read_json(r.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant