Skip to main content

Automatically generate data APIs for your Flask routes

Project description

Automatically generate data APIs for your Flask routes, with very little effort on your part. It should integrate into your existing application with very few changes required.


Given the following code:

from flask import Flask

app = Flask(__name__)

def foo():
    return render_template('foo.html', foo='bar', baz='boo')

We can automatically generate API functions for this route, rather simply:

from flask import Flask
from flask_dataapi import DataApi

app = Flask(__name__)
api = DataApi(app)

def foo(render_template):
    return render_template('foo.html', foo='bar', baz='boo')

There are only two changes made. First, we call api.route for the decorator, and second, the first argument to the view function is the render_template function that we’ll call.

This will automatically add a second route of /foo.json that outputs JSON of the data that was provided to render_template. The route will have a name of foo_api, so links or other references will use that name, e.g. url_for('foo_api').


In addition to free code, we also need free data. This makes it trivial to ensure that all data presented to users is easily extractable by the user.


flask-dataapi is available under the terms of the AGPL, version 3 or any later version.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for flask-dataapi, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size flask_dataapi-0.2.1-py3-none-any.whl (15.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size flask_dataapi-0.2.1.tar.gz (14.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page