APIS Core is a library that allows you to easily build tools to manage prosopographical data. It is not a ready-made software solution that you can just deploy and start working. The typical workflow for starting an APIS project is as follows: set up the project, create an ontology, customize functionalities and views, and finally add your data. This section will guide you through the first step.

Prerequisites

APIS needs Python 3.11+.

Installation

django-admin startproject my_apis_instance

Add apis-core-rdf as a dependency to your project.

To use the APIS framework in your application, you will need to add the following dependencies to INSTALLED_APPS:

INSTALLED_APPS = [
    # our main app, containing the ontology (in the `models.py`)
    # and our customizations
    "sample_project",
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    # ui stuff used by APIS
    "crispy_forms",
    "crispy_bootstrap4",
    "django_filters",
    "django_tables2",
    "dal",
    "dal_select2",
    # REST API
    "rest_framework",
    # swagger ui generation
    "drf_spectacular",
    # The APIS apps
    "apis_core.core",
    "apis_core.generic",
    "apis_core.apis_metainfo",
    "apis_core.apis_entities",
    # APIS collections provide a collection model similar to
    # SKOS collections and allow tagging of content
    "apis_core.collections",
    # APIS history modules tracks changes of instances over
    # time and lets you revert changes
    "apis_core.history",
]

Finally, add the APIS urls to your applications URL Dispatcher

urlpatterns = [
    path("", include("apis_core.urls", namespace="apis")),
    # https://docs.djangoproject.com/en/stable/topics/auth/default/#module-django.contrib.auth.views
    path("accounts/", include("django.contrib.auth.urls")),
    # https://docs.djangoproject.com/en/stable/ref/contrib/admin/#hooking-adminsite-to-urlconf
    path("admin/", admin.site.urls),
]

Now start using your Django project

./manage.py runserver

Now you should be ready to roll. Start creating your ontology.

Installation with Docker

This is the recommended way to install APIS on local machines as well as on server infrastructure. For experimenting with APIS you can use the Docker file provided in the APIS core library. It allows you to spin up an APIS instance using the sample project shipped with the APIS core library. To start it, start a terminal and run:

  • cd path/to/apis-core-rdf to change to the directory where the Docker file is located,
  • docker build -t apis . to build the APIS image,
  • docker run -p 5000:5000 apis to start the container.

The APIS instance should now be accessible under http://localhost:5000.

Alternatively you can also use the Docker image built for our demo project. To do so run:

  • docker run -p 5000:5000 ghcr.io/acdh-oeaw/apis-core-rdf/discworld/main:latest to start the container.

To use the image for local development you can mount your local APIS instance directory into the container using the following command:

docker run -p 5000:5000 -v /path/to/your/apis_instance:/app apis

Please note that you might need to install custom dependencies for the APIS instance in your local Docker container.

This container uses the Django development server and is not suitable for production use. Please see the next section for deploying APIS in production.

Docker Compose

In production, APIS should be used together with an SQL database. The simplest way to set that up is by using Docker Compose. Below is an example of a docker-compose.yml file that sets up an APIS instance with a PostgreSQL database.

version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    depends_on:
      db:
        condition: service_healthy
        restart: true

    environment: # some settings can be overwritten with env variables
      - DJANGO_SETTINGS_MODULE=apis.settings
      - DJANGO_SECRET_KEY=your_secret_key
      - DJANGO_DEBUG=True
      - DATABASE_URL=postgres://postgres:postgres@db:5432/postgres
    volumes:
      - ${PWD}/local_apis_instance:/app #mount your local APIS instance to the container if needed
    ports:
      - 5000:5000

  db:
    image: postgres:latest
    restart: unless-stopped
    volumes:
      - postgres-data:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: postgres
      POSTGRES_DB: postgres #use other passwords in production
      POSTGRES_PASSWORD: postgres
      POSTGRES_EXTENSIONS: pg_trgm
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
      interval: 10s
      timeout: 3s
      retries: 3

volumes:
  postgres-data:

After docker-compose up you should now have a default APIS installation accessible under http://127.0.0.1:5000.