Skip to main content

Multi purpose API Generator based on an Ontology Framework.

Project description

OntologyToAPI

This project is an ontology-driven API generator designed for backend development by transforming structured domain knowledge into fully functional APIs. The tool accepts ontologies specified in Turtle (.ttl), Resource Description Framework (.rdf) and Web Ontology Language (.owl).

Publish to PyPI and TestPyPI

Ontological Framework:

  • The following classes, relationships and data properties serve as a semantic blueprint for both metadata and business models.
AbstractOntologyClasses

The ontological framework is composed of two main modules:

  • Metadata Ontology Module: This module defines the essential classes and properties required to describe the metadata and its sources (e.g. Query to be executed on the CommunicationTechnology).
  • BusinessModel Ontology Module: This module captures the specific business logic and rules governing some operation, it requires an ExternalCode concretization, and it can require any metadata or parameter (To be sent in the API request).
  • ExternalCode Ontology Module: This module has all the technical details to connect to an external code, it also adds the possibility to dynamically require python packages.
  • Communications Ontology Module: This module describes the communication technologies that can be used to fetch the data of some metadata in multiple forms (e. g).

From now on you must be ready to go and create your own ontological specification importing the Ontology Modules and extending it. You can do this by using the Protégé ontology editor (https://protege.stanford.edu/). Or if you prefer you can use any text editor to create your ontology files in the supported formats (.ttl, .rdf, .owl).

Step 1: Installing the Package

pip install -U ontologytoapi

Step 2: Running

  • If you want to do a quick test we provided some .ttl samples at the following repository: https://github.com/JCGCosta/OntologyToAPISamples
  • With your metadata and business models ontologies implemented you can generate your API by having the following python file as an entry point:
import uvicorn
from OntologyToAPI.core.APIGenerator import APIGenerator

if __name__ == "__main__":
    APIGen = APIGenerator(showLogs=True)
    APIGen.load_ontologies(paths=[
        "Your/Metadata/Ontology/.ttl.owl.rdf"
    ])
    APIGen.load_ontologies(paths=[
        "Your/BusinessModel/Ontology/.ttl.owl.rdf"
    ])
    APIGen.serialize_ontologies()
    api_app = APIGen.generate_api_routes()
    uvicorn.run(api_app, host="127.0.0.1", port=5000)

Change Log

VERSION="0.0.12" LAST_UPDATE="27/10/2025"

FIRST RELEASE

  • Added "auto" functionality to path in the business model definition.
  • Added validation in the MongoDB connector to ensure the right connection string.

Project details


Download files

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

Source Distribution

ontologytoapi-0.0.12.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ontologytoapi-0.0.12-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file ontologytoapi-0.0.12.tar.gz.

File metadata

  • Download URL: ontologytoapi-0.0.12.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ontologytoapi-0.0.12.tar.gz
Algorithm Hash digest
SHA256 380dbe024a490724f4c1d785457d9229e824c15f1ba8a992368bc54225723951
MD5 1ace54a0f4d14cf690c4c013de235e12
BLAKE2b-256 cdc0942d19bb0b8ee0421f6bded1264e0d7a95797aa2ba953ce147db28df6441

See more details on using hashes here.

File details

Details for the file ontologytoapi-0.0.12-py3-none-any.whl.

File metadata

  • Download URL: ontologytoapi-0.0.12-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ontologytoapi-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 fac7010cd45e7c1cf94b0eef76531805bef9ddd4b48b7f7f41b93f944ac08946
MD5 1912e087a6a563318e809b5ef5abda08
BLAKE2b-256 6ecef27959a5d87d697dad6e52a2d80742665fce7bc11c82d32f4cc14fb9868b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page