Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/franckldx/swapi-stream
Download data from https://swapi.co/ using a read stream.
https://github.com/franckldx/swapi-stream
Last synced: 5 days ago
JSON representation
Download data from https://swapi.co/ using a read stream.
- Host: GitHub
- URL: https://github.com/franckldx/swapi-stream
- Owner: franckLdx
- License: mit
- Created: 2016-11-13T11:26:53.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-24T21:07:46.000Z (over 6 years ago)
- Last Synced: 2024-10-30T07:07:30.449Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 91.8 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# swapi-stream
Download [swapi data](https://swapi.co/) using a read stream.
## Requirement
* Node >= 8.0.0 (swapi-stream 1.x works with node 6.0.0)
* To be fan of Star Wars## Installation
npm install --save swapi-stream## Usage
To get films list:
```javascript
const swapiStream = require('swapi-stream');
const result = swapiStream.get(swapiStream.FILMS);
result.on('data', data => console.log(data.title));
result.on('error', (error) => console.log('ERROR', error.toString()));
result.on('end', () => console.log('END'));
```
To get planets list:
```javascript
const swapiStream = require('swapi-stream');
const result = swapiStream.get(swapiStream.PLANETS);
result.on('data', data => console.log(data.title));
result.on('error', (error) => console.log('ERROR', error.toString()));
result.on('end', () => console.log('END'));
```## API
```javascript
const myStream = swapiStream.get();
```
__resourceName__ is mandatory. It's the resource name as defined [swapi data Rest API](https://swapi.co/documentation#root). Rather than typing the name, you can use swapiStream constants (like shown in above examples):
* FILMS
* PEOPLE
* PLANETS
* VEHICLES
* STARSHIPS
* SPECIES__swapiStream.get__ returns a stream emitting the regular events data, end and error. As it's a stream, it returns all entities of the resource. If this does not suit your need, you may prefer a module that returns entities page by page like [swapi-node](https://www.npmjs.com/package/swapi-node).