Interfaces

There are four endpoint-specific interfaces and a generic request interface. Each interface handles the formatting, request sending, and responses for the user. The user only needs to know the parameters for their request object.

Observation Request Interface

The observation interface, defined in skynetapi/requests/obs_request.py, has five methods:

Method
Description

Add

Adds a single observation with the provided observation parameters

Update

Updates a single observation with the provided ID and parameters

Cancel

Cancels a single observation with the provided ID

Get

Returns a single observation object matching the provided criteria

Search

Returns a list of observation IDs matching the provided criteria

Example Usage

from skynetapi import ObservationRequest

obs_request = ObservationRequest(token='your_skynet_api_token')

params = {
    'name': 'api-test',
    'mode': 1,
    'timeAccountId': 456,
    'targetTracking': 'track_target',
    'raHours': 12.,
    'decDegs': 40.,
    'minEl': 20,
    'maxSun': -18,
    'minMoonSepDegs': 0,
    'exps': json.dumps(
                [dict(
                    expLength=5,
                    filterRequested='R',
                    telescopeRequested='Morehead')
                ]
            )
}

obs = obs_request.add(**params)

print(obs.id, obs.name)        # output: '1234567', 'api-test'
print(obs.exps[0].exp_length)  # output: 5

Exposure Request Interface

The exposure interface, defined in skynetapi/requests/exps_request.py, has five methods:

Method
Description

Add

Adds a single exposure to the provided observation

Update

Updates a single exposure with the provided ID and parameters

Cancel

Cancels a single exposure with the provided ID

Get

Returns a single exposure object matching the provided criteria

Search

Returns a list of exposure IDs matching the provided criteria

Download Request Interface

The download interface, defined in skynetapi/requests/dl_request.py, has four methods:

By default, the download requests return the filename and byte string representation of the requested file. Optionally, the user can pass in an out_dir argument to automatically decode the the byte string and save the file to the specified directory. This will return the file path to the saved image.

Generic Request Interface

The HTTPRequest allows for requests to any endpoint in the Skynet API, including those that already have specific interfaces. In fact, all of the interfaces described above inherit from the HTTPRequest class and simply call the request method within it.

The point of this interface is to allow the user to make any request that they need, even if there isn't a specific interface for the needed endpoint. It also formats the request, handles the server response and transforms it into a Python object.

All the user needs to know is the token, method, endpoint, and desired keyword arguments.

Example Usage

Last updated