NeoWs
NeoWs (Near Earth Object Web Service) is 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. Description from NASA API Portal.
SyncNeoWs
- class nasawrapper.neows.SyncNeoWs(api_key: str)
This class uses asynchronous programming syntax to make requests to the NeoWs web service and returns the API response.
Descriptions of the methods are from the NASA API Portal.
- property allowed_keys
Returns the allowed keys in list format.
- property api_key
Returns the API key.
- get_neo_browse() nasawrapper.neows.NeoWsBrowseResponse
Browse the overall Asteroid data-set.
Example
from nasawrapper import SyncNeoWs neows = SyncNeoWs("DEMO_KEY") result = neows.get_neo_browse() # this may take some time, # since the API's searching for all asteroids print(result)
- get_neo_feed(options: Dict[str, Any]) nasawrapper.neows.NeoWsFeedResponse
Retrieve a list of Asteroids based on their closest approach date to Earth. Here’s a list of the allowed keys:
Allowed Keys
Key
Type
Function
start_date
Sets a starting date for the asteroid search
end_date
Sets a ending date for the asteroid search
Example
from nasawrapper import SyncNeoWs from datetime import datetime neows = SyncNeoWs("DEMO_KEY") result = neows.get_neo_feed({ "start_date": datetime(2010, 2, 3), "end_date": datetime(2010, 2, 4) })
- get_neo_lookup(asteroid_id: int) nasawrapper.neows.Asteroid
Lookup a specific Asteroid based on its NASA JPL small body (SPK-ID) ID. Find more about this at https://ssd.jpl.nasa.gov/tools/sbdb_query.html to get the overall data-set of asteroids and their ids.
Example
from nasawrapper import SyncNeoWs neows = SyncNeoWs("DEMO_KEY") result = neows.get_neo_lookup(3542519) print(results)
- get_today_neo_feed() nasawrapper.neows.NeoWsFeedResponse
Retrieve a list of Asteroids based on today’s date in the current UTC.
Example
from nasawrapper import SyncNeoWs neows = SyncNeoWs("DEMO_KEY") result = neows.get_today_neo_feed() print(result)
AsyncNeoWs
- class nasawrapper.neows.AsyncNeoWs(api_key: str)
This class uses asynchronous syntax to make requests to the NeoWs web service and returns the API response.
Descriptions of the methods are from the NASA API Portal.
- property allowed_keys
Returns the allowed keys in list format.
- property api_key
Returns the API key.
- async get_neo_browse() nasawrapper.neows.NeoWsBrowseResponse
This function is a coroutine.
Browse the overall asteroid data-set.
Example
from nasawrapper import AsyncNeoWs from datetime import datetime import asyncio async def main(): neows = AsyncNeoWs("DEMO_KEY") result = await neows.get_neo_browse() print(result) loop = asyncio.get_event_loop() loop.run_until_complete(main())
- async get_neo_feed(options: Dict[str, Any]) nasawrapper.neows.NeoWsFeedResponse
This function is a coroutine.
Same this as
SyncNeoWs.get_neo_feed
, but with asynchronous syntax.Example
from nasawrapper import AsyncNeoWs from datetime import datetime import asyncio async def main(): neows = AsyncNeoWs("DEMO_KEY") result = await neows.get_neo_feed({ "start_date": datetime(2010, 2, 3), "end_date": datetime(2010, 2, 4) }) print(result) loop = asyncio.get_event_loop() loop.run_until_complete(main())
- async get_neo_lookup(asteroid_id: int) nasawrapper.neows.Asteroid
This function is a coroutine.
Lookup a specific asteroid based on its NASA JPL small body (SPK-ID) ID. Find more about this at https://ssd.jpl.nasa.gov/tools/sbdb_query.html or simply use
AsyncNeoWs.get_neo_browse
to get the overall data-set of asteroids and their ids.Example
from nasawrapper import AsyncNeoWs from datetime import datetime import asyncio async def main(): neows = AsyncNeoWs("DEMO_KEY") result = await neows.get_neo_lookup(3542519) print(result) loop = asyncio.get_event_loop() loop.run_until_complete(main())
- async get_today_neo_feed() nasawrapper.neows.NeoWsFeedResponse
This function is a coroutine.
Same this as
SyncNeoWs.get_today_neo_feed
, but with asynchronous syntax.Example
from nasawrapper import AsyncNeoWs from datetime import datetime import asyncio async def main(): neows = AsyncNeoWs("DEMO_KEY") result = await neows.get_today_neo_feed() print(result) loop = asyncio.get_event_loop() loop.run_until_complete(main())
NeoWsQueryBuilder
- class nasawrapper.neows.NeoWsQueryBuilder(api_key: str, options={})
Retrieve a list of Asteroids based on their closest approach date to Earth, just like
SyncNeoWs.get_neo_feed
, except by the fact that you are the person who will build the query.Example
from nasawrapper import NeoWsQueryBuilder from datetime import datetime builder = NeoWsQueryBuilder("DEMO_KEY") result = builder.set_start_date(datetime(2020, 2, 3)).set_end_date(datetime(2020, 2, 4)).get_feed() print(result)
- property api_key
Returns the API key.
- get_feed()
Make the request with the provided information.
- property options
Returns the options in dict format.
- set_end_date(end_date: datetime.datetime)
Set ‘end_date’ field to the options.
- set_start_date(start_date: datetime.datetime)
Set ‘start_date’ field to the options.