Giter Site home page Giter Site logo

tposney / kanka-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from james-firth/kanka-js

0.0 1.0 0.0 19 KB

A Javascript wrapper for the Kanka.io API.

Home Page: https://github.com/James-Firth/kanka-js

License: MIT License

JavaScript 100.00%

kanka-js's Introduction

Kanka JS

A wrapper for the Kanka API written in javascript.

This wrapper works with both async/await and Promises.

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();

kanka-js's People

Contributors

james-firth avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.