Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
Feishu-Bitable-Python-API/LIST_TABLES.py at main · BlueSkyXN/Feishu-Bitable-Python-API · GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
BlueSkyXN
Feishu-Bitable-Python-API
Repository navigation
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
Feishu-Bitable-Python-API
/
LIST_TABLES.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
66 lines (57 loc) · 2.6 KB
main
Breadcrumbs
Feishu-Bitable-Python-API
/
LIST_TABLES.py
Copy path
Top
File metadata and controls
Code
Blame
66 lines (57 loc) · 2.6 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import
requests
import
configparser
import
json
import
argparse
def
LIST_TABLES
(
app_token
=
None
,
user_access_token
=
None
,
page_size
=
None
,
page_token
=
None
,
config_file
=
None
):
# 如果未指定配置文件,则使用默认的配置文件名
if
config_file
is
None
:
config_file
=
"feishu-config.ini"
# 创建配置解析器对象
config
=
configparser
.
ConfigParser
()
# 读取配置文件
config
.
read
(
config_file
,
encoding
=
'utf-8'
)
# 如果未提供 app_token,则从配置文件中获取
if
not
app_token
:
app_token
=
config
.
get
(
'TOKEN'
,
'app_token'
)
# 如果未提供 user_access_token,则从配置文件中获取
if
not
user_access_token
:
user_access_token
=
config
.
get
(
'TOKEN'
,
'user_access_token'
)
# 如果未提供 page_token,则从配置文件中获取,如果配置文件中没有设置则默认为 None
if
not
page_token
:
page_token
=
config
.
get
(
'LIST_TABLES'
,
'page_token'
,
fallback
=
None
)
# 如果未提供 page_size,则从配置文件中获取,如果配置文件中没有设置则默认为 100
if
not
page_size
:
page_size
=
config
.
get
(
'LIST_TABLES'
,
'page_size'
,
fallback
=
100
)
# 构建请求的 URL
url
=
f"https://open.feishu.cn/open-apis/bitable/v1/apps/
{
app_token
}
/tables"
# 设置请求的头部信息
headers
=
{
'Authorization'
:
f'Bearer
{
user_access_token
}
'
,
'Content-Type'
:
'application/json; charset=utf-8'
}
# 构建请求的参数
params
=
{
'page_size'
:
page_size
}
if
page_token
:
params
[
'page_token'
]
=
page_token
# 发送 GET 请求
response
=
requests
.
get
(
url
,
headers
=
headers
,
params
=
params
)
# 返回响应的 JSON 数据
return
response
.
json
()
def
LIST_TABLES_CMD
():
# 创建命令行参数解析器
parser
=
argparse
.
ArgumentParser
()
# 添加命令行参数
parser
.
add_argument
(
'--app_token'
,
help
=
'app token'
)
parser
.
add_argument
(
'--user_access_token'
,
help
=
'user access token'
)
parser
.
add_argument
(
'--page_size'
,
type
=
int
,
help
=
'page size'
)
parser
.
add_argument
(
'--page_token'
,
help
=
'page token'
)
parser
.
add_argument
(
'--config_file'
,
default
=
"feishu-config.ini"
,
help
=
'config file path'
)
# 解析命令行参数
args
=
parser
.
parse_args
()
# 调用 LIST_TABLES 函数获取表格列表的响应数据
response_body
=
LIST_TABLES
(
args
.
app_token
,
args
.
user_access_token
,
args
.
page_size
,
args
.
page_token
,
args
.
config_file
)
# 将响应数据以缩进格式打印输出
print
(
json
.
dumps
(
response_body
,
indent
=
4
))
if
__name__
==
"__main__"
:
# 执行 LIST_TABLES_CMD 函数
LIST_TABLES_CMD
()
You can’t perform that action at this time.