Giter VIP home page Giter VIP logo

nasa-api's Introduction

nasa provides a simple Python wrapper to interact with the NASA Data APIs. Full documentation for the APIs is available on NASA's site, and named parameters here are the same as there.

Installation

Install using pip:

pip install nasa-api-wrapper

If you'd like to contribute, feel free to run git clone on the Github repository:

git clone https://github.com/brendanv/nasa-api.git

Usage

Acquire an API key and set your API key as the NASA_API_KEY environment variable before using the API!

Supported APIs

Astronomy Picture of the Day

Receive images and metadata about NASA's current and past Astronomy Pictures of the Day. Just choose a date, and indicate if you'd like to receive the set of tags for the image along with your other data.

>>> from nasa import apod
>>> picture = apod.apod('2015-05-01')
>>> picture.url
'http://apod.nasa.gov/apod/image/1505/messengerImpactSite_black600.jpg'
>>> picture.title
"MESSENGER's Last Day on Mercury"

Earth Assets and Imagery

Fetch Landsat 8 images of any location on Earth! This consists of two distinct APIs: Assets that detail when a picture was taken of a given location, and the actual Imagery for that location and time.

You can use the Assets API to fetch images:

>>> from nasa import earth
>>> assets = earth.assets(lat=1.5, lon=100.75, begin='2014-02-01', end='2014-06-01')
>>> [(a.date, a.id) for a in assets]
[('2014-02-04T03:30:01', 'LC8_L1T_TOA/LC81270592014035LGN00'),
 ('2014-02-20T03:29:47', 'LC8_L1T_TOA/LC81270592014051LGN00'),
 ...
 ('2014-05-27T03:28:32', 'LC8_L1T_TOA/LC81270592014147LGN00')]

>>> image = assets[0].get_asset_image()
>>> image.id
'LC8_L1T_TOA/LC81270592014035LGN00"'
>>> image.image.__str__()
'<PIL.PngImagePlugin.PngImageFile image mode=RGB size=512x512>'

Or simply fetch the images directly:

>>> from nasa import earth 
>>> image = earth.image(lat=1.5, lon=100.75, date='2014-02-01')
>>> image.id
'LC8_L1T_TOA/LC81270592014035LGN00'

Patents

See what cool patents are held in the NASA patent portfolio using the Patents API.

>>> from nasa import patents
>>> patents = patents.patents(query='temperature', limit=5)
>>> [(p.id, p.category) for p in patents]
[('patent_MSC-24506-1', 'aeronautics'),
 ('patent_LEW-18761-1', 'materials and coatings'),
 ('patent_LEW-18561-1', 'materials and coatings'),
 ('patent_LEW-18949-1', 'materials and coatings'),
 ('patent_LAR-17681-1', 'materials and coatings')]

Sounds

Browse sounds released by NASA using the Sounds API.

>>> from nasa import sounds
>>> sounds = sounds.sounds(query='apollo')
>>> [(s.id, s.duration) for s in sounds]
[(181835738, 18365),
 (173578614, 30095),
 ...
 (172463116, 2429)]

Browse reports from the Mars Atmospheric Aggregation System

Easily get the latest report:

>>> from nasa import maas
>>> report = maas.latest()
>>> report.min_temp_fahrenheit
-110.2

Or multiple reports that match a given query:

>>> from nasa import maas
>>> reports = maas.archived(terrestrial_date_start='2012-10-01', terrestrial_date_end='2012-10-31')
>>> reports['count']
508
>>> [r.sol for r in reports['results']]
[84, 83, 82, 81, 80, 79, 78, 77, 76, 75]

# Get the next page of results
>>> paginator = reports['next']
>>> next_page = paginator()
>>> [r.sol for r in next_page['results']]
[74, 73, 72, 71, 70, 68, 67, 66, 65, 64]

archived takes keyword args that allow you to filter by most report fields available on the MAASReport.

nasa-api's People

Contributors

asmith26 avatar brendanv avatar dunkledore avatar dyson-yamashita avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.