https://github.com/james-firth/kanka-js
A Javascript wrapper for the Kanka.io API.
https://github.com/james-firth/kanka-js
api-wrapper async-await javascript js kanka
Last synced: 3 days ago
JSON representation
A Javascript wrapper for the Kanka.io API.
- Host: GitHub
- URL: https://github.com/james-firth/kanka-js
- Owner: James-Firth
- License: mit
- Created: 2018-09-30T14:33:55.000Z (over 6 years ago)
- Default Branch: development
- Last Pushed: 2023-10-03T22:27:49.000Z (over 1 year ago)
- Last Synced: 2025-05-09T06:48:39.529Z (7 days ago)
- Topics: api-wrapper, async-await, javascript, js, kanka
- Language: JavaScript
- Homepage: https://github.com/James-Firth/kanka-js
- Size: 21.5 KB
- Stars: 3
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Kanka JS
:warning: **OUT OF DATE/DEPRECATION WARNING:** I haven't had a chance to work with this for a long time now and there have been _many_ changes. Considering using this as inspiration for your own library instead of using it directly!
---
A wrapper for the Kanka API written in javascript.
This wrapper works with both async/await and Promises.
```js
const kanka = require('kanka');// First set your API token.
// Alternatively export the environmental variable KANKA_TOKEN="myToken"
const token = 'myAPIToken';
kanka.setToken(token);// Grab an individual campaign, or list all of them.
// NOTE: If you have a lot of campaigns (over 45) this version not work for you as I haven't implemented pagination.async function runExample(){
console.log("Start");
try {
let campaignList = await kanka.listCampaigns();
// Some types come back as Pages. For those types look at the data key
let campaignNames = campaignList.data.map(x => `"${x.name}"`);
console.log(`Campaign Names: ${campaignNames}\n`);let camp = await kanka.getCampaign(campaignList.data[0].id);
console.log(`Looking at Campaign: "${camp.name}"\n`);let characters = await camp.characters.get();
console.log(`Characters: ${characters.map(x => ' '+x.name)}\n`);let person = await camp.characters.get(characters[0].id);
let attributes = await person.attributes.get();
console.log(`Attributes for ${person.name}: ${attributes.map(x => x.name+': '+x.value+'\n')}\n`);let relations = await person.relations.get();
console.log(`Relations for ${person.name}: ${relations}\n`);let notes = await person.notes.get();
console.log(`Notes for ${person.name}: ${notes}\n`);let calendar = await camp.calendars.get();
console.log(`Calendars: ${calendar.map(x => ' '+x.name)}\n`);let events = await camp.events.get();
console.log(`Events: ${events.map(x => ' '+x.name)}\n`);} catch(e) {
throw e;
}
}runExample();
```