npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ne-swapi

v0.1.4

Published

an angular module for SWAPI

Readme

ne-swapi

an angular module for SWAPI

Get the Package

$ bower install ne-swapi --save or npm install ne-swapi --save

First Inject the Module as an App Dependency

$ angular.module('myApp', ['ne.swapi'])

Then Inject the swapi Service Into Your Components

controller usage:

angular.module('myApp')
.controller('starshipsController', function($scope, swapi) {
  swapi.starships.all()
  .then(function(starships) {
    $scope.starships = starships;
  });
});

route resolve usage:

angular.module('myApp')
.config(function($routeProvider) {
  $routeProvider
   .when('/starships', {
      templateUrl: 'starships.html',
      controller: 'starshipsController',
      resolve: {
        starships: function(swapi) {
          return swapi.starships.all();
        }
      }
    }
  });
});

Use It

ne-swapi provides one general purpose helper method:

  • swapi.get(url) gets the resource(s) at the given url

and the following 5 helper methods for each of the SWAPI endpoints (films, people, planets, species, starships, vehicles):

  • .all() returns a promise that resolves to all resources (not paginated)
    • sample: swapi.films.all()
  • .id(id) returns a promise that resolves to a specific resource (defaults to 1)
    • sample: swapi.people.id(5)
  • .get() returns a promise that resolves to the first page of resources
    • sample: swapi.planets.get()
  • .page(page) returns a promise that resolves to the nth page of resources (defaults to 1)
    • sample: swapi.species.page(3)
  • .schema() returns a promise that resolves to the resource schema
    • sample: swapi.starships.schema()

More Samples

swapi.get(url)

A wrapper for $http.get.

swapi.get('http://swapi.co/api/people/1/')
.then(function(person) {
  $scope.person = person; // {"name": "Luke Skywalker", "height": "172", ...}
});

swapi.vehicles.all()

swapi.vehicles.all()
.then(function(allVehicles) {
  $scope.vehicles = allVehicles; // {"count": 39, "results": [{"name": "Sand Crawler", ...} ...] ...}
});

swapi.films.id()

swapi.films.id(3)
.then(function(film) {
  $scope.film = film; // {"title": "Return of the Jedi", "episode_id": 6, ...}
});

swapi.people.get()

swapi.people.get()
.then(function(people) {
  $scope.people = people; // {"count": 82, "next": "http://swapi.co/api/people/?page=2", ...}
});

swapi.people.page()

swapi.people.page(3)
.then(function(people) {
  $scope.people = people; // {"count": 82, "next": "http://swapi.co/api/people/?page=4", ...}
});

swapi.species.schema()

swapi.species.schema()
.then(function(speciesSchema) {
  $scope.schema = speciesSchema; // {"required": ["name", "height", "mass", ...] ...}
});

chaining

since all methods return promises, you can chain calls:

swapi.films.id(2)
.then(function(film) {
  return swapi.get(film.characters[0]);
})
.then(function(person) {
  return swapi.get(person.vehicles[1]);
})
.then(function(vehicle) {
  $scope.vehicle = vehicle;
})
.catch(function(error) {
  //any error in the chain will fall through to here and skip subsequent .then calls
})