一个简单且用户友好的Python-to-trelloapi
trello.p的Python项目详细描述
Python Trello API
在特雷洛.py是一个简单的Python API,用于与Trello通信。它是一个面向对象的API,使用Trello Rest API。在
此API由LisaF854的Roblox-Trello | Object Oriented Trello API编写。它使用与该API相似的结构,因此您会注意到许多函数都应用于该API。在
这个API具有简单且用户友好的函数,可以完成许多通常由您自己完成的任务。将来会增加更多的功能,以备需要。在
入门
要使用此API,请首先使用pip
从PyPI安装它:
pip install trello.py
或者从GitHub页面下载并运行目录中的代码:
^{pr2}$此API需要应用程序密钥和令牌才能工作。要获取应用程序密钥,只需转到https://trello.com/app-key并获取生成的应用程序密钥。暂时将其保存在某个地方,因为以后需要访问它。在
一旦你有了你的应用程序密钥,你也需要获得你的应用程序令牌。您可以访问https://trello.com/1/authorize?expiration=never&scope=read,write&response_type=token&name=Trello.py%20Access&key=YOUR_KEY_HERE以获取令牌。请确保将YOUR_KEY_HERE
替换为应用程序密钥。一旦你授权了它,它会给你你的令牌。把代币也放在什么地方。在
WARNING: You should only share your token with people that you trust. Your token is like the password of your account and the app key is the username. If your app key is ever leaked, it should not cause many issues, but it is recommended that you change it. On the other hand, if your token is in fact leaked, make sure to remove access to it immediately and generate a new one. If a person has your token, then they have access to your account (via code) and have the ability to do anything that you can do. Make sure it is always kept in a safe place and hidden from the public.
下面的代码是一个导入trelloapi(作为Trello)、按名称检索board并获取board数据的示例。在
fromtrelloimportTrelloAPIasTrelloMyTrello=Trello("YOUR_APP_KEY","YOUR_TOKEN")Board=MyTrello.GetBoardByName("Your Board Name")BoardData=Board.GetData()
(注意:Trello确实支持OAuth,但是pythonapi还没有对它的任何支持。)
基本信息
您可以将Trello
类看作帐户。您应该只在脚本中初始化Trello
的一个实例。尽管这是允许的,但不建议有一个以上的Trello
实例。在
Trello
实例具有三个基本函数:
- GetBoardByName(String
BoardName
)-按名称获取板 - GetBoardById(String
BoardId
)-通过板的ID获取板 - new(String
Type
,StringName
,ObjectParent
)-创建具有给定名称的新对象(Board
,List
,Card
)。如果它是一个List
对象,那么父对象必须是Board
对象,即列表所在的电路板。如果它是一个Card
对象,那么父对象必须是List
对象,该对象就是列表所在的列表。如果是一块板,十块你可以留空
目前,有五种类型的对象,Trello
,Board
,List
,Card
,和{Trello
)都有一些共同的函数,它们是
- GetId()—获取对象的ID
- GetData(String
Param
(可选))-以JSON格式获取对象的数据。Param
参数是可选的。它基本上是对预先制作的URL的扩展,用于特殊请求,如卡片或标签列表 - SetProperty(String
Property
,StringValue
)-将对象的Property
的值设置为Value
。不建议您使用此函数。仅在需要时使用 - ClassName()-返回对象的类名(
Board
,List
,Card
,或{})
错误、报告和建议
请记住,这个API还处于早期阶段。它将有bug,这是早期版本中常见的情况。如果您发现任何错误或有任何建议,请通过Discord直接发送给我,或在GitHub页(W.I.P.)上创建错误报告或建议。如果你通过不和与我联系,我的用户名是Batman212369#5703
。在
NOTE: Yes, I know that currently there aren't any checkings (doesn't check for errors nor if the input is the correct type) when calling methods. This will be added soon, but for now just use the API responsibly and you should not get any errors.
- 项目
标签: