Skip to main content

A really simple app that allows you to write out your RESTful APIs spec in a logical form and automatically generate stub functions for each endpoint.

Installing

Install from Source

To install from source, you will need to first clone the repository from GitHub:

git clone https://github.com/Michael-F-Bryan/flask_api_builder.git

Then run the setup.py file:

python3 setup.py install

With Pip

Or you can install directly from the Python Packaging Index:

pip install flask_api_builder

Usage

In order to generate your base API, you first need to write up a spec for it. The spec contains the definitions for each of your API’s end points, as well as some variables to customize the Blueprint each API endpoint is attached to.

Writing The Spec File

The spec file is designed to be quite intuitive to use. It is set out in a table-like format, with each column being aligned with spaces. Any line starting with a “#” is interpreted as a comment and ignored by the parser.

Defining Variables

Defining variables is really easy, just add a line with variable-name: value. The variable names currently supported are:

Blueprint-name

The name for your blueprint (defaults to “api”)

Prepend-with

The path that all endpoints attached to your API Blueprint are prepended with (nothing by default)

Error-handlers

Add pre-made 404 and 500 error handlers. They will be included unless something other than true, yes, 1, or y is entered (not case sensitive)

All variable names are not case sensitive.

Defining Endpoints

API Endpoints are defined one per line, in a table-like format. Each line consists of 3 or 4 fields delimited by two or more whitespace characters. This means that you need to separate your columns by at least two spaces so the parser will read them correctly.

The fields correspond to an endpoint’s METHOD, URL, DESCRIPTION and (optionally) the NAME of the function generated. If no name is provided then one will be generated for you given the method and URL parameters (no guarantees that the generated name will be intelligible though).

Here is an example of a simple spec for a to-do list app:

blueprint-name: api
#Method    URL                       Description
GET       /tasks                     Retrieve list of tasks
GET       /tasks/<int:task_id>       Retrieve task number <task_id>
POST      /tasks                     Create a new task

Changelog

[Unreleased]

New Features

  • Added error handlers to the generated code

Version 0.1.1 (2016-44-23)

New Features

  • Added a commandline option to view an example spec

  • Turned the module into a package and gave it a commandline entry point

Documentation Changes

  • Wrote up a basic README

  • Added an example spec file

Administration and Chores

  • Added a makefile to automate the boring stuff

  • Turned the module into a package with a main.py file

  • Added the ability to create sdist’s and wheels properly

Version 0.1.0 (2016-05-22)

New Features

  • Copied the main file from a jupyter notebook and set up the project

Release files for flask_api_builder 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flask_api_builder 0.2.0
File Size Uploaded
flask_api_builder-0.2.0.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flask_api_builder 0.2.0
File Interpreter ABI Platform
flask_api_builder-0.2.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 17.6 kB

Release files / flask_api_builder-0.2.0.tar.gz

Download URL flask_api_builder-0.2.0.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
501c497432e08d860df01a421695be280e7ccb7f11d8a678df29d3373fc8c085
BLAKE2b-256 checksum
How to use checksums
40a2a7b2a296c6643ee6af4a805840f1e2a1dd207ea5bef2e43795092c1a9302
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / flask_api_builder-0.2.0-py2.py3-none-any.whl

Download URL flask_api_builder-0.2.0-py2.py3-none-any.whl
Size 10.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
70567395095906ea0463f08e1403c6768be6929c1245f6b8ae0d0eee2fcf5c59
BLAKE2b-256 checksum
How to use checksums
148d3c6f5c246e58c3e0c06c3e72d6e9e0a7eadbabc8122fd81c6fcf7b7abb8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page