数据提取API
您将学习到
- 如何使用Cypress Cloud API提取测试数据
- 可用于数据提取的API端点
- 如何使用API获取CSV、JSON或XLSX格式的数据
- 如何获取特定日期范围内的数据
企业级报告数据可通过Cypress Cloud API从云端下载。返回的数据支持多种文件格式,便于集成到BI报告平台,同时提供可编程解析的JSON文件。该API支持获取多层次的测试数据,包括包含状态、错误信息、运行标签和分组、测试回放链接等详细信息的单个测试结果数据。
所有在企业级报告中可见的数据均可通过此API获取。
Cypress Cloud高级功能
数据提取API仅适用于订阅了 企业版Cypress Cloud计划的用户。
API概览
报告数据通过Cloud中的API密钥访问。在Cypress Cloud中进入集成→企业API,复制为您的组织创建的API密钥。无需额外启用功能,只要订阅了企业版Cypress Cloud计划,通过API访问测试数据的功能即已激活。

注意事项:
- 企业级报告中的数据非实时显示。聚合数据基于UTC时间当天午夜更新,即数据更新至"昨日结束"。但单个结果数据接近实时,运行完成后30分钟内可用。返回近实时数据的端点如下所述。
- 历史数据可用性取决于Cypress Cloud中的数据保留期限。
API端点详情
使用以下API端点。将YOUR-API-KEY
替换为您的API密钥,report_id
指定要检索的数据类型。
可用查询参数:
-
start_date。必填,格式为yyyy-MM-dd或yyyy-MM-ddTHH:mm:ss。
例如,请求2025年1月1日的开始日期:
?start_date=2025-01-01
。请求当天UTC时间12:30的开始时间:?start_date=2025-01-01T12%3A30%3A00
-
end_date。可选,格式同上。未指定时默认为当天。
例如,请求2025年3月1 日的结束日期:
?end_date=2025-03-01
。请求当天UTC时间12:30的结束时间:?end_date=2025-03-01T12%3A30%3A00
-
projects。可选,接受Cypress项目名称,需URL编码。可传递多个项目参数。
例如,筛选项目_Project e2e_和_Phoenix_:
&projects=Project%20e2e&projects=Phoenix
-
branch。可选,接受提交分支名称,需URL编码。可传递多个分支参数。
例如,筛选分支_develop_和_commitBranch1_:
&branch=develop&branch=commitBranch1
-
export_format。指定返回数据的文件格式,有效选项:
csv
、json
、xlsx
例如,请求JSON格式:
&export_format=json
使用情况与项目
项目列表
获取自start_date以来在Cypress Cloud中记录测试的所有项目列表。返回的ID用于Cypress Cloud中项目级分析页面的URL链接生成。
report_id:project-list
返回数据包括:
- project_name
- id
各项目测试数量
了解组织中各项目的测试使用情况,返回各项目的简单汇总。
report_id:usage-per-project-summary
返回数据包括:
- project_name
- test_run_count
各项目测试数量趋势
了解组织中各项目的测试使用情况随时间的变化。
report_id:usage-per-project-over-time
返回数据包括:
- project_name
- test_run_count
- week
- day
Cypress测试类型
了解组织内端到端测试和组件测试的采用情况。
report_id:cypress-test-types
返回数据包括:
- testing_type (e2e或component)
- total_tests
- total_e2e
- total_ct
- week
- day
Cypress测试套件规模
了解组织中所有项目的测试套件规模增长情况。计算每次运行的平均测试用例数,排除因错误或超时导致的运行。
report_id:test-suite-size-summary
返回数据包括:
- total_tests
- total_e2e
- total_ct
- week
Cypress测试套件规模趋势
了解测试套件规模随时间的变化。
report_id:test-suite-size-over-time
返回数据包括:
- project_name
- total_tests
- total_e2e
- total_ct
- week
项目测试数量与状态
提取项目级别的运行状态汇总数据,随时间变化。
report_id:status-per-test-daily
返回数据包括:
- project_name
- status
- test_run_count
- week
- day
运行状态
按运行状态
了解运行级别的成功与失败率。若运行任何部分失败,则整个运行视为失败。
report_id:status-per-build-summary
返回数据包括:
- status
- test_run_count
按运行状态趋势
了解运行级别的成功与失败率随时间变化。
report_id:status-per-build-over-time
返回数据包括:
- status
- test_run_count
- week
- day
按规格状态
了解规格级别的成功与失败率。若规格任何部分失败,则整个规格视为失败。
report_id:status-per-spec-summary
返回数据包括:
- status
- test_run_count
按规格状态趋势
了解规格级别的成功与失败率随时间变化。
report_id:status-per-spec-over-time
返回数据包括:
- status
- test_run_count
- week
- day
按测试运行状态
了解单个测试级别的成功与失败率。
report_id:status-per-test-summary
返回数据包括:
- failed
- passed
按测试运行状态趋势
了解单个测试级别的成功与失败率随时间变化。
report_id:status-per-test-over-time
返回数据包括:
- project_name
- test_run_count
- week
- status
版本与浏览器
Cypress运行版本
监控组织中使用的Cypress应用版本。
report_id:cypress-build-versions-summary
返回数据包括:
- run_count
- cypress_version
Cypress运行版本趋势
监控组织中 使用的Cypress应用版本随时间变化。
report_id:cypress-build-versions-over-time
返回数据包括:
- run_count
- cypress_version
- week
各项目Cypress运行版本趋势
监控各项目中使用的Cypress应用版本随时间变化。
report_id:cypress-build-versions-per-project-over-time
返回数据包括:
- project_name
- run_count
- cypress_version
- week
测试浏览器
监控组织中测试的浏览器类型。
report_id:browsers-tested
返回数据包括:
- spec_count
- browser
浏览器版本测试
监控组织中测试的浏览器具体版本。
report_id:browser-versions
返回数据包括:
- spec_count
- browser
- version
浏览器版本测试趋势
监控组织中测试的浏览器具体版本随时间变化。
report_id:browser-versions-over-time
返回数据包括:
- spec_count
- browser
- version
- day
- week
各项目浏览器版本测试趋势
监控各项目中测试的浏览器具体版本随时间变化。
report_id:browser-versions-per-project-over-time
返回数据包括:
- project_name
- spec_count
- browser
- version
- day
- week
测试级数据
以下API的数据在运行完成后30分钟内接近实时可用。
单个规格结果
提取所有规格结果,无论状态如何。单次请求最多返回500,000条记录,超过需分多次请求。
report_id:spec-details
返回数据包括:
- project_name
- created_at (日期和时间)
- run_number
- commit_author_name
- spec (路径和文件名)
- status
- total_tests
- pass_tests
- flaky_tests
- fail_tests
- parallel_enabled
- commit_branch
- group_name
- failed_spec_prioritized
- spec_duration (毫秒)
- browser_name
- browser_version
- os_name
- os_version
单个失败测试结果
提取所有失败测试的详细结果。单次请求最多返回500,000条记录。
report_id:failed-test-details
返回数据包括:
- project_name
- created_at (日期和时间)
- run_number
- commit_author_name
- commit_branch
- commit_sha
- ci_build_id
- status
- group_name
- run_tags (字符串数组)
- error_name (字符串数组)
- error_message (字符串数组)
- test_replay_url
- spec (路径和文件名)
- test_name (测试名称与Cypress Cloud显示一致,使用'///'分隔片段)
单个测试结果
提取所有测试的详细结果,无论状态如何。单次请求最多返回500,000条记录。
report_id:test-details
返回数据包括:
- project_name
- created_at (日期和时间)
- run_number
- commit_author_name
- commit_branch
- commit_sha
- ci_build_id
- status
- group_name
- run_tags (字符串数组)
- test_duration
- error_name (字符串数组)
- error_message (字符串数组)
- test_replay_url
- spec (路径和文件名)
- test_name (测试名称与Cypress Cloud显示一致,使用'///'分隔片段)
运行时长
平均运行时长趋势
获取通过运行的平均、中位数、最小和最大时长,随时间变化。
report_id:average-passing-build-duration
返回数据包括:
- project_name
- run_count
- avg_pass_run_duration (平均)
- mdn_pass_run_duration (中位数)
- min_pass_run_duration (最小)
- max_pass_run_duration (最大)
- day
- week
平均规格时长趋势
获取规格的平均、中位数、最小和最大时长,随时间变化。单次请求最多返回500,000条记录。
report_id:average-passing-spec-duration
返回数据包括:
- project_name
- spec (路径和文件名)
- spec_count
- avg_pass_spec_duration (平均)
- mdn_pass_spec_duration (中位数)
- min_pass_spec_duration (最小)
- max_pass_spec_duration (最大)
- day
- week