Trello API wrapper for Go
Switch branches/tags
Clone or download
adlio Merge pull request #21 from mangelajo/customFields
Add basic support for CustomFields
Latest commit e4cc07c Oct 9, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
testdata Merge pull request #21 from mangelajo/customFields Oct 9, 2018
.gitignore Expands .gitignore. Sep 26, 2016
.travis.yml Deprecates support for Go 1.4-1.6. Mar 10, 2018
LICENSE Initial commit Sep 24, 2016
README.md Add IDLabels to the README Mar 20, 2018
TODO.txt README notes. Mar 31, 2017
action-collection.go Adds ActionCollection.FilterToCardMembershipChangeActions(). Dec 30, 2016
action-collection_test.go Changes Action.Card, ACtion.CardSource and Action.Old to a more limit… Dec 2, 2017
action.go Changes Action.Card, ACtion.CardSource and Action.Old to a more limit… Dec 2, 2017
action_test.go Changes Action.Card, ACtion.CardSource and Action.Old to a more limit… Dec 2, 2017
arguments.go Change trello.Defaults from a var to a function to avoid accidentally… Oct 2, 2016
arguments_test.go Change trello.Defaults from a var to a function to avoid accidentally… Oct 2, 2016
attachment.go Prevents license notice from becoming GoDoc package comment. Sep 26, 2016
board.go Runs go fmt over board.go after merging PR #25. Sep 19, 2018
board_test.go Add Lists and Actions to Board Jan 30, 2018
card.go Merge pull request #21 from mangelajo/customFields Oct 9, 2018
card_test.go Add basic support for CustomFields Jun 21, 2018
checklist.go fix: Trello have float values for checklist `Pos` May 6, 2017
client.go Merge branch 'master' of github.com:adlio/trello Apr 13, 2018
client_test.go Fix broken test that was calling unexported field Mar 10, 2018
custom-fields.go Add basic support for CustomFields Jun 21, 2018
custom-fields_test.go Add basic support for CustomFields Jun 21, 2018
errors.go Adds error structs. Dec 29, 2016
label.go Label API support Jun 21, 2018
label_test.go Label API support Jun 21, 2018
list-duration-sort.go Refactoring GetListDurations() to check Action.DidChangeListForCard()… Dec 30, 2016
list-duration.go Transitions remaining client.Logger.Debugf() calls to client.log() ca… Aug 17, 2017
list-duration_test.go Adds ListDuration{} and card.GetListDurations(), which is a feature t… Oct 2, 2016
list.go Set client on cards when getting lists May 19, 2018
list_test.go Set client on cards when getting lists May 19, 2018
member-duration.go Transitions remaining client.Logger.Debugf() calls to client.log() ca… Aug 17, 2017
member-duration_test.go Initial test for MemberDuration{}. Needs more unit-level testing. Jan 2, 2017
member.go Adds Member.Email. Jun 17, 2017
member_test.go Change trello.Defaults from a var to a function to avoid accidentally… Oct 2, 2016
mock-response_test.go Card ancestor improvements. Dec 29, 2016
organization.go Adds Organization{} struct and Client.GetOrganization(). Sep 27, 2016
organization_test.go Change trello.Defaults from a var to a function to avoid accidentally… Oct 2, 2016
search.go Merge pull request #13 from luccacabra/search-boards-client Mar 21, 2018
search_test.go Change trello.Defaults from a var to a function to avoid accidentally… Oct 2, 2016
token.go GetToken() test coverage. Oct 3, 2016
token_test.go Webhook testing. Oct 3, 2016
trello-logo.png Logo. Sep 26, 2016
trello.go Documentation of IDToTime() features. Jan 2, 2017
trello_test.go Documentation of IDToTime() features. Jan 2, 2017
webhook.go HEAD requests now return an empty object and nil error. Nov 8, 2016
webhook_test.go Adds client.Createwebhook(). Oct 5, 2016

README.md

Go Trello API

Trello Logo

GoDoc Build Status Coverage Status

A #golang package to access the Trello API. Nearly 100% of the read-only surface area of the API is covered, as is creation and modification of Cards. Low-level infrastructure for features to modify Lists and Boards are easy to add... just not done yet.

Pull requests are welcome for missing features.

My current development focus is documentation, especially enhancing this README.md with more example use cases.

Installation

The Go Trello API has been Tested compatible with Go 1.7 on up. Its only dependency is the github.com/pkg/errors package. It otherwise relies only on the Go standard library.

go get github.com/adlio/trello

Basic Usage

All interaction starts with a trello.Client. Create one with your appKey and token:

client := trello.NewClient(appKey, token)

All API requests accept a trello.Arguments object. This object is a simple map[string]string, converted to query string arguments in the API call. Trello has sane defaults on API calls. We have a trello.Defaults() utility function which can be used when you desire the default Trello arguments. Internally, trello.Defaults() is an empty map, which translates to an empty query string.

board, err := client.GetBoard("bOaRdID", trello.Defaults())
if err != nil {
  // Handle error
}

Client Longevity

When getting Lists from Boards or Cards from Lists, the original trello.Client pointer is carried along in returned child objects. It's important to realize that this enables you to make additional API calls via functions invoked on the objects you receive:

client := trello.NewClient(appKey, token)
board, err := client.GetBoard("ID", trello.Defaults())

// GetLists makes an API call to /boards/:id/lists using credentials from `client`
lists, err := board.GetLists(trello.Defaults())

for _, list := range lists {
  // GetCards makes an API call to /lists/:id/cards using credentials from `client`
  cards, err := list.GetCards(trello.Defaults())
}

Get Trello Boards for a User

Boards can be retrieved directly by their ID (see example above), or by asking for all boards for a member:

member, err := client.GetMember("usernameOrId", trello.Defaults())
if err != nil {
  // Handle error
}

boards, err := member.GetBoards(trello.Defaults())
if err != nil {
  // Handle error
}

Get Trello Lists on a Board

board, err := client.GetBoard("bOaRdID", trello.Defaults())
if err != nil {
  // Handle error
}

lists, err := board.GetLists(trello.Defaults())
if err != nil {
  // Handle error
}

Get Trello Cards on a Board

board, err := client.GetBoard("bOaRdID", trello.Defaults())
if err != nil {
  // Handle error
}

cards, err := board.GetCards(trello.Defaults())
if err != nil {
  // Handle error
}

Get Trello Cards on a List

list, err := client.GetList("lIsTID", trello.Defaults())
if err != nil {
  // Handle error
}

cards, err := list.GetCards(trello.Defaults())
if err != nil {
  // Handle error
}

Creating a Card

The API provides several mechanisms for creating new cards.

Creating Cards from Scratch on the Client

This approach requires the most input data on the card:

card := trello.Card{
  Name: "Card Name",
  Desc: "Card description",
  Pos: 12345.678,
  IDList: "iDOfaLiSt",
  IDLabels: []string{"labelID1", "labelID2"},
}
err := client.CreateCard(card, trello.Defaults())

Creating Cards On a List

list, err := client.GetList("lIsTID", trello.Defaults())
list.AddCard(trello.Card{ Name: "Card Name", Description: "Card description" }, trello.Defaults())

Creating a Card by Copying Another Card

err := card.CopyToList("listIdNUmber", trello.Defaults())

Get Actions on a Board

board, err := client.GetBoard("bOaRdID", trello.Defaults())
if err != nil {
  // Handle error
}

actions, err := board.GetActions(trello.Defaults())
if err != nil {
  // Handle error
}

Get Actions on a Card

card, err := client.GetCard("cArDID", trello.Defaults())
if err != nil {
  // Handle error
}

actions, err := card.GetActions(trello.Defaults())
if err != nil {
  // Handle error
}

Rearrange Cards Within a List

err := card.MoveToTopOfList()
err = card.MoveToBottomOfList()
err = card.SetPos(12345.6789)

Moving a Card to Another List

err := card.MoveToList("listIdNUmber", trello.Defaults())

Card Ancestry

Trello provides ancestry tracking when cards are created as copies of other cards. This package provides functions for working with this data:

// ancestors will hold a slice of *trello.Cards, with the first
// being the card's parent, and the last being parent's parent's parent...
ancestors, err := card.GetAncestorCards(trello.Defaults())

// GetOriginatingCard() is an alias for the last element in the slice
// of ancestor cards.
ultimateParentCard, err := card.GetOriginatingCard(trello.Defaults())

Debug Logging

If you'd like to see all API calls logged, you can attach a .Logger (implementing Debugf(string, ...interface{})) to your client. The interface for the logger mimics logrus. Example usage:

logger := logrus.New()
logger.SetLevel(logrus.DebugLevel)
client := trello.NewClient(appKey, token)
client.Logger = logger