Skip to main content

A wrapper for NASA APIs

Project description

Warnings

This library is an alpha release yet, maybe there are some bugs, please report them to issues page.

Credits

Every API used in this library is avaliable on NASA API portal. This is just a simple wrapper to fetch their APIs and this library does not have any relationship to NASA, every issue/suggestion should be reported on the issues page.
The documentation provided on this readme has inspiration on the documentation provided on the NASA API portal about their APIs.

Instalation

You can install this package by PIP using the following command:

pip install nasawrapper

Updating package

Updating package using PIP:

pip install --upgrade nasawrapper

Documentation

APOD

This API has the following description in their website: "Each day a different image or photograph of our fascinating universe is featured, along with a brief explanation written by a professional astronomer.".
The class responsable for this API is Apod, which you have to instantiate with an api key (learn how to get here).
Example:

from nasawrapper import Apod

apod = Apod("your-api-key")

This class has only one method which make the request to the API, called get_apod. For using it, you have to provide a single parameter (a dict) with some keys with the information you want to use to make the request. Avaliable keys are:

Parameter Function Type
date The date of the APOD image to retrieve datetime.datetime
start_date The start of a date range, when requesting date for a range of dates. Cannot be used with date . Also, can not be before Jun 16, 1995. datetime.datetime
end_date The end of the date range, when used with start_date. Can not be used without start_date and can not be after start_date. datetime.datetime
count If this is specified then count randomly chosen images will be returned. Cannot be used with date or start_date and end_date. int
thumbs Return the URL of video thumbnail. If an APOD is not a video, this parameter is ignored. bool

You can not provide any other parameters, or an error will be thrown.
Examples:

from nasawrapper import Apod
from datetime import datetime

apod = Apod("your-api-key")

# fetching data between two dates
print(apod.get_apod({
    "start_date": datetime(year=2020, month=10, day=10),
    "end_date": datetime(year=2020, month=10, day=11),
    "thumbs": True
}))

# fetching specific number of data
print(apod.get_apod({
    "count": 5
}))

# fetching data from specific date
print(apod.get_apod({
    "date": datetime(year=2020, month=10, day=12)
}))

NeoWs

The NASA API portal describes this API as "a RESTful web service for near earth Asteroid information. With NeoWs a user can: search for Asteroids based on their closest approach date to Earth, lookup a specific Asteroid with its NASA JPL small body id, as well as browse the overall data-set.".

The class responsable for this API is NeoWs, which you also must instantiate with an API key (learn how to get it here). Examples:

from nasawrapper import NeoWs

neows = NeoWs("your-api-key")

Neo - Feed

This endpoint, acording to the NASA API portal returns a list of asteroids based on their closest approach date to Earth.

The class responsable for this API has a method called get_neo_feed. To use it correctly, you should provide a dict with, at least, a 'start_date' to make the request. The avaliable keys are:

Parameter Function Type
start_date Starting date for asteroid search datetime.datetime
end_date Ending date for asteroid search. The limit is 7 days from the 'start_date' and it is set to 7 days from 'start_date' by default. datetime.datetime

Examples:

from nasawrapper import NeoWs
from datetime import datetime

neows = NeoWs("your-api-key")

# fetching from a start_date 
print(neows.get_neo_feed({
    "start_date": datetime(year=2020, month=1, day=10)
}))

# specifying the end_date
print(neows.get_neo_feed({
    "start_date": datetime(year=2020, month=1, day=10),
    "end_date": datetime(year=2020, month=1, day=11)
}))

Neo - Lookup

  • TODO

Neo - Browse

  • TODO

Where can I get an API key

To get an API key, access the NASA API portal and click on "Generate API key". Then, provide your First Name, Last Name, Email and, if you would like to, an Application URL (this parameter is optional).

After clicking on "Signup", you should receive an email on the email address provided with your API key. Then you are ready to use your API key acording to the rate limit (hourlt limit for API keys is 1000 requests).

You can also use a DEMO_KEY instead a real API key, however, it has more restricted limits (30 requests per IP address per hour and 50 requests per IP address per day).

Why you shouldu use this wrapper

  • More readable code;
  • No long URLs;
  • You have absolutely sure about the output: if the code runs without any errors, the output will be the API response about what you want.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nasawrapper-0.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nasawrapper-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file nasawrapper-0.1.0.tar.gz.

File metadata

  • Download URL: nasawrapper-0.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.6

File hashes

Hashes for nasawrapper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 075ca6e799a719a5ca1297a0411d4eafb736de683908ffe3ac6805c5252523dc
MD5 e5c2a25e16fc132065aa721bdf2565db
BLAKE2b-256 bc442c86267f0486df291d8e4f29e5f8ee76dd3393907677b2023de58da1c619

See more details on using hashes here.

File details

Details for the file nasawrapper-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nasawrapper-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.6

File hashes

Hashes for nasawrapper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d13badb9077c3aad9fdb1f75a63e8f76f39ede127e87f02f522e0166bfdf69e4
MD5 eb90cbb5b50cb9a2dad956b9d4a67da6
BLAKE2b-256 b21f7d73636a12d0f10676df4a9ba377920d9f37a1f2f9a288e2194f79eea875

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page