Request

class astrometry_net_client.request.PostRequest(*args, **kwargs)

Makes a POST request instead of the default GET request. It can be used as a mixin class, alongside other

Essentially replaces:
>>> r = Request(url, method='post', arguments...)
With
>>> r = PostRequest(url, arguments...)

For further usage see the Request class

class astrometry_net_client.request.Request(url: Optional[str] = None, method: str = 'get', data: Optional[dict] = None, settings: Optional[astrometry_net_client.settings.Settings] = None, **kwargs)

Class to make requests to the Astrometry.net API. Intended use mainly for extending / internal class usage.

Requests are made using the requests library, and is capable of making GET and POST requests (controlled by the method argument in the constructor).

Typical usage (makes a GET request):
>>> r = Request('some-url')
>>> response = r.make()

The constructor prepares the request, but does not yet make it. To send / make the request use the method: r.make().

For a POST request:
>>> r = Request('some-url', method='post', data=data, settings=settings)
>>> response = r.make()

where data and settings are both combined and wrapped into the ‘request-json’ form, but are split to allow for some general settings.

An alternative for not using the “method=’post’” is to use the PostRequest class

It is valid to omit specifying a url, if the subclass already has its own url attribute.

The internal _make_request() method can be used to extend the functionality of requests (e.g. AuthorizedRequest: by making sure the user is logged in).

Additional arguments specied in the constructor (which are not directly used in this class or any subclass) will be stored and passed to the request call.

The original response (as returned from the requests module call) is stored in the original_response attribute.

make() → Union[dict, bytes]

Send the actual request to the API. returns the response

This method is mainly for convenience, as to avoid the user unfriendly _make_request() method.

Returns

Type depends on the request which is being send. Can be a dict but also a binary file (e.g. when expecting a filts file).

Return type

response

astrometry_net_client.request.file_request(url: str) → bytes

Utility function which makes a request to url and gets a file in response.

Parameters

url (str) – URL to send the request to.

Returns

Return type

the binary contents of this file.

astrometry_net_client.request.fits_file_request(url: str) → astropy.io.fits.hdu.hdulist.HDUList

Make request to url and return a FITS file.

Makes a request to url and read the binary_fits response into an astropy fits file (astropy.io.fits.HDUList)

Parameters

url (str) – URL to send the request to.

Returns

Return type

an astropy fits file (astropy.io.fits.HDUList)