Quick start

Architectural overview

API diagram

Installing it yourself

The best way to run the Protari API is to import it as a package into your own python module (the "Protari instance" in the above diagram).

The protari-sample repository is a ready-to-go example. It contains some sample datasets and some sample data.

git clone protari-sample and follow the instructions provided there. The gist of those instructions is provided below.

If you want to develop the Protari libraries themselves, see the Developer's guide to setting up Protari.

The code relies on git+ssh to refer to other dependencies, so you will need to register your ssh key.

Choose the latest tagged version of protari-sample

Type git tag and choose the latest tag shown (eg. 1.0.0). Then type:

git checkout 1.0.0  # Replace the version with the latest tag.

Install Python, pip and pipenv

See the pipenv documentation for the steps to install python, pip and pipenv. This link may be helpful for linux users.

The API has been developed for Python 3.6, although later versions may work too.

Install the Required Packages

Enter the protari-sample directory, install the required packages into a virtual environment (including the ability to connect to a Postgres database), and enter that environment, via:

pipenv install --dev
pipenv shell

Note pipenv install --dev installs the protari-setup library, which is not required to run the API, but is required to build the database. (In production, where you are connecting to a pre-existing database, you would use pipenv install without the --dev.)

Set up a Sample Database

Ensure your database server is running, eg. installing a postgres server.

Then, still in the protari-sample directory, type:

./bin/build_db

Run the API's dev server

You can now run the API by typing (again, still in the protari-sample directory):

python application.py

You can test it out in your browser by navigating to http://localhost:8080/v1/ui/. (The v1 may change. See the file protari-api/swagger.yaml file for the current version.)

That page provides an interface for exploring the API. Alternatively you can check out the full API specification at http://localhost:8080/v1/swagger.json.

Note – do not use this development web server in production, as it does not scale well and serves only one request at a time. Some of the options available for properly running Flask in production are documented in the Flask documentation here. The server can be anything that supports WSGI (eg. Apache with mod_wsgi or nginx). The only required static files are those that provide the swagger UI for the API, if enabled.