Skip to content

Snipy7374/nasa.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nasa.py

WIP

Demo

image

Requirements

aiohttp
aiofiles

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")

Currently supported NASA API endpoints

  • APOD (Astronomy picture of the day) - /planetary/apod - (all query parameters)

TODO

  • Add is_video property on AstronomyPicture (based on media_type)
  • Add support for the count query parameter on /planetary/apod endpoint to get multiple random image
  • Solve typing issues with typing.overloads on client.py
  • Support other endpoints
  • Add async client & methods
  • Add logging
  • Add docs :)
  • Add developing tools
  • Add workflows on github