Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sidhantpanda/xkcd-api
An API wrapper to fetch xkcd comics
https://github.com/sidhantpanda/xkcd-api
api cli nodejs
Last synced: 23 days ago
JSON representation
An API wrapper to fetch xkcd comics
- Host: GitHub
- URL: https://github.com/sidhantpanda/xkcd-api
- Owner: sidhantpanda
- License: mit
- Created: 2016-08-02T06:34:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T19:26:26.000Z (almost 2 years ago)
- Last Synced: 2024-04-13T21:58:03.932Z (7 months ago)
- Topics: api, cli, nodejs
- Language: JavaScript
- Homepage:
- Size: 43.9 KB
- Stars: 11
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# xkcd-api
An API wrapper and CLI tool to fetch xkcd comics.```
$ npx xkcd-api
``````
$ npm install xkcd-api
``````javascript
$ var xkcd = require('xkcd-api');
```### APIs available
* [Get the latest comic](#get_latest)
* [Get a particular comic](#get_comic)
* [Get a random comic](#get_random)### CLI equivalent
* [Get the latest comic](#get_latest_cli)
* [Get a particular comic](#get_comic_cli)
* [Get a random comic](#get_random_cli)### Get the latest comic
```javascript
xkcd.latest(function(error, response) {
if (error) {
console.error(error);
} else {
console.log(response);
}
});
```### Get a particular comic
```javascript
xkcd.get('comic-id', function(error, response) {
if (error) {
console.error(error);
} else {
console.log(response);
}
});
```### Get a random comic
```javascript
xkcd.random(function(error, response) {
if (error) {
console.error(error);
} else {
console.log(response);
}
});
```## CLI Features
Please make sure you've installed the package globally or are running it with npx.### Get the latest comic (CLI)
```
xkcd-api
xkcd-api -l
xkcd-api --latest
```### Get a particular comic (CLI)
```
xkcd-api -n 1714
xkcd-api --number 1714
```### Get a random comic (CLI)
```
xkcd-api -r
xkcd-api --random
```---
### Contributors
[Štefan Jarina](https://github.com/stefanjarina)[justchen1369](https://github.com/justchen1369)
---
### Submit issues
You can raise an issue in this repo or mail me at [email protected]