timetree sdk python
v0.1.3
Python的时间表API SDK。
请注意终止时间表API的时间表:
新申请创建的停用:2023年8月2日(星期三)
从这个日期开始,将停止创建新应用程序。在此阶段,这不会影响现有的应用程序。
完全关闭时间表API:2023年12月22日(星期五)
在此日期,所有API端点将停止可用,有效地停止了API的所有功能。
$ pip install timetree-sdk
from timetree_sdk import TimeTreeApi
api = TimeTreeApi ( 'API_ACCESS_TOKEN' )
calendar = api . get_calendar ( 'CALENDAR_ID' )
print ( calendar . data . attributes . name ) # calendar name
oauth_authorize_url = TimeTreeApi . get_oauth_authorize_url ( 'CLIENT_ID' , 'REDIRECT_URI' , 'RESPONSE_TYPE' , 'STATE' )
user = api . get_current_user ()
print ( user . data . attributes . name ) # user name
calendars = api . get_calendars ()
print ( calendars . data [ 0 ]. attributes . name ) # first calendar name
calendar = api . get_calendar ( 'CALENDAR_ID' )
print ( calendar . data . attributes . name ) # calendar name
labels = api . get_calendar_labels ( 'CALENDAR_ID' )
print ( labels . data [ 0 ]. attributes . name ) # first calendar's label name
members = api . get_calendar_members ( 'CALENDAR_ID' )
print ( members . data [ 0 ]. attributes . name ) # first calendar's member name
event = api . get_event ( 'CALENDAR_ID' , 'EVENT_ID' )
print ( event . data . attributes . title ) # event title
events = api . get_upcoming_events ( 'CALENDAR_ID' , 'Asia/Tokyo' , 7 )
print ( events . data [ 0 ]. attributes . title ) # most recent event title in 7 days
event = Event (
data = EventData (
attributes = EventAttributes (
title = 'Title' ,
category = 'schedule' ,
all_day = False ,
start_at = '2020-04-04T11:00:00.000Z' ,
end_at = '2020-04-04T13:00:00.000Z' ,
description = 'Description' ,
location = 'Location' ,
start_timezone = 'Japan' ,
end_timezone = 'Japan'
),
relationships = EventRelationships (
label = EventRelationshipsLabel (
data = EventRelationshipsLabelData (
id = 'LABEL_ID' ,
type = 'label'
)
),
attendees = EventRelationshipsAttendees (
data = [ EventRelationshipsAttendeesData (
id = 'USER_ID' ,
type = 'user'
)]
)
)
)
)
response = api . create_event ( 'CALENDAR_ID' , event )
print ( response . data . attributes . title ) # Title
event = Event (
data = EventData (
attributes = EventAttributes (
title = 'Updated Title' ,
category = 'schedule' ,
all_day = False ,
start_at = '2020-04-04T11:30:00.000Z' ,
end_at = '2020-04-04T13:30:00.000Z' ,
description = 'Description' ,
location = 'Location' ,
start_timezone = 'Japan' ,
end_timezone = 'Japan'
),
relationships = EventRelationships (
label = EventRelationshipsLabel (
data = EventRelationshipsLabelData (
id = 'LABEL_ID' ,
type = 'label'
)
),
attendees = EventRelationshipsAttendees (
data = [ EventRelationshipsAttendeesData (
id = 'USER_ID' ,
type = 'user'
)]
)
)
)
)
response = api . create_event ( 'CALENDAR_ID' , 'EVENT_ID' , event )
print ( response . data . attributes . title ) # Updated Title
status_code = api . delete_event ( 'CALENDAR_ID' , 'EVENT_ID' )
print ( status_code ) # 204 on success
comment = EventComment (
data = EventCommentData (
attributes = EventCommentAttributes (
content = 'Hello, world'
)
)
)
event_comment = api . create_event_comment ( 'CALENDAR_ID' , 'EVENT_ID' , comment )
print ( event_comment . data . attributes . content ) # Hello, world
官方API文档
英语:https://developers.timetreeapp.com/en/docs/api
日语:https://developers.timetreeapp.com/ja/docs/api