Skip to content

Latest commit

 

History

History
100 lines (62 loc) · 4.21 KB

py-trello.md

File metadata and controls

100 lines (62 loc) · 4.21 KB

py-trello

  • sarumont/py-trello: Python API wrapper around Trello's API #ril

    • A wrapper around the Trello API written in Python. Each Trello object is represented by a corresponding Python object.

      The attributes of these objects are CACHED, but the CHILD OBJECTS ARE NOT. This can possibly be improved when the API allows for notification subscriptions; this would allow caching (assuming a connection was available to invalidate the cache as appropriate).

新手上路 {: #getting-started }

  • Usage - sarumont/py-trello: Python API wrapper around Trello's API #ril

    from trello import TrelloClient
    
    client = TrelloClient(
        api_key='your-key',
        api_secret='your-secret',
        token='your-oauth-token-key',
        token_secret='your-oauth-token-secret'
    )
    
    • Where token and token_secret come from the 3-legged OAuth process and api_key and api_secret are your Trello API credentials that are (generated here).

      To use without 3-legged OAuth, use only api_key and api_secret on client.

      好奇就一個 library 而言,是如何做到 3-legged OAuth 的 ?? 上面 generate here 的 URL https://trello.com/1/appKey/generate 目前會轉向到 https://trello.com/app-key

    • Working with boards

      all_boards = client.list_boards()
      last_board = all_boards[-1]
      print(last_board.name)
      
    • working with board lists and cards

      all_boards = client.list_boards()
      last_board = all_boards[-1]
      last_board.list_lists()
      my_list = last_board.get_list(list_id)
      
      for card in my_list.list_cards():
          print(card.name)
      

      看起來滿直覺的,相較於手動打 API 是有一點優勢的。

Authentication ??

TrelloClient.get_card() 很沒效率 ??

  • py-trello/trelloclient.py at 0.15.0 · sarumont/py-trello

    def get_card(self, card_id):
        """Get card
        :rtype: Card
        """
        card_json = self.fetch_json('/cards/' + card_id)
        list_json = self.fetch_json('/lists/' + card_json['idList'])
        board = self.get_board(card_json['idBoard'])
        return Card.from_json(List.from_json(board, list_json), card_json)
    

    拿 card 時,會一併拿所屬的 list,以及該 list 所屬的 board,所以會多出 2 個 request。

安裝設置 {: #setup }

參考資料 {: #reference }

社群:

手冊: