Metadata-Version: 2.4
Name: js-api
Version: 0.2.99
Summary: Custom API written in Python using FastAPI
Author-email: Jack Stockley <jack@jstockley.com>
Project-URL: Homepage, https://github.com/jnstockley/api
Project-URL: Repository, https://github.com/jnstockley/api.git
Project-URL: Issues, https://github.com/jnstockley/api/issues
Keywords: starter,template,python
Classifier: Programming Language :: Python :: 3
Requires-Python: <4.0,>=3.14
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastapi[standard]==0.141.1
Requires-Dist: sqlalchemy==2.0.54
Requires-Dist: sqlmodel==0.0.44
Requires-Dist: python-dotenv==1.2.3
Requires-Dist: psycopg[binary]==3.3.6
Requires-Dist: nctalk==0.0.4
Dynamic: license-file

# API
This is a custom API, written in Python using FastAPI, to help me accomplish tasks the can be improved through a RESTful API

## Setup
Simplest setup is to start from [compose.yml](https://github.com/jnstockley/api/blob/dev/compose.yml) and [template.env](https://github.com/jnstockley/api/blob/dev/template.env), which should be renamed to `.env`

### Environment Vairables
- `API_KEY` - Any long, random string. Keep this secret as this is the only form of authentication for the API. All routes require it, except `/health-check/`
- `DATABASE_URL` - The URL to connect to postgres DB. Must start with `postgresql+psycopg://`. Should be in the format specifiec in [template.env](https://github.com/jnstockley/api/blob/dev/template.env)
- `TZ` - Timezone of the container
- `PGTZ` - Timezone the Postgres container should use
- `NEXTCLOUD_URL` - Base URL (must be `https://`) of the Nextcloud instance used by `/webhook/nextcloud-talk`
- `NEXTCLOUD_TALK_TOKEN` - Conversation token of the registered [Nextcloud Talk bot](https://nextcloud-talk.readthedocs.io/en/latest/bot-list/) used by `/webhook/nextcloud-talk`
- `NEXTCLOUD_TALK_SECRET` - Shared secret of the registered Nextcloud Talk bot used by `/webhook/nextcloud-talk`

## Webhooks
- `POST /webhook/nextcloud-talk` - Forwards a `header` and `message` to a Nextcloud Talk conversation via the [Nextcloud Talk Bot API](https://nextcloud-talk.readthedocs.io/en/latest/bot-list/), using the [nctalk](https://pypi.org/project/nctalk/) package. Requires the `X-API-KEY` header and a JSON body: `{"header": "...", "message": "..."}`

## How to Access
Using the [compose.yml](https://github.com/jnstockley/api/blob/dev/compose.yml) file, you can access the API at `http://<IP>:5000/health-check`. If everything is setup correctly, you should see `{"status":"ok"}`
