Skip to main content

stac-fastapi-mongo

Mongo backend for the stac-fastapi project built on top of the sfeos core api library.

PyPI version Join the chat at https://gitter.im/stac-fastapi-mongo/community

To install from PyPI:

pip install stac_fastapi.mongo

For changes, see the Changelog

Development Environment Setup

To install the classes in your local Python env, run:

pip install -e .[dev]

Pre-commit

Install pre-commit.

Prior to commit, run:

pre-commit run --all-files

Build stac-fastapi.mongo backend

docker-compose up mongo
docker-compose build app-mongo

Running Mongo API on localhost:8084

docker-compose up app-mongo

To create a new Collection:

curl -X "POST" "http://localhost:8084/collections" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "id": "my_collection"
}'

Note: this "Collections Transaction" behavior is not part of the STAC API, but may be soon.

Collection pagination

The collections route handles optional limit and token parameters. The links field that is returned from the /collections route contains a next link with the token that can be used to get the next page of results.

curl -X "GET" "http://localhost:8084/collections?limit=1&token=example_token"

Testing

make test

Ingest sample data

make ingest

Basic Auth

Environment Variable Configuration

Basic authentication is an optional feature. You can enable it by setting the environment variable BASIC_AUTH as a JSON string.

Example:

BASIC_AUTH={"users":[{"username":"user","password":"pass","permissions":"*"}]}

User Permissions Configuration

In order to set endpoints with specific access permissions, you can configure the users key with a list of user objects. Each user object should contain the username, password, and their respective permissions.

Example: This example illustrates the configuration for two users: an admin user with full permissions (*) and a reader user with limited permissions to specific read-only endpoints.

{
    "users": [
        {
            "username": "admin",
            "password": "admin",
            "permissions": "*"
        },
        {
            "username": "reader",
            "password": "reader",
            "permissions": [
                {"path": "/", "method": ["GET"]},
                {"path": "/conformance", "method": ["GET"]},
                {"path": "/collections/{collection_id}/items/{item_id}", "method": ["GET"]},
                {"path": "/search", "method": ["GET", "POST"]},
                {"path": "/collections", "method": ["GET"]},
                {"path": "/collections/{collection_id}", "method": ["GET"]},
                {"path": "/collections/{collection_id}/items", "method": ["GET"]},
                {"path": "/queryables", "method": ["GET"]},
                {"path": "/queryables/collections/{collection_id}/queryables", "method": ["GET"]},
                {"path": "/_mgmt/ping", "method": ["GET"]}
            ]
        }
    ]
}

Public Endpoints Configuration

In order to set endpoints with public access, you can configure the public_endpoints key with a list of endpoint objects. Each endpoint object should specify the path and method of the endpoint.

Example: This example demonstrates the configuration for public endpoints, allowing access without authentication to read-only endpoints.

{
    "public_endpoints": [
        {"path": "/", "method": "GET"},
        {"path": "/conformance", "method": "GET"},
        {"path": "/collections/{collection_id}/items/{item_id}", "method": "GET"},
        {"path": "/search", "method": "GET"},
        {"path": "/search", "method": "POST"},
        {"path": "/collections", "method": "GET"},
        {"path": "/collections/{collection_id}", "method": "GET"},
        {"path": "/collections/{collection_id}/items", "method": "GET"},
        {"path": "/queryables", "method": "GET"},
        {"path": "/queryables/collections/{collection_id}/queryables", "method": "GET"},
        {"path": "/_mgmt/ping", "method": "GET"}
    ],
    "users": [
        {
            "username": "admin",
            "password": "admin",
            "permissions": "*"
        }
    ]
}

Basic Authentication Configurations

See docker-compose.basic_auth_protected.yml and docker-compose.basic_auth_public.yml for basic authentication configurations.

Metadata

Release files for stac-fastapi.mongo 3.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 stac-fastapi.mongo 3.2.0
File Size Uploaded
stac_fastapi_mongo-3.2.0.tar.gz 17.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stac-fastapi.mongo 3.2.0
File Interpreter ABI Platform
stac_fastapi.mongo-3.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 33.9 kB

Release files / stac_fastapi_mongo-3.2.0.tar.gz

Download URL stac_fastapi_mongo-3.2.0.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6a353ec5927ad6ae90915370ca7b91a9b18aed33e106b0f9a36c61f9d057f416
BLAKE2b-256 checksum
How to use checksums
9d4668a60093a14f9bbad3acbd03b44ea43ded8b0945297ee7b30886bce57976
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / stac_fastapi.mongo-3.2.0-py3-none-any.whl

Download URL stac_fastapi.mongo-3.2.0-py3-none-any.whl
Size 16.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f22aace3d183bef2986036d03d5c17e447d03f14ebf65849ca14cd2bbf93d8c1
BLAKE2b-256 checksum
How to use checksums
9e6019eb1aa1bcf388745836cae6020f76e4bf3ac25712a403974df928d20ae8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

3.2.0 This release

2 release files

3.1.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.3.2

2 release files

2.3.1

2 release files

2.3.0

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