Skip to main content

datacontract api

Start the datacontract CLI as server application with REST API. The OpenAPI documentation as Swagger UI is available on http://localhost:4242. You can execute the commands directly from the Swagger UI. To protect the API, you can set the environment variable DATACONTRACT_CLI_API_KEY to a secret API key. To authenticate, requests must include the header 'x-api-key' with the correct API key. This is highly recommended, as data contract tests may be subject to SQL injections or leak sensitive information. To connect to servers (such as a Snowflake data source), set the credentials as environment variables as documented in https://docs.datacontract.com/configuration It is possible to run the API with extra arguments for uvicorn.run() as keyword arguments, e.g.: datacontract api --port 1234 --root_path /datacontract.

datacontract api [OPTIONS]
OptionDefaultDescription
--port4242Bind socket to this port.
--host127.0.0.1Bind socket to this host. Hint: For running in docker, set it to 0.0.0.0
--reload / --no-reload--no-reloadWatch the source files and restart the server on changes. For development only; off by default.
--contract-variables—Environment variables a posted data contract may read through ${VAR} references, as comma-separated fnmatch globs (e.g. 'TABLE_,CUTOFF_DATE', or '' to allow all). Empty by default.
--allow-local-files / --no-allow-local-files—Let a posted data contract read the server's own disk through servers[].type: local. Off by default.
--debug / --no-debug—Enable debug logging
datacontract api --port 4242 --host 0.0.0.0

Guide: Run as a web server.