-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,102 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "ae17559e", | ||
"metadata": {}, | ||
"source": [ | ||
"# Using a self-hosted API server\n", | ||
"\n", | ||
"In this notebook we go over the steps required to set up and connect to a self-hosted [API server](https://hub.docker.com/r/opvious/api-server), allowing you to host your own Opvious platform.\n", | ||
"\n", | ||
"<div class=\"alert alert-block alert-warning\">\n", | ||
" ⚠ The API server's image is subject to the <a href=\"https://www.opvious.io/end-user-license-agreements/api-image\">Opvious API image EULA</a>. Commercial use requires a separate license which can be requested <a href=\"https://forms.gle/8ZP2zr91TY9TPcp66\">here</a>.\n", | ||
"</div>\n", | ||
"\n", | ||
"\n", | ||
"## Starting the server\n", | ||
"\n", | ||
"### With the CLI\n", | ||
"\n", | ||
"The simplest way to download and run the API server is with the [Opvious CLI](https://www.npmjs.com/package/opvious-cli#starting-an-api-server). The CLI will take care of setting up the server's dependencies automatically before starting it:\n", | ||
"\n", | ||
"```sh\n", | ||
"npm install -g opvious-cli # Install the CLI\n", | ||
"opvious api start # Start the API server along with its dependencies\n", | ||
"```\n", | ||
"\n", | ||
"Refer to the CLI's README or run `opvious api --help` to view the list of available commands. You may also be interested in the server's telemetry configuration options described [here](https://hub.docker.com/r/opvious/api-server).\n", | ||
"\n", | ||
"\n", | ||
"### From the Docker image\n", | ||
"\n", | ||
"Alternatively, you can download and run the [`opvious/api-server`](https://hub.docker.com/r/opvious/api-server) Docker image directly. This allows you to use it with your own database and/or cache:\n", | ||
"\n", | ||
"```\n", | ||
"docker run -p 8080:8080 \\\n", | ||
" -e DB_URL=postgres:// \\\n", | ||
" -e REDIS_URL=redis:// \\\n", | ||
" -e OPVIOUS_API_IMAGE_EULA \\\n", | ||
" opvious/api-server\n", | ||
"```\n", | ||
"\n", | ||
"Refer to the image's documentation for more information.\n", | ||
"\n", | ||
"\n", | ||
"## Connecting to the server\n", | ||
"\n", | ||
"Once the API server is running, the next step is to use it from the SDKs. To do so, simply set the `OPVIOUS_ENDPOINT` environment variable to the server's endpoint (http://localhost:8080 if started via the CLI with default options). For example from your Bash configuration:\n", | ||
"\n", | ||
"```\n", | ||
"# ~/.bashrc\n", | ||
"OPVIOUS_ENDPOINT=http://localhost:8080\n", | ||
"```\n", | ||
"\n", | ||
"You may also find it useful to create a [dedicated configuration profile](https://www.npmjs.com/package/opvious-cli#configuration-profiles) pointing to it:\n", | ||
"\n", | ||
"```\n", | ||
"# ~/.config/opvious/cli.yml\n", | ||
"profiles:\n", | ||
" - name: local\n", | ||
" endpoint: http://localhost:8080\n", | ||
"```\n", | ||
"\n", | ||
"\n", | ||
"## Authenticating requests\n", | ||
"\n", | ||
"The server's `STATIC_TOKENS` environment variable is used to specify a comma-separated list of static API tokens for authenticating API requests. Each entry's format is `<email>=<token>`, where `<email>` is the associated account's email. When using the CLI, this variable is set with the `-t` option:\n", | ||
"\n", | ||
"```sh\n", | ||
"opvious api start -t [email protected]=secret-token\n", | ||
"```\n", | ||
"\n", | ||
"These tokens can then be used as regular API tokens in SDKs by prefixing them with `static:`. For example requests to the server started with the command just above can be authenticated as `[email protected]` by setting `OPVIOUS_TOKEN=static:secret-token`." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "75b0bdbb", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.5" | ||
} | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "ae17559e", | ||
"metadata": {}, | ||
"source": [ | ||
"# Using a self-hosted API server\n", | ||
"\n", | ||
"In this notebook we go over the steps required to set up and connect to a self-hosted [API server](https://hub.docker.com/r/opvious/api-server), allowing you to host your own Opvious platform.\n", | ||
"\n", | ||
"\n", | ||
"## Starting the server\n", | ||
"\n", | ||
"### With the CLI\n", | ||
"\n", | ||
"The simplest way to download and run the API server is with the [Opvious CLI](https://www.npmjs.com/package/opvious-cli#starting-an-api-server). The CLI will take care of setting up the server's dependencies automatically before starting it:\n", | ||
"\n", | ||
"```sh\n", | ||
"npm install -g opvious-cli # Install the CLI\n", | ||
"opvious api start # Start the API server along with its dependencies\n", | ||
"```\n", | ||
"\n", | ||
"Refer to the CLI's README or run `opvious api --help` to view the list of available commands. You may also be interested in the server's telemetry configuration options described [here](https://hub.docker.com/r/opvious/api-server).\n", | ||
"\n", | ||
"\n", | ||
"### From the Docker image\n", | ||
"\n", | ||
"Alternatively, you can download and run the [`opvious/api-server`](https://hub.docker.com/r/opvious/api-server) Docker image directly. This allows you to use it with your own database and/or cache:\n", | ||
"\n", | ||
"```\n", | ||
"docker run -p 8080:8080 \\\n", | ||
" -e DB_URL=postgres:// \\\n", | ||
" -e REDIS_URL=redis:// \\\n", | ||
" -e OPVIOUS_API_IMAGE_EULA \\\n", | ||
" opvious/api-server\n", | ||
"```\n", | ||
"\n", | ||
"Refer to the image's documentation for more information.\n", | ||
"\n", | ||
"\n", | ||
"## Connecting to the server\n", | ||
"\n", | ||
"Once the API server is running, the next step is to use it from the SDKs. To do so, simply set the `OPVIOUS_ENDPOINT` environment variable to the server's endpoint (http://localhost:8080 if started via the CLI with default options). For example from your Bash configuration:\n", | ||
"\n", | ||
"```\n", | ||
"# ~/.bashrc\n", | ||
"OPVIOUS_ENDPOINT=http://localhost:8080\n", | ||
"```\n", | ||
"\n", | ||
"You may also find it useful to create a [dedicated configuration profile](https://www.npmjs.com/package/opvious-cli#configuration-profiles) pointing to it:\n", | ||
"\n", | ||
"```\n", | ||
"# ~/.config/opvious/cli.yml\n", | ||
"profiles:\n", | ||
" - name: local\n", | ||
" endpoint: http://localhost:8080\n", | ||
"```\n", | ||
"\n", | ||
"\n", | ||
"## Authenticating requests\n", | ||
"\n", | ||
"The server's `STATIC_TOKENS` environment variable is used to specify a comma-separated list of static API tokens for authenticating API requests. Each entry's format is `<email>=<token>`, where `<email>` is the associated account's email. When using the CLI, this variable is set with the `-t` option:\n", | ||
"\n", | ||
"```sh\n", | ||
"opvious api start -t [email protected]=secret-token\n", | ||
"```\n", | ||
"\n", | ||
"These tokens can then be used as regular API tokens in SDKs by prefixing them with `static:`. For example requests to the server started with the command just above can be authenticated as `[email protected]` by setting `OPVIOUS_TOKEN=static:secret-token`." | ||
] | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "75b0bdbb", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |