Skip to content

OpenShock API

DocumentationGitHub licenseGitHub SponsorsDiscord

masterBuild StatusCodeQL Status
developBuild StatusCodeQL Status

API Documentation

You can access our Open API Doc here:

https://api.openshock.app/scalar/viewer

Configuration

The API can be configured using the following environment variables. These variables should be available to all containers in the stack. Preferred way is a .env file.

VariableRequiredDefault valueAllowed / Example value
OPENSHOCK__DB__CONNxHost=postgres-server-host;Port=5432;Database=openshock;Username=openshock;Password=superSecurePassword
OPENSHOCK__DB__SKIPMIGRATIONfalsetrue, false
OPENSHOCK__DB__DEBUGfalsetrue, false
OPENSHOCK__ACCOUNT__REGISTRATIONENABLEDtruetrue, false - false disables new user sign-ups
OPENSHOCK__FRONTEND__BASEURLxhttps://my-openshock-instance.net or https://shocklink.net
OPENSHOCK__FRONTEND__SHORTURLxhttps://myoi.net or https://shockl.ink
OPENSHOCK__FRONTEND__COOKIEDOMAINxmy-openshock-instance.net
OPENSHOCK__REDIS__CONNxredis-server-host:6379
OPENSHOCK__MAIL__SENDER__EMAILxsystem@my-openshock-instance.net
OPENSHOCK__MAIL__SENDER__NAMExMyOpenShockInstance System
OPENSHOCK__MAIL__TYPExMAILJET, SMTP
OPENSHOCK__TURNSTILE__ENABLExtrue, false

Refer to the Npgsql Connection String documentation page for details about OPENSHOCK__DB_CONN. Refer to StackExchange.Redis Configuration documentation page for details about OPENSHOCK__REDIS__CONN.

Turnstile

When Turnstile enable is set to true, the following environment variable is required:

VariableRequiredDefault valueAllowed / Example value
OPENSHOCK__TURNSTILE__SITEKEYx
OPENSHOCK__TURNSTILE__SECRETKEYx

EMail

MAILJET

You need these environment variables to use Mailjet:

VariableRequiredDefault valueAllowed / Example value
OPENSHOCK__MAIL__MAILJET__KEYx
OPENSHOCK__MAIL__MAILJET__SECRETx

SMTP

You need these environment variables to use SMTP:

VariableRequiredDefault valueAllowed / Example value
OPENSHOCK__MAIL__SMTP__HOSTxmail.my-openshock-instance.net
OPENSHOCK__MAIL__SMTP__PORT587587
OPENSHOCK__MAIL__SMTP__USERNAMExsystem@my-openshock-instance.net
OPENSHOCK__MAIL__SMTP__PASSWORDxsuperSecurePassword
OPENSHOCK__MAIL__SMTP__ENABLESSLtruetrue or false
OPENSHOCK__MAIL__SMTP__VERIFYCERTIFICATEtruetrue or false

(Live Control) Gateway

These are the environment variables for the live control gateway. They are only required on the gateway container and are configuration local to the gateway.

VariableRequiredDefault valueAllowed / Example value
OPENSHOCK__LCG__FQDNxde1-gateway.my-openshock-instance.netde1-gateway.shocklink.net
OPENSHOCK__LCG__COUNTRYCODExDE or XX as a placeholder / unknown

Deployment / Self Hosting

The OpenShock stack consists of the following components:

  • Postgres as database
  • Redis-Stack (with keyspace events KEA) (preferably DragonflyDB)
  • One or multiple APIs (container, API)
  • One or multiple gateways (container, LCG)
  • One or multiple cron daemons (container, CRON)
  • Frontend - stateless, can run on edge

Requirements

OpenShock instance needs to be under the same domain name to work correctly. This is due to cookie limitations in browsers.

Frontend: https://openshock.app API: https://api.openshock.app LCG: https://de1-gateway.openshock.app

In this case your cookie domain would be openshock.app, even if the frontend would be hosted under e.g. https://frontend.openshock.app

Using Docker (provided docker-compose.yml)

  1. Grab the docker-compose.yml and .env file from the repository
  2. Change the values in the .env file
  3. Adjust traefik to your needs (e.g. add SSL certificates)

Run with docker compose up -d


You could also bring your own reverse proxy.
You would need to remove traefik from the docker-compose.yml and route the traffic in your reverse proxy.

Support development!

You can support the OpenShock Dev Team here: Sponsor OpenShock

About

Backend for the OpenShock solution, that enables controlling shock collars over the internet.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

24 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages