* Route variables and Query parameters are interpreted as scalars according to the variables types in the associated query and passed as JSON data through the query variables:
* Missing nullable variables are interpreted as ``NULL``
* Boolean variables are interpreted as ``Boolean``
* Boolean flags without values e.g. ``/api/rest/myquery?mybool`` are interpreted as ``true``
* String variables are interpreted as ``String``
* UUID variables are interpreted as ``String``
* ID variables are interpreted as ``String``
* Number, Int, Float, and Double variables are interpreted as ``Number``
***All other types or mismatches currently report variable type errors**
When making a request to this API only one endpoint should match. If multiple endpoints match your request this is considered an error and will report so via a 500 status code. If endpoints exist with your path, but none matching your HTTP method then a 405 error will be returned
listing the methods that you can use.
Sample requests
***************
..code-block:: http
GET /api/rest/simple_query/1 HTTP/1.1
..code-block:: http
POST /api/rest/complicated_mutation/2?time=now HTTP/1.1
Content-Type: application/json
{
"user": {"name": "Simon"}
}
Response
^^^^^^^^
The response is determined by the saved query. The response will be the same as if you had made the query directly in the GraphQL console.
See the :ref:`api_reference_graphql` for more details.
The OpenAPI 3 specification of the REST endpoints are exposed at ``/api/swagger/json`` for admin role only:
..code-block:: http
GET /api/swagger/json HTTP/1.1
X-Hasura-Role: admin
The response JSON will be a OpenAPI 3 specification (OAS 3.0) for all the
RESTified GraphQL Endpoints for admin roles. For more details about OAS 3.0,
`click here <https://swagger.io/specification/>`__.
Sample request
^^^^^^^^^^^^^^
..code-block:: http
GET /api/swagger/json HTTP/1.1
X-Hasura-Role: admin
Response
^^^^^^^^
..code-block:: JSON
{
"openapi": "3.0.0",
"info": {
"version": "",
"title": "Rest Endpoints",
"description": "These OpenAPI specifications are automatically generated by Hasura."
},
"paths": {
"/api/rest/users": {
"get": {
"summary": "Fetch user data",
"description": "This API fetches user data (first name and last name) from the users table.\n***\nThe GraphQl query for this endpoint is:\n``` graphql\nquery MyQuery{\n users {\n first_name\n last_name\n }\n}\n```",
"responses": {}
},
"parameters": [
{
"schema": {
"type": "string"
},
"in": "header",
"name": "x-hasura-admin-secret",
"description": "Your x-hasura-admin-secret will be used for authentication of the API request."