Go client for the Kanka API

kanka

PkgGoDev Build Status Coverage Status Go Report Card

Manage your Kanka campaign or build tools for other creators with the thoroughly tested and documented kanka package.

The kanka package provides a client to handle all communication with the Kanka API.

The package is structured into convenient and discoverable services for managing characters, locations, organizations, events, and much more.

Installation

If you do not have Go installed yet, you can find installation instructions here.

To pull the most recent version of kanka, use go get.

go get github.com/Henry-Sarabia/kanka

Then import the package into your project as you normally would.

import "github.com/Henry-Sarabia/kanka"

Usage

Creating A Client

To use the kanka package, you need a Kanka API key. If you do not have a key yet, you can follow the instructions here to get one.

Create a client with your API key to start communicating with the Kanka API.

c, err := kanka.NewClient("YOUR_API_KEY", nil)

If you need to use a preconfigured HTTP client, simply pass its address to the NewClient function.

c, err := kanka.NewClient("YOUR_API_KEY", &custom)

Services

The client contains a separate service for working with each of the Kanka API endpoints. Each service has a set of functions to retrieve, list, create, update, or delete campaign data.

To start communicating with the Kanka API, choose a service and call one of its functions.

Take the Campaigns service for this example.

To retrieve a list of the current user's campaigns, use the Index function.

cmps, err := c.Campaigns.Index()

You now have access to a list of the user's campaigns via cmps.

Retrieving An Entity

To retrieve a specific entity from a campaign, use the Get function.

Take the Quests service for example.

For this service, Get requires a campaign ID and quest ID.

qst, err := c.Quests.Get(cmpID, qstID)

The result is stored in qst of type Quest.

Retrieving A List Of Entities

To retrieve a list of a campaign's entities of a certain type, use the Index function.

Take Locations for example.

For this service, Index requires only a campaign ID.

locs, err := c.Locations.Index(cmpID, nil)

If you want to limit the results to only the locations that have been updated since a specific time, provide that time to the Index function.

t := time.Date(2019, time.November, 4, 11, 0, 0, 0, time.UTC)

locs, err := c.Locations.Index(cmpID, t)

The result is stored in locs of type []Location.

Creating An Entity

To create a new entity, use the Create function.

Take Characters for example.

For this service, Create requires a campaign ID and the data for the new character in the form of type SimpleCharacter.

ch := SimpleCharacter{
    Name: "Daenerys Targaryen",
    Sex: "Female",
    Title: "Mother of Dragons",
}

_, err := c.Characters.Create(cmpID, ch)

The Create functions return the newly created entity back to the caller.

This example simply discards the value.

Updating An Entity

To update an existing entity, use the Update function.

Take Items for example.

For this service, Update requires a campaign ID, an item ID, and the data for the new item in the form of type SimpleItem.

item := SimpleItem{
    Name: "Bag of Holding",
    Size: "15 pounds",
    Price: "300 gold",
}

_, err := c.Items.Update(cmpID, item)

The Update functions return the updated entity back to the caller.

This example simply discards the value.

Deleting An Entity

To delete an entity, use the Delete function.

Take Journals for example.

For this service, Delete requires a campaign ID and a journal ID.

err := c.Journals.Delete(cmpID, jrnID)

Rate Limits, Errors, And You

The Kanka API is rate limited. For the most accurate and updated information, please visit the Kanka documentation.

If one of your requests to the Kanka API fails due to the rate limit or other temporary reason, the error returned can be asserted for the Temporary behavior.

For more information about temporary errors, please visit Dave Cheney's blog.

Contributions

If you would like to contribute to this project, please adhere to the following guidelines.

  • Submit an issue describing the problem.
  • Fork the repo and add your contribution.
  • Add appropriate tests.
  • Run go fmt, go vet, and golint.
  • Prefer idiomatic Go over non-idiomatic code.
  • Follow the basic Go conventions found here.
  • If in doubt, try to match your code to the current codebase.
  • Create a pull request with a description of your changes.
Owner
Henry Sarabia
I have a BS in CS at CSU Fresno. I am a full stack developer who primarily works in Go and TypeScript with React and Vue to develop web applications and APIs.
Henry Sarabia
Similar Resources

Client-server-golang-sqs - Client Server with SQS and golang

Client Server with SQS and golang Multi-threaded client-server demo with Go What

Feb 14, 2022

Go Client Library for Amazon Product Advertising API

go-amazon-product-advertising-api Go Client Library for Amazon Product Advertising API How to Use go get -u github.com/ngs/go-amazon-product-advertisi

Sep 27, 2022

A Go client library for the Twitter 1.1 API

Anaconda Anaconda is a simple, transparent Go package for accessing version 1.1 of the Twitter API. Successful API queries return native Go structs th

Jan 1, 2023

Go client library for interacting with Coinpaprika's API

Coinpaprika API Go Client Usage This library provides convenient way to use coinpaprika.com API in Go. Coinpaprika delivers full market data to the wo

Dec 8, 2022

Golang client for ethereum json rpc api

Ethrpc Golang client for ethereum JSON RPC API. web3_clientVersion web3_sha3 net_version net_peerCount net_listening eth_protocolVersion eth_syncing e

Jan 7, 2023

Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://developer.github.com/v4/).

githubv4 Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://docs.github.com/en/graphql). If you're looking for a client

Dec 26, 2022

📟 Tiny utility Go client for HackerNews API.

go-hacknews Tiny utility Go client for HackerNews API. Official Hackernews API Install go get github.com/PaulRosset/go-hacknews Usage Few examples a

Sep 27, 2022

A golang client for the Twitch v3 API - public APIs only (for now)

go-twitch Test CLIENT_ID="my client ID" go test -v -cover Usage Example File: package main import ( "log" "os" "github.com/knspriggs/go-twi

Sep 27, 2022

Go Client for the Unsplash API

Unsplash API client A wrapper for the Unsplash API. Unsplash provides freely licensed high-resolution photos that can be used for anything. Documentat

Dec 30, 2022
Comments
  • Incorrect test cases for Entity services

    Incorrect test cases for Entity services

    One case (Status OK, valid response, invalid entID) from two service functions (Create andUpdate) are not correctly testing for an invalid entID.

    The following services are affected from the same or similar bug:

    • Attributes
    • EntityEvents
    • EntityInventories
    • EntityNotes
    • EntityTags
    • Relations
  • Implement request retry functionality

    Implement request retry functionality

    The Kanka API allows 30 request per minute (increased to 90 for Patreons). Kanka will throttle a user's requests if they exceed this limit.

    A retry option should be implemented into the Client so a user can opt into automatically retrying their requests in the event of receiving a 421 or 429 HTTP response code.

  • Incorrect documentation for compound-word services

    Incorrect documentation for compound-word services

    Services with names comprised of compound words have grammatical errors in their type's documentation.

    The following services are affected with the same or similar errors:

    • EntityEvent
    • EntityInventory
    • EntityNote
    • EntityTag
    • MapPoint
    • QuestCharacter
A Go client implementing a client-side distributed consumer group client for Amazon Kinesis.
A Go client implementing a client-side distributed consumer group client for Amazon Kinesis.

Kinesumer is a Go client implementing a client-side distributed consumer group client for Amazon Kinesis.

Jan 5, 2023
Nutanix-client-go - Go client for the Nutanix Prism V3 API

nutanix-client-go This repository contains portions of the Nutanix API client code in nutanix/terraform-provider-nutanix. It has been extracted to red

Jan 6, 2022
Go client for the YNAB API. Unofficial. It covers 100% of the resources made available by the YNAB API.

YNAB API Go Library This is an UNOFFICIAL Go client for the YNAB API. It covers 100% of the resources made available by the YNAB API. Installation go

Oct 6, 2022
An API client for the Notion API implemented in Golang

An API client for the Notion API implemented in Golang

Dec 30, 2022
A Wrapper Client for Google Spreadsheet API (Sheets API)

Senmai A Wrapper Client for Google Spreadsheet API (Sheets API) PREPARATION Service Account and Key File Create a service account on Google Cloud Plat

Nov 5, 2021
Simple-Weather-API - Simple weather api app created using golang and Open Weather API key
Simple-Weather-API - Simple weather api app created using golang and Open Weather API key

Simple Weather API Simple weather api app created using golang and Open Weather

Feb 6, 2022
Client for the cloud-iso-client

cloud-iso-client Client for the cloud-iso-client. Register an API token Before using this client library, you need to register an API token under your

Dec 6, 2021
Go-http-client: An enhanced http client for Golang
Go-http-client: An enhanced http client for Golang

go-http-client An enhanced http client for Golang Documentation on go.dev ?? This package provides you a http client package for your http requests. Y

Jan 7, 2023
Aoe4-client - Client library for aoe4 leaderboards etc

AOE4 Client Overview This is a go client used to query AOE4 data from either the

Jan 18, 2022
Balabola-go-client - GO client for Yandex balabola service

Balabola GO Client GO client for Yandex balabola service Yandex warning The neur

Jan 29, 2022