pyastroapi.api.http

Module Contents

Functions

get(→ HttpResponse)

Perform a HTTP Get request

post(→ HttpResponse)

Perform a HTTP Post request

put(→ HttpResponse)

Perform a HTTP Put request

delete(→ HttpResponse)

Perform a HTTP Delete request

post_bibcodes(→ HttpResponse)

Perform a HTTP Post request with a list of bibcodes

bigquery_bibcodes(→ HttpResponse)

Perform a ADS Big query with a list of bibcodes

download_file(url, filename)

Download a file to filename

pyastroapi.api.http.get(token: str, url: str, data: Payload_t = None, json: bool = True) HttpResponse

Perform a HTTP Get request

Parameters:
  • token (str) – ADS Token

  • url (str) – URL to get. This should usually include some sort of extra identifier

  • data (Payload_t, optional) – Any additional data being passed, thats not in the URL. Defaults to None.

  • json (bool, optional) – Whether to return the data in a JSON compatible format. Defaults to True.

Return type:

HttpResponse

pyastroapi.api.http.post(token: str, url: str, data: Payload_t = None, params: Any = None, json: bool = True) HttpResponse

Perform a HTTP Post request

Parameters:
  • token (str) – ADS Token

  • url (str) – URL to post to

  • data (Payload_t, optional) – Data being sent. Defaults to None.

  • params (Payload_t, optional) – Data being sent via the url and not the post dict. Defaults to None.

  • json (bool, optional) – Whether to return the data in a JSON compatible format. Defaults to True.

Return type:

HttpResponse

pyastroapi.api.http.put(token: str, url: str, data: Payload_t) HttpResponse

Perform a HTTP Put request

Parameters:
  • token (str) – ADS Token

  • url (str) – URL to post to

  • data (Payload_t, optional) – Data being sent. Defaults to None.

Return type:

HttpResponse

pyastroapi.api.http.delete(token: str, url: str) HttpResponse

Perform a HTTP Delete request

Parameters:
  • token (str) – ADS Token

  • url (str) – URL to post to

Return type:

HttpResponse

pyastroapi.api.http.post_bibcodes(token: str, url: str, bibcodes: str | List[str], multi_bibs: bool = True) HttpResponse

Perform a HTTP Post request with a list of bibcodes

Parameters:
  • token (str) – ADS Token

  • url (str) – URL to post to

  • bibcodes (t.Union[str, t.List[str]]) – Either a single bibcode or a list of bibcodes

  • multi_bibs (bool) – Some end points care whether you use bibcode or bibcodes and thats not consistent with the actual number of bibcodes used

Return type:

HttpResponse

pyastroapi.api.http.bigquery_bibcodes(token: str, url: str, bibcodes: str | List[str], params: Any) HttpResponse

Perform a ADS Big query with a list of bibcodes

Parameters:
  • token (str) – ADS Token

  • url (str) – URL to post to

  • bibcodes (t.Union[str, t.List[str]]) – Either a single bibcode or a list of bibcodes

  • params (dict) – Extra params sent

Return type:

HttpResponse

pyastroapi.api.http.download_file(url: str, filename: str)

Download a file to filename

On return you should check if the file exists to see if it succeeded.

Parameters:
  • url (str) – URL to download from

  • filename (str) – Filename to save file to.

Raises:

FileDownloadFailed – _description_