2023-04-26 16:22:48 +03:00
# Cursed API for ArchiveBox
ArchiveBox [doesn't have a web API ](https://github.com/ArchiveBox/ArchiveBox/issues/496 ) yet. This is shitty single-endpoint API to automate page archiving. It uses subprocess to run archivebox CLI. archivebox CLI runs in new thread to avoid blocking main thread.
2023-04-26 16:46:36 +03:00
# Deployment
2023-04-26 16:22:48 +03:00
2023-04-26 16:46:36 +03:00
You must deploy API to server which ArchieveBox runs.
Make working directory, create virtualenv and install dependencies:
2023-04-26 16:22:48 +03:00
```
2023-04-26 16:46:36 +03:00
apt install -y git python3-venv
mkdir -p /opt/cursed_archievebox_api & & cd /opt/cursed_archievebox_api
python -m venv env
source env/bin/activate
2023-04-26 16:22:48 +03:00
pip install bottle gunicorn
2023-04-26 16:46:36 +03:00
git clone https://git.nxhs.cloud/ge/cursed-archivebox-api.git .
2023-04-26 16:22:48 +03:00
```
2023-04-26 16:46:36 +03:00
Start API. Set actual path to docker-compose.yml:
2023-04-26 16:22:48 +03:00
```
ARCHIVEBOX_BIN="docker compose -f /opt/archievebox/docker-compose.yml run archivebox" python cursed_archivebox_api.py
```
2023-04-26 16:46:36 +03:00
See also [cursed-archivebox-api.service ](cursed-archivebox-api.service ).
Install service:
```
cp cursed-archivebox-api.service /etc/systemd/system
systemctl enable --now cursed-archivebox-api.service
```
See logs:
```
journalctl -u cursed-archivebox-api.service -f
```
2023-04-26 16:22:48 +03:00
# Environment
| Variable | Default |
| ----------------- | --------------------- |
| `ARCHIVEBOX_BIN` | `/usr/bin/archivebox` (default for non-Docker installations) |
| `CURSED_PORT` | `9998` |
| `CURSED_HOST` | `0.0.0.0` |
| `CURSED_SERVER` | `gunicorn` See [server backends ](https://bottlepy.org/docs/dev/deployment.html#switching-the-server-backend ) |
# GET /add
Query parameters:
* `url` . Resource URL
* `depth` . Archive depth. Default: 0 (current page)
* `tag` . List of comma separated tags e.g. `my_tag` , `my_tag,another_one` .
2023-04-26 16:46:36 +03:00
Example request:
2023-04-26 16:22:48 +03:00
```
curl -i 'http://localhost:9998/add?url=https://example.com& depth=0& tag=api,example'
```