nasa_apis

Last updated:

0 purchases

nasa_apis Image
nasa_apis Images
Add to Cart

Description:

nasa apis

NASA APIs #






A wrapper for the NASA Open APIs with caching and helpful utilities for seamless integration. Provides an easy dart-specific way of working with the requests available and provides parsed responses, including configurable caching and management of data.
For information on NASA's APIs, see the documentation on NASA Open APIs.
This wrapper is not affiliated with NASA or their APIs in any capacity. It was created for our own usage and made public to support the open-source community.
Prerequisites #
NASA recommends that you signup for an API key if you expect heavy API usage, such as using the API in an app you are developing. Visit https://api.nasa.gov/ to get a free key.
Usage #
To use this plugin, add nasa_apis as a dependency in your pubspec.yaml file.
Examples #
Here are small examples that show you how to use the API. The examples provided do not show all of the API. Please review the documentation for additonal information.
All requests will return a tuple of data, with the first item being an integer HTTP response code, and the second will be the data items.
Configuration
Configure the plugin to use an API key, re-route logging, change caching durations, and more.
Nasa.init(
apiKey: "INSERT YOUR API KEY",
apodSupport: true,
apodCacheSupport: true,
apodDefaultCacheExpiration: const Duration(days: 90)
);
copied to clipboard
Astronomy Picture of the Day (APOD)
Review the documentation for an ApodItem for the fields of data. Generally the data will include a uuid, copyright, date, explanation, hdUrl, mediaType, serviceVersion, thumbnailUrl if video, title, and url.
Requests
Perform requests with the API to get the specified dates. If caching is enabled, all requests (except requestByRandom()) are cached, so re-requesting them will be faster and not count against the NASA API request limit.
Tuple2<int, ApodItem?> itemPair = await requestByDate(DateTime(2005, 9, 13));
...
Tuple2<int, List<ApodItem>?> itemPair = await requestByMonth(2012, 1);
...
const int count = 7;
Tuple2<int, List<ApodItem>?> itemsPair = await requestByRandom(count);
...
DateTime startDate = DateTime(2022, 10, 1);
DateTime endDate = DateTime(2022, 10, 7);
Tuple2<int, List<ApodItem>?> itemPair = await requestByRange(startDate, endDate);
copied to clipboard
Update and retrieve categories
Categories can be added to an item and saved. Categories can also be search for using a provided search function. The 'expiration' field in an ApodItem can be updated to a different expiration, or set to null to make persistent.
ApodItem apodItem = ...;
apodItem.categories.add("example");
apodItem.expiration = DateTime.now().add(const Duration(days: 3));
await updateItemCache(apodItem: apodItem);

List<ApodItem> items = await getCategory(category: "example");
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.