PHP Classes

NASA Near Earth Orbit API Client: Get near Earth orbit object data with NASA API

Recommend this page to a friend!
  Info   Example   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 58%Total: 194 All time: 8,546 This week: 78Up
Version License PHP version Categories
neowsclient 1.0.0MIT/X Consortium ...5.6PHP 5, Web services, Physics
Description 

Author

This class can get near Earth orbit object data with NASA API.

It can send HTTP requests to NASA Open API to retrieve several types of information about near Earth orbit objects.

Currently it can get information about object orbital data, distances, velocity, diameters, etc..

Innovation Award
PHP Programming Innovation award nominee
December 2016
Number 4


Prize: One subscription to the PDF edition of the PHP Architect magazine
Near Earth objects can be comets or asteroids that came of the outer space and have been attracted to the planet Earth.

NASA keeps track of these objects and makes the known information about them available via an API.

This way you may be informed of known near Earth objects that are coming close to the planet.

This class provides means to extract the known information of near Earth objects using this NASA API.

Manuel Lemos
Picture of Sergii Pryz
  Performance   Level  
Innovation award
Innovation award
Nominee: 5x

 

Example

<?php
namespace Picamator\NeoWsClient\Example;

/**
 * Resource: GET /rest/v1/stats
 */

require_once 'app.php';

use \
Picamator\NeoWsClient\Request\Data\StatisticsRequest;

/** @var \Picamator\NeoWsClient\Manager\Manager $manager */
$manager = $container->get('neo_ws_manager_statistics_manager');

// get response
$request = new StatisticsRequest();
$response = $manager->find($request);

/** @var \Picamator\NeoWsClient\Model\Api\Data\StatisticsInterface $data */
$data = $response->getData();

echo <<<EOT
=================================
        NEO Statistics
=================================

HTTP Code |
{$response->getCode()}
Api key limit |
{$response->getRateLimit()->getLimit()}
Api key remaining |
{$response->getRateLimit()->getRemaining()}


Close approach count |
{$data->getCloseApproachCount()}
Last updated |
{$data->getLastUpdated()->format('Y-m-d')}
NEO count |
{$data->getNeoCount()}
Source |
{$data->getSource()}
NASA JPL url |
{$data->getNasaJplUrl()}

EOT;


Details

NeoWsClient

PHP 7 ready Latest Stable Version License SensioLabsInsight

Master

Build Status Coverage Status

Dev

Build Status Coverage Status

NeoWsClient - client for NASA Open Api "Near Earth Object Web Service" or NeoWs in short. All NeoWs data is from the NASA JPL Asteroid team.

NeoWsClient supports NeoWs v1 with resources:

  • feed
  • neo
  • stats

Requirements

Installation

Update to your composer.json with:

{
    "require": {
        "picamator/neo-ws-client": "~1.0"
    }
}

Examples

To run examples please create parameters.yml in config directory using as a template parameters.yml.dist. The DEMO_KEY is a valid api token. It has limitation as requests per hour, per day. More information in NASA official documentation.

Example list:

Arbitrary precision math

NeoWsClient formats only Date to DateTime object all others keeps original API's. NeoWs uses string for long precision float like e.g. .6304873017364636 execution floatval on them would removes last two digits. Therefore NeoWsClient does not convert strings to int or float. To make any math with string floats please use BCMath. BCMath takes care of arbitrary precision mathematics.

Technical specification

That section describes extension and configuration points.

Dependency injection

NeoWsClient uses Symfony DI. It's configuration in services.yml.

Data mapping

NeoWsClient works with data mapping to create objects based on Api response. To make customization or build objects from API response it's need to create mapper repository object. Mapper repository object is a simple data storage over schema with implementation Mapper\Api\RespositoryInterface.

The schema contains:

Name | Is required | Description --- | --- | --- source | yes | Key in API response destination | yes | Property inside NeoWsClient value object destinationContainer | yes | Name of NeoWsClient object where destination property is located schema | no | Sub schema collectionOf | no | Interface name of NeoWsClient objects that will be present inside collection. It's an interface of destinationContainer in sub-schema. filter | no | Name of NeoWsClient filter object, it runs over API's data

Errors

There are three different error types:

  • Response HTTP codes: 401, 403, 404
  • Response HTTP code 200 with empty body
  • Exception

Response HTTP codes: 401, 403, 404

In case of getting HTTP codes: 401, 403, 404 or any unsuccessful one application return empty response. Empty response means valid Response object where:

  • code: is a http code
  • data: `stdClass` over body response string
  • rateLimit: valid rate limit object with data if they are present in API's header

Response HTTP code 200 with empty body

If API returns empty body with HTTP code 200 with several simultaneously requests. The NeoWsClient Manager rise exception ManagerException in that case. Because HTTP code 200 means OK, but body is wrong therefore NeoWsClient can not distinguish valid/invalid data by HTTP code.

That exception SHOULD be catch without putting any logic like resend, wait 3 sec. then resend again etc. Instead it's better to have cache over API.

Exception

The full exception list that NeoWsClient rises is in Exception folder. If exception rise it means that application can not proceed request, it does not have any business logic in it.

Documentation

Developing

To configure developing environment please:

  1. Follow Docker installation steps
  2. Run inside Docker container `composer install`

Contribution

If you find this project worth to use please add a star. Follow changes to see all activities. And if you see room for improvement, proposals please feel free to create an issue or send pull request. Here is a great guide to start contributing.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project and its community you agree to abide by those terms.

License

NeoWsClient is licensed under the MIT License. Please see the LICENSE file for details.


Screenshots (1)  
  • statistics.png
  Files folder image Files (147)  
File Role Description
Files folder imageconfig (2 files)
Files folder imagedev (3 directories)
Files folder imagedoc (2 directories)
Files folder imagesrc (8 directories)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file LICENSE.txt Lic. License
Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 99%
Total:194
This week:0
All time:8,546
This week:78Up
 User Ratings  
 
 All time
Utility:75%StarStarStarStar
Consistency:75%StarStarStarStar
Documentation:66%StarStarStarStar
Examples:66%StarStarStarStar
Tests:-
Videos:-
Overall:58%StarStarStar
Rank:1549