Update: August 2020. The second half of this article is still useful, but Bearer no longer handles integrations. Instead, check out Pizzly, our open source project for integrating with APIs, and take a look at Corentin's guide on setting it up.
Eventbrite's powerful event discovery and management platform is completely accessible through their developer platform. Version 3 is a REST API that uses OAuth2 for authorization, which means it's not only familiar, but there's a Bearer integration for it.
In this article we will:
- Set up your application on Eventbrite and get the credentials.
- Connect Bearer and the @bearer/node client to handle the auth and requests.
- Create, review, and publish a new event.
Setting up an app on the Eventbrite platform
Eventbrite requires an account on their platform as well as an API key to get started. Here's a brief overview, or check out our step-by-step guide on How to configure the Eventbrite API.
First, get your key from the Eventbrite Platform page.
You can then configure your application and get any necessary credentials on the account page.
There, you'll find the client ID (API Key) and client secret needed for the next step. This is also the place to set your application name, redirect URI, and application URI.
⚠️ Make sure
https://int.bearer.sh/v2/auth/callback
is set as the OAuth redirect URI on your Eventbrite app settings under "Key Info"
Set up the Eventbrite integration and connect Bearer
If you haven't already, activate the Eventbrite Integration on Bearer. For more on setting up an integration, see the getting started guide.
Once the integration is enabled, you can access it in your app using one of Bearer's clients. For this tutorial, we'll use the @bearer/node client.
We will only create events from a single user, you, which means you will use your own Auth ID. In case you want to create events for third-party users, make sure to generate an identity for them to retrieve their Auth ID.
Get started by initializing a new node application:
npm init --yes
Install the Bearer client for Node.js
npm install @bearer/node
With the integration enabled in your app, you can now use it to make API calls to Eventbrite.
Create a new file index.js
, require the Bearer client, and initialize the integration:
// npm install @bearer/node
const bearer = require("@bearer/node")
// Initialize the client
const client = bearer("YOUR-SECRET-KEY")
// Set up the Eventbrite Integration
const eventBrite = client.integration("eventbrite").auth('YOUR-AUTH-ID)
Make sure to replace YOUR-SECRET-KEY
and YOUR-AUTH-ID
with the correct values.
If you've set up Bearer before, this will be familiar. The secret key comes from your Bearer settings page, and the auth ID comes from the identity generated when you set up Eventbrite within Bearer.
We can test the integration and make sure everything is working by having the client make a call to the API:
eventBrite.get("users/me/organizations").then(({ data }) => {
console.log(data)
})
When you run node index.js
, you should see a list of all organizations that the authenticated user belongs to. This is important for the next step, creating a new event.
Create, review, and publish a new event
With the client set up, now you can create a new event in the organization of your choice. The Eventbrite API provides an endpoint for creating new events. The key requirement, aside from the event details, is the organization ID (like one obtained from the previous example).
eventBrite
.post("organizations/ORG-ID/events/", {
body: {
event: {
name: {
html: "Test Event"
},
start: {
timezone: "America/Los_Angeles",
utc: "2019-12-01T02:00:00Z"
},
end: {
timezone: "America/Los_Angeles",
utc: "2019-12-01T05:00:00Z"
},
currency: "USD"
}
}
})
.then(({ data }) => {
console.log(data)
})
In the code above, we've sent only the required properties needed for a new event. Specifically: the name
, start
time, end
time, and currency
. Check the documentation for a full list of possible properties you can change.
The response we get back contains details on the new event, including it's id
, url
and status
. The current status will be "draft".
All events are created as drafts, and must be published with a separate API call to the publish endpoint.
If you try to publish the event you just created, you'll receive an error. Events need tickets before they can be published. To do this, you'll use the create ticket class endpoint.
eventBrite
.post("/events/EVENT-ID/ticket_classes/", {
body: {
ticket_class: {
name: "General Entry",
free: true,
quantity_total: 50
}
}
})
.then(({ data }) => console.log(data))
.catch(console.error)
Ticket classes require at least the name
, free
, quantity_total
, and for paid tickets the cost
properties.
With the event created, and the ticket class added, it is now possible to publish the event.
eventBrite
.post("events/EVENT-ID/publish/")
.then(({ data }) => console.log(data))
.catch(console.error)
If any required data is missing, the error response will let you know. Otherwise, a successful publish will return { published: true }
.
Takeaways and things to try
Creating events from scratch with the Eventbrite API is a multi-step task. If you find yourself creating many of the same type of event, an easier option is to copy an existing event and use it as a base. A few other useful things you can do:
- Create private events by setting the
listed
property to false. - Retrieve Attendee data to connect your users with an events attendees.
- Use the media endpoint to upload images to an event.
Like this tutorial or have an idea for one you'd like to see? Connect with us @BearerSH
Top comments (0)