Upload an Event’s Logo

Let's learn how to upload the logo for an event using Eventbrite API.

Upload a logo

Eventbrite API provides the facility to upload a logo for an event. The logo is uploaded to Eventbrite’s online repository, and the uploaded logo can be assigned to an event.

The following URL uses the POST method to upload an image:

https://www.eventbriteapi.com/v3/media/upload/

In the code widget below, the upload_file function will read an image and upload it to Eventbrite’s online storage. We have specified the type of the file image-event-logo. This function will return the response status and upload_token. The upload_token will be used to fetch the details of the uploaded image.

The input for this operation is an image, and the response object has the following attributes:

Object

Type

Description

id

string

This is the unique ID of the image uploaded.

crop_mask

object

This indicates an object with details of crop size.

aspect_ratio

string

This value tells us how much the image is smaller or larger by compared to the original image.

edge_color

color code

This object indicates the value of color on the edges of the image.

edge_color_set

boolean

This value tells whether to set the border color or not.

url

string

This is the URL to retrieve the cropped image.

original.height

number

This object indicates the height of the original image.

original.width

number

This object indicates the width of the original image.

original.url

string

This is the URL to retrieve the original image.

Press + to interact
import requests, urllib
import json
OAUTH_TOKEN = '{{PRIVATE_TOKEN}}'
MEDIA_UPLOAD_URL = 'https://www.eventbriteapi.com/v3/media/upload/'
def upload_file(filename):
instructions_url = MEDIA_UPLOAD_URL + '?' + urllib.parse.urlencode({
'type': 'image-event-logo',
'token': OAUTH_TOKEN
})
data = requests.get(instructions_url).json()
post_args = data['upload_data']
response = requests.post(data['upload_url'],
data = post_args,
files = {
data['file_parameter_name']: open(filename, 'rb')
}
)
return response, data['upload_token']
upload_response, upload_token = upload_file('__ed_input.png')
notify_url = MEDIA_UPLOAD_URL + '?' + urllib.parse.urlencode({'token': OAUTH_TOKEN})
image_data = {'upload_token': upload_token, 'crop_mask': {'top_left': {'y':1, 'x':1}, 'width':1280, 'height':640}}
response = requests.post(notify_url, json=image_data)
response = response.json()
url = response['url']
# rendering the image using html
print(f'<img src={url} width=500px>')
print("<br>Logo Id: ", response['id'])

We can retrieve the image using the url, and the id can be used to update the logo_id of the event using the update API call or during the creation of an event.

Assign a logo to an event

To assign the logo to an event, provide EVENT_ID and LOGO_ID in the widget below if not already:

Press + to interact
import requests
import json
url = 'https://www.eventbriteapi.com/v3/events/{{EVENT_ID}}/'
headers = {
'Authorization': 'Bearer {{PRIVATE_TOKEN}}',
'Content-Type': 'application/json'
}
values = json.dumps({
"event": {
"logo_id": "{{LOGO_ID}}"
}
})
response = requests.request("POST", url, headers=headers, data=values).json()
print(json.dumps(response, indent=4))