Execute a query

POST /api/dataset

Execute a query and retrieve the results in the usual format.

Body Required

Responses

POST /api/dataset
curl \
 -X POST http://metabase.example.com/api/dataset \
 -H "Content-Type: application/json" \
 -d '{"database":0,"native":{"query":"query"},"query":{"limit":1,"page":{"page":5,"items":5},"source_table":6},"type":"native","constraints":{"max-results":2,"max-results-bare-rows":7}}'
Request example
{
  "database": 0,
  "native": {
    "query": "query"
  },
  "query": {
    "limit": 1,
    "page": {
      "page": 5,
      "items": 5
    },
    "source_table": 6
  },
  "type": "native",
  "constraints": {
    "max-results": 2,
    "max-results-bare-rows": 7
  }
}
Request examples
{
  "type": "native",
  "query": {
    "page": {
      "page": 5,
      "items": 5
    },
    "limit": 1,
    "source_table": 6
  },
  "native": {
    "query": "query"
  },
  "database": 0,
  "constraints": {
    "max-results": 2,
    "max-results-bare-rows": 7
  }
}
Response examples (200)
{
  "json_query": {
    "database": 0,
    "native": {
      "query": "query"
    },
    "query": {
      "limit": 1,
      "page": {
        "page": 5,
        "items": 5
      },
      "source_table": 6
    },
    "type": "native",
    "constraints": {
      "max-results": 2,
      "max-results-bare-rows": 7
    }
  },
  "data": {
    "results_metadata": {
      "columns": [
        {
          "special_type": "special_type",
          "base_type": "base_type",
          "name": "name",
          "display_name": "display_name"
        },
        {
          "special_type": "special_type",
          "base_type": "base_type",
          "name": "name",
          "display_name": "display_name"
        }
      ],
      "checksum": "checksum"
    },
    "rows_truncated": 1,
    "native_form": {
      "query": "query",
      "params": "params"
    },
    "columns": [
      "columns",
      "columns"
    ],
    "rows": [
      [
        "{}",
        "{}"
      ],
      [
        "{}",
        "{}"
      ]
    ],
    "cols": [
      {
        "special_type": "special_type",
        "description": "description",
        "remapped_to": "remapped_to",
        "schema_name": "schema_name",
        "source": "source",
        "table_id": 2,
        "display_name": "display_name",
        "fk_field_id": "fk_field_id",
        "target": {
          "special_type": "special_type",
          "base_type": "base_type",
          "name": "name",
          "description": "description",
          "id": 7,
          "display_name": "display_name",
          "table_id": 1,
          "visibility_type": "visibility_type"
        },
        "extra_info": "{}",
        "base_type": "base_type",
        "name": "name",
        "fingerprint": {
          "global": {
            "distinct-count": 1
          },
          "type": "{}"
        },
        "id": 4,
        "remapped_from": "remapped_from",
        "visibility_type": "visibility_type"
      },
      {
        "special_type": "special_type",
        "description": "description",
        "remapped_to": "remapped_to",
        "schema_name": "schema_name",
        "source": "source",
        "table_id": 2,
        "display_name": "display_name",
        "fk_field_id": "fk_field_id",
        "target": {
          "special_type": "special_type",
          "base_type": "base_type",
          "name": "name",
          "description": "description",
          "id": 7,
          "display_name": "display_name",
          "table_id": 1,
          "visibility_type": "visibility_type"
        },
        "extra_info": "{}",
        "base_type": "base_type",
        "name": "name",
        "fingerprint": {
          "global": {
            "distinct-count": 1
          },
          "type": "{}"
        },
        "id": 4,
        "remapped_from": "remapped_from",
        "visibility_type": "visibility_type"
      }
    ]
  },
  "context": "context",
  "started_at": "2000-01-23 04:56:07 +0000",
  "running_time": 3,
  "average_execution_time": "average_execution_time",
  "status": "status",
  "row_count": 9
}
Response examples (200)
{
  "data": {
    "cols": [
      {
        "id": 4,
        "name": "name",
        "source": "source",
        "target": {
          "id": 7,
          "name": "name",
          "table_id": 1,
          "base_type": "base_type",
          "description": "description",
          "display_name": "display_name",
          "special_type": "special_type",
          "visibility_type": "visibility_type"
        },
        "table_id": 2,
        "base_type": "base_type",
        "extra_info": "{}",
        "description": "description",
        "fingerprint": {
          "type": "{}",
          "global": {
            "distinct-count": 1
          }
        },
        "fk_field_id": "fk_field_id",
        "remapped_to": "remapped_to",
        "schema_name": "schema_name",
        "display_name": "display_name",
        "special_type": "special_type",
        "remapped_from": "remapped_from",
        "visibility_type": "visibility_type"
      },
      {
        "id": 4,
        "name": "name",
        "source": "source",
        "target": {
          "id": 7,
          "name": "name",
          "table_id": 1,
          "base_type": "base_type",
          "description": "description",
          "display_name": "display_name",
          "special_type": "special_type",
          "visibility_type": "visibility_type"
        },
        "table_id": 2,
        "base_type": "base_type",
        "extra_info": "{}",
        "description": "description",
        "fingerprint": {
          "type": "{}",
          "global": {
            "distinct-count": 1
          }
        },
        "fk_field_id": "fk_field_id",
        "remapped_to": "remapped_to",
        "schema_name": "schema_name",
        "display_name": "display_name",
        "special_type": "special_type",
        "remapped_from": "remapped_from",
        "visibility_type": "visibility_type"
      }
    ],
    "rows": [
      [
        "{}",
        "{}"
      ],
      [
        "{}",
        "{}"
      ]
    ],
    "columns": [
      "columns",
      "columns"
    ],
    "native_form": {
      "query": "query",
      "params": "params"
    },
    "rows_truncated": 1,
    "results_metadata": {
      "columns": [
        {
          "name": "name",
          "base_type": "base_type",
          "display_name": "display_name",
          "special_type": "special_type"
        },
        {
          "name": "name",
          "base_type": "base_type",
          "display_name": "display_name",
          "special_type": "special_type"
        }
      ],
      "checksum": "checksum"
    }
  },
  "status": "status",
  "context": "context",
  "row_count": 9,
  "json_query": {
    "type": "native",
    "query": {
      "page": {
        "page": 5,
        "items": 5
      },
      "limit": 1,
      "source_table": 6
    },
    "native": {
      "query": "query"
    },
    "database": 0,
    "constraints": {
      "max-results": 2,
      "max-results-bare-rows": 7
    }
  },
  "started_at": "2000-01-23T04:56:07+00:00",
  "running_time": 3,
  "average_execution_time": "average_execution_time"
}