Features

Python Objects

Successful Skynet API responses return a JSON object containing key, value pairs of information. The skynetapi library automatically converts the response to a Python object with snake case attributes. This is handled in the Serializable class.

# Response without using skynatapi
response = ...
response = response.json()

# Get the id, name, and time account information
obs_id = response['obs']['id']
obs_name = response['obs']['name']
obs_ta = response['obs']['timeAccountId']

print(type(obs))  # output: <class 'Dict'>

I've thought about making classes for each API endpoint (e.g., Observation, Exposure, etc.). Each class would inherit from Serializable but would then have its own distinguishable type. This would also allow for more flexibility with handling each request. Since Serializable is completely general, you lose some flexibility to handle any unique or special cases.

However, the benefit of using a single Serializable class is that it handles every case and every endpoint. Even if the endpoints change, are added, or removed, it will still handle every case. This is very nice from a development point so this is what I went with. If there's a desire from users to change create a class for each endpoint, then I would definitely consider it.

Snake Case

Fields in the Skynet database are defined using camel case. It's standard to use snake case with Python and it always bugs me when I have to mix cases. The skynetapi library allows users to define the request parameters in snake case or camel case and will convert it to camel case (if needed) before sending the request.

Last updated