Quickstart#
Installation#
With PyPi
pip install -U nasasync
With git
pip install git+https://github.com/Snipy7374/nasa.py
Requirements#
aiohttp
aiofiles
requests
Basic usage#
Create a client object
import typing as t
from nasa import NasaSyncClient
if t.TYPE_CHECKING:
from nasa import AstronomyPicture
client = NasaSyncClient(token="TOKEN_HERE")
get the todays astronomy picture
astronomy_picture: AstronomyPicture = client.get_astronomy_picture()
save an image
astronomy_picture.image.save("image.png")
This library also supports Async requests
import typing as t
from nasa import NasaAsyncClient
if t.TYPE_CHECKING:
from nasa import AstronomyPicture
client = NasaAsyncClient(token="TOKEN_HERE")
async def main():
async with client:
astronomy_picture: AstronomyPicture = await client.get_astronomy_picture()
await astronomy_picture.image.save("image.png")