Skip to main content

An opinionated wrapper around FastAPI with custom microservice registration

Project description

Picoapi

A wrapper around FastAPI to simplify microservice creation. Very opinionated but also simple to fork if you would like to add your own version of service registration and configuration to FastAPI.

Usage

create a .env file or export the following variables:

ENV variable Required (default) Default Description Examples Implemented
API_HOST Yes The host of the API myhost|123.123.123.123|localhost|127.0.0.1
API_PORT No 8888 The port of the API 8080
API_BIND Yes The interface descriptor to bind to 127.0.0.1|0.0.0.0
API_TITLE Yes The FastAPI title Example API Name
API_DESCRIPTION No A brief Description The FastAPI description An Example of a short description about an API
API_REGISTER_PATH Yes The url of the Keeper registration endpoint (similar to consul) http://keeper:8100/register
API_HEALTH_PATH No The path relative to this FastAPI to call for health checks /health
API_HEALTH_INTERVAL No 300 The frequency to perform health checks (in seconds) 300
API_VERSION No 0.0.1 The version of this FastAPI 0.0.1-alpha
API_TAGS No The tags for this microservice, used as part of discovery, delimited with ":" (like $PATH) servicetag1:servicetag2:servicetag3
API_CORS_ALLOW_ORIGINS No * The CORS allowed origins, delimited with "!" No
API_CORS_ALLOW_METHODS No * The CORS allowed methods, delimited with "!" No
API_CORS_ALLOW_HEADERS No * The CORS allowed headers, delimited with "!" No

Example .env file:

# API config
# ==========
API_BIND="0.0.0.0"
API_HOST="localhost"
API_PORT="8888"
API_TITLE="test"
API_DESCRIPTION="test description"
API_VERSION="0.0.1-alpha"

# microservice registration
# =========================
API_KEEPER_URL="http://localhost:8100/register"
API_HEALTH_PATH="/health"
API_HEALTH_INTERVAL="300"

Authors & Contributors

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

picoapi-0.0.2.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

picoapi-0.0.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file picoapi-0.0.2.tar.gz.

File metadata

  • Download URL: picoapi-0.0.2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for picoapi-0.0.2.tar.gz
Algorithm Hash digest
SHA256 8e7cf119aa661dcb5f9c2e493847168c3853fc0cb6b6cecf3fb7d9401ca9b1b1
MD5 89b4fc49df8c4049b6f7ee5d929b7a3f
BLAKE2b-256 8b47be0b9308692f2533090e33b812d8ae2516bf1f599cd49e538a7ea5d96ec1

See more details on using hashes here.

File details

Details for the file picoapi-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: picoapi-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for picoapi-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7bc3fb856ed3be5465761af73ad777ee23b18548786cdb978f2e7c3689054715
MD5 a623860f0176ca938469cec84427844f
BLAKE2b-256 6024e8ac673c34473edf620f928983c811f8caafaa04f4e1db38436e54675d36

See more details on using hashes here.

Supported by

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