Logo

销售与参会者报告

学习如何使用 Eventbrite API 生成销售报告和参会者报告。

概念

销售与参会者报告

学习如何使用 Eventbrite API 生成销售报告和参会者报告。

Eventbrite API 提供了生成报告的功能,支持两种类型的报告:活动的销售情况报告和参会人员报告。

销售报告

我们可以为某个活动生成销售报告。以下 URL 使用 GET 请求方法来生成销售报告:

1https://www.eventbriteapi.com/v3/organizations/{organization_id}/reports/sales/?event_ids={event_id}

请求参数

此 API 调用所需的请求参数如下:

对象类型分类描述
event_ids字符串数组必填我们要生成销售报告的活动 ID 列表
event_status字符串可选活动状态;可选值为 all、live 和 ended
start_date字符串可选活动的开始日期
end_date字符串可选活动的结束日期
filter_by字符串可选用于筛选数据,可包含多个筛选条件
group_by字符串可选按指定变量对返回数据进行分组;可选值包括 payment_method、ticket、currency、event_currency、country、city、state、source、zone、location 和 delivery_method
period整数可选选定 date_facet 的时间单位周期
date_facet字符串可选日期时间段;可选值包括 fifteen、hour、day、event_day、week、month、year 和 none。默认值为 day
timezone字符串可选活动所在时区。若未指定,默认使用第一个活动的时区

下面通过一个示例来获取某活动的销售报告。点击“运行”以执行代码。

1const endpointUrl = new URL('https://www.eventbriteapi.com/v3/organizations/{{ORGANIZATION_ID}}/reports/sales/?event_ids={{EVENT_ID}}'); 2 3const headerParameters = { 4 'Authorization': 'Bearer {{PRIVATE_TOKEN}}' 5}; 6 7const options = { 8 method: 'GET', 9 headers: headerParameters, 10}; 11 12async function retrieveSalesReport() { 13 try { 14 const response = await fetch(endpointUrl, options); 15 printResponse(response); 16 } catch (error) { 17 printError(error); 18 } 19} 20 21// 调用函数发起 API 请求 22retrieveSalesReport();
  • 第 1 行: 我们定义了端点 URL,其中 {ORGANIZATION_ID} 为 URL 参数,event_ids 作为过滤参数。
  • 第 12–19 行: 我们创建了一个名为 retrieveSalesReport 的函数,使用 fetch 发起 API 请求,并处理可能出现的异常。自定义函数 printResponse 和 printError 分别用于打印响应和错误信息。
  • 第 22 行: 我们调用了 retrieveSalesReport 函数。

响应字段

输出 JSON 响应中的对象数组包含以下重要字段:

对象类型描述
timezone字符串活动的时区
event_ids字符串数组公开活动 ID 列表
data.date字符串活动发生的日期
data.topics字符串数组与活动相关的主题
data.date_localized字符串活动的本地开始时间
data.totals.currency字符串国际标准 ISO 4217 三位货币代码
data.totals.gross整数票务总收入
data.totals.net整数票价及附加费用后的实际收入
data.totals.quantity整数已售出票券的总数量
data.totals.fees整数Eventbrite 平台收取的总费用
data.totals.royalty整数从票务销售中获得的总版税金额

参会人员报告

我们可以为某个活动生成参会人员报告。以下 URL 使用 GET 请求方法来生成参会人员报告:

1https://www.eventbriteapi.com/v3/organizations/{ORGANIZATION_ID}/reports/attendees/?event_ids={EVENT_ID}

请求参数

请求参数与销售报告相同。以下是获取参会人员报告的示例:

1const endpointUrl = new URL('https://www.eventbriteapi.com/v3/organizations/{{ORGANIZATION_ID}}/reports/attendees/?event_ids={{EVENT_ID}}'); 2 3const headerParameters = { 4 'Authorization': 'Bearer {{PRIVATE_TOKEN}}' 5}; 6 7const options = { 8 method: 'GET', 9 headers: headerParameters, 10}; 11 12async function retrieveAttendeesReport() { 13 try { 14 const response = await fetch(endpointUrl, options); 15 printResponse(response); 16 } catch (error) { 17 printError(error); 18 } 19} 20 21// 调用函数发起 API 请求 22retrieveAttendeesReport();
  • 第 1 行: 我们定义了端点 URL,其中 {ORGANIZATION_ID} 为 URL 参数,event_ids 作为过滤参数。
  • 第 12–19 行: 我们创建了一个名为 retrieveAttendeesReport 的函数,使用 fetch 发起 API 请求,并处理可能出现的异常。自定义函数 printResponse 和 printError 分别用于打印响应和错误信息。
  • 第 22 行: 我们调用了 retrieveAttendeesReport 函数。

响应字段

输出 JSON 响应中的对象数组包含以下重要字段:

对象类型描述
timezone字符串活动的时区
event_ids字符串数组公开活动 ID 列表
data.date字符串活动的日期
data.topics字符串数组与活动相关的主题
data.date_localized字符串活动的本地开始时间
data.totals.num_attendees整数参会人员总数
data.totals.num_orders整数订单总数

折扣和促销代码

React 中的 API 集成