v1

latestOpenAPI 3.0.3Apache 2.02026-07-13161446.9 KB
Data API

Get a document (with input)

The server will return a bad request (400) response if either:

  • The query requires an input document and you do not provide it
  • You provided an input document but the query has already defined it.

If path indexes into an array, the server will attempt to convert the array index to an integer. If the path element cannot be converted to an integer, a not found response (404) will be returned.

post/v1/data/{path}

Query parameters

prettyboolean

If true, response will be in a human-readable format.

provenanceboolean

If true, response will include build and version information in addition to the result.

explainstring

If set to full, response will include query explanations in addition to the result.

metricsboolean

If true, compiler performance metrics will be returned in the response.

instrumentboolean

If true, response will return additional performance metrics in addition to the result and the standard metrics.

Caution: This can add significant overhead to query evaluation. The recommendation is to only use this parameter if you are debugging a performance problem.

Response

Success

Example response

{
  "result": [
    {
      "id": "example2",
      "raw": "package opa.examples\\n\\nimport data.servers\\n\\nviolations[server] {\\n\\tserver = servers[_]\\n\\tserver.protocols[_] = \\\"http\\\"\\n\\tpublic_servers[server]\\n}\\n",
      "ast": {
        "package": {
          "path": [
            {
              "type": "import",
              "value": "data.opa.example"
            }
          ]
        },
        "rules": [
          {
            "head": {
              "name": "violations",
              "key": {
                "type": "var",
                "value": "$0"
              }
            },
            "body": [
              {
                "index": 1,
                "terms": [
                  {
                    "type": "var"
                  }
                ]
              }
            ]
          }
        ]
      }
    }
  ],
  "provenance": {
    "build_commit": "4c6e524",
    "build_hostname": "3bb58334a5a9"
  },
  "metrics": {
    "timer_rego_input_parse_ns": 69994,
    "timer_rego_query_parse_ns": 4096,
    "timer_rego_query_compile_ns": 4096,
    "timer_rego_query_eval_ns": 69994,
    "timer_rego_module_parse_ns": 12345,
    "timer_rego_module_compile_ns": 69994,
    "timer_server_handler_ns": 631000,
    "timer_server_read_bytes_ns": 631000,
    "timer_query_compile_stage_build_comprehension_index_ns": 43000,
    "timer_query_compile_stage_check_safety_ns": 852000,
    "timer_query_compile_stage_check_types_ns": 577000,
    "timer_query_compile_stage_check_undefined_funcs_ns": 426000,
    "timer_query_compile_stage_check_unsafe_builtins_ns": 14000,
    "timer_query_compile_stage_resolve_refs_ns": 3000,
    "timer_query_compile_stage_rewrite_comprehension_terms_ns": 329000,
    "timer_query_compile_stage_rewrite_dynamic_terms_ns": 27000,
    "timer_query_compile_stage_rewrite_expr_terms_ns": 40000,
    "timer_query_compile_stage_rewrite_local_vars_ns": 187000,
    "timer_query_compile_stage_rewrite_to_capture_value_ns": 1178000,
    "timer_query_compile_stage_rewrite_with_values_ns": 23000
  },
  "explanation": [
    {
      "op": "enter",
      "type": "expr",
      "node": {
        "terms": [
          {
            "type": "var",
            "value": "$term1"
          }
        ]
      }
    }
  ]
}