How to Build an Events Database Using the ParseHub API, Python & Flask

How to Build an Events app using Python, Flask and the ParseHub API

Now that you have your data and turned into an API by using the ParseHub browser extension, it’s time to build our simple events web app. Your web app will communicate with the ParseHub API to get and display all of the events we scraped in the first part of the tutorial. Check out our full ParseHub API documentation here as well.

Install Python and Flask

We will build the events website using Python  and Flask, a web framework, similar to Rails for Ruby.
To get started, make sure your computer runs Python or download it by following this Python guide. If you are using a Mac, versions of MacOS 10.2 - 10.5 come with Python already installed. If you are using an older Mac version, download the latest python release here. For Windows XP users follow this ActivePython guide.

To install Flask, open up your terminal and install it with the following command line:

sudo pip install Flask

Choose a location on your computer where you want your events app to be saved, create a new folder for it and cd into that folder. I named my application “activities”.

mkdir activities
cd activities

Make sure you have your API key and project token from the ParseHub Firefox extension, as mentioned above. You can find your API key under your account page. Click the profile symbol at the top of the extension and select “Account”. And get your project token from the “Settings” tab in your project.  

Fetch the data and display it in your events app

Create a file and rename it in your activities folder.

The script below imports Flask and the homepage() function fetches the data we scraped from The data is rendered and displayed using the template in activities.html that we will create next.

Most of the function below was copy and pasted from the ParseHub API Reference. Make sure to replace the {PROJECT_TOKEN} and {API_KEY} with the two keys you found above in your project and ParseHub account.


from flask import Flask, render_template
import requests
import json

app = Flask(__name__, template_folder='.')

def homepage():
 params = {
   'api_key': {API_KEY}',
 r = requests.get(
 return render_template('activities.html', locations=json.loads(r.text)['locations'])

if __name__ == '__main__':

Let’s create our movies template and get the app to display all of the cities, the categories for each city and the activities for each category. Create a file and rename it activities.html in your activities folder.

<!-- activities.html -->

     {% for city in locations %}
         {% for category in city["categories"] %}
             {% for activity in category["activities"] %}
             {% endfor %}
         {% endfor %}
     {% endfor %}

In your terminal enter:


Now visit http://localhost:5000 in your browser to see the website in action.

Of course you can go ahead and make your app look much nicer with a framework like bootstrap.
web scraping parsehub tutorial
You can follow this Python tutorial to learn how to add caching, run your project on a schedule to get a refresh of data whenever you like, and use webhooks.

ParseHub also has packages available in Node.js, PHP and Python built by the developer community.

If you are trying to build something similar or want to get even more fancy, contact us at any time!


Be sure to read the next Application Development article: How To Leverage Ruby's Functional Programming Capability