Skip to content

main_index

The OPTIMADE Index Meta-Database server

The server is based on MongoDB, using either pymongo or mongomock.

This is an example implementation with example data. To implement your own index meta-database server see the documentation at https://optimade.org/optimade-python-tools.

add_major_version_base_url(app)

Add mandatory endpoints to /vMAJOR base URL.

Source code in optimade/server/main_index.py
def add_major_version_base_url(app: FastAPI):
    """Add mandatory endpoints to `/vMAJOR` base URL."""
    for endpoint in (index_info, links):
        app.include_router(endpoint.router, prefix=BASE_URL_PREFIXES["major"])

add_optional_versioned_base_urls(app)

Add the following OPTIONAL prefixes/base URLs to server:

    /vMajor.Minor
    /vMajor.Minor.Patch

Source code in optimade/server/main_index.py
def add_optional_versioned_base_urls(app: FastAPI):
    """Add the following OPTIONAL prefixes/base URLs to server:
    ```
        /vMajor.Minor
        /vMajor.Minor.Patch
    ```
    """
    for version in ("minor", "patch"):
        app.include_router(index_info.router, prefix=BASE_URL_PREFIXES[version])
        app.include_router(links.router, prefix=BASE_URL_PREFIXES[version])