xyz-angular-swapi
v0.1.0
Published
AngularJS wrapper to consume swapi.co API
Downloads
8
Readme
AngularJS service for Star Wars API
An AngularJS service wrapping Stars Wars API (swapi.co), inspired by SWAPI-Wrapper by Raymond Camden.
The service is completly promise oriented and offers access to swapi.co from AngularJS applications.
The xyz.angular.swapi
modules comes with one angular constant swapiEndpoints
, used internally by the main service swapiService
.
To use the service just import the module in your AngularJS application and inject the swapiService
whre required.
// include the module
angular.module('myStarWarsApp', ['xyz.angular.swapi']).
controller('jediController', ['swapiService',
function($scope, swapiService) {
// get luke skywalker data
swapiService.peope('1').
then(function(lukeData){
$scope.luke = lukeData;
});
}
])
<ul>
<li>Name: {{luke.name}}</li>
<li>Eyes color: {{luke.eye_color}}</li>
<li>Skin color: {{luke.skin_color}}</li>
</ul>
For any end-point exposed by swapi.com 3 methods are available:
- get specific resource by type and id
- get all resources for a given type
- get JSON Schema for a given type
Complete API, all methods return a promise.
film
film(id)
return one filmfilms([page])
return all films paginated. If no page is passed defaults to 1.filmSchema()
return the JSON Schema for thefilm
resource
people
person(id)
return one personpeople([page])
return all people paginated. If no page is passed defaults to 1.peopleSchema()
return the JSON Schema for thepeople
resource
planets
planet(id)
return one planetplanets([page])
return all planets paginated. If no page is passed defaults to 1.planetSchema()
return the JSON Schema for theplanet
resource
species
singleSpecies(id)
return one speciesspecies([page])
return all species paginated. If no page is passed defaults to 1.speciesSchema()
return the JSON Schema for thespecies
resource
starships
starship(id)
return one starshipstarships([page])
return all starships paginated. If no page is passed defaults to 1.starshipSchema()
return the JSON Schema for thestarship
resource
vehicles
vehicle(id)
return one vehiclevehicles([page])
return all vehicles paginated. If no page is passed defaults to 1.vehicleSchema()
return the JSON Schema for thevehicle
resource
Work in progress
An integration with the local storage has been already done but has external dependencies. Will be added as soon as we can remove all dependencies.