{"id":20347556,"url":"https://github.com/kuzudb/api-server","last_synced_at":"2025-04-12T01:02:26.410Z","repository":{"id":227086440,"uuid":"770408724","full_name":"kuzudb/api-server","owner":"kuzudb","description":"REST-style API server for the Kuzu graph database powered by Express.js.","archived":false,"fork":false,"pushed_at":"2025-02-24T16:20:50.000Z","size":49,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T20:45:27.413Z","etag":null,"topics":["graph-db","kuzu","rest-api"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/kuzudb/api-server","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kuzudb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-11T13:58:32.000Z","updated_at":"2025-03-13T13:13:09.000Z","dependencies_parsed_at":"2024-03-11T15:46:16.293Z","dependency_job_id":"1ab96648-77d0-496e-9f5d-e65f8133c847","html_url":"https://github.com/kuzudb/api-server","commit_stats":null,"previous_names":["kuzudb/api-server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuzudb%2Fapi-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuzudb%2Fapi-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuzudb%2Fapi-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuzudb%2Fapi-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kuzudb","download_url":"https://codeload.github.com/kuzudb/api-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501873,"owners_count":21114683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graph-db","kuzu","rest-api"],"created_at":"2024-11-14T22:17:07.486Z","updated_at":"2025-04-12T01:02:26.214Z","avatar_url":"https://github.com/kuzudb.png","language":"JavaScript","readme":"# Kùzu API Server\n\nREST-style API server for the Kùzu graph database powered by Express.js.\n\n## Get started\n\nKùzu API Server is launched as a Docker container. Please refer to the [Docker documentation](https://docs.docker.com/get-docker/) for details on how to install and use Docker.\n\nTo access an existing Kùzu database, you can mount its path to the `/database` directory as follows:\n\n```bash\ndocker run -p 8000:8000 \\\n           -v path/to/database:/database \\\n           --rm kuzudb/api-server:latest\n```\n\nBy mounting local database files to Docker via `-v path/to/database:/database`,\nthe changes done through the API server will persist to the local database files after the server is shutdown.\n\nThe `--rm` flag tells docker that the container should automatically be removed after we close docker.\n\nIf the launching is successful, you should see the logs similar to the following in your shell:\n\n```\n[00:46:50.833] INFO (1): Access mode: READ_WRITE\n[00:46:50.834] INFO (1): CORS enabled for all origins\n[00:46:50.853] INFO (1): Version of Kùzu: 0.3.1\n[00:46:50.854] INFO (1): Deployed server started on port: 8000\n```\n\n### Additional launch configurations\n\n#### Access mode\n\nBy default, the API server is launched in read-write mode, which means that you can modify the database. If you want to launch it in read-only mode, you can do so by setting the `MODE` environment variable to `READ_ONLY` as follows.\n\n```bash\ndocker run -p 8000:8000 \\\n           -v path/to/database:/database \\\n           -e MODE=READ_ONLY \\\n           --rm kuzudb/api-server:latest\n```\n\nThe API server will then be launched in read-only mode, and you will see the following log message:\n\n```\n[00:46:50.833] INFO (1): Access mode: READ_ONLY\n```\n\nIn read-only mode, you can still issue read queries, but you cannot run write queries or modify the schema.\n\n#### Buffer pool size\n\nBy default, the API server is launched with a maximum buffer pool size of 80% of the available memory. If you want to launch API server with a different buffer pool size, you can do so by setting the `KUZU_BUFFER_POOL_SIZE` environment variable to the desired value in bytes as follows.\n\nFor example, to launch the API server with a buffer pool size of 1GB, you can run the following command.\n\n```bash\ndocker run -p 8000:8000 \\\n           -v path/to/database:/database \\\n           -e KUZU_BUFFER_POOL_SIZE=1073741824 \\\n           --rm kuzudb/api-server:latest\n```\n\n#### Cross-Origin Resource Sharing (CORS)\n\nBy default, the API server is launched with CORS enabled for all origins. If you want to disable CORS, you can do so by setting the `CROSS_ORIGIN` environment variable to `false` as follows.\n\n```bash\ndocker run -p 8000:8000 \\\n           -v path/to/database:/database \\\n           -e CROSS_ORIGIN=false \\\n           --rm kuzudb/api-server:latest\n```\n\n### Launch with Podman\n\nIf you are using [Podman](https://podman.io/) instead of Docker, you can launch the API server by replacing `docker` with `podman` in the commands above. However, note that by default Podman maps the default user account to the `root` user in the container. This may cause permission issues when mounting local database files to the container. To avoid this, you can use the `--userns=keep-id` flag to keep the user ID of the current user inside the container, or enable `:U` option for each volume to change the owner and group of the source volume to the current user.\n\nFor example:\n\n```bash\npodman run -p 8000:8000 \\\n           -v path/to/database:/database:U \\\n           --rm kuzudb/api-server:latest\n```\n\nor,\n\n```bash\npodman run -p 8000:8000 \\\n           -v path/to/database:/database \\\n           --userns=keep-id \\\n           --rm kuzudb/api-server:latest\n```\n\nPlease refer to the official Podman docs for [mounting external volumes](https://docs.podman.io/en/latest/markdown/podman-run.1.html#mounting-external-volumes) and [user namespace mode](https://https://docs.podman.io/en/latest/markdown/podman-run.1.html#userns-mode) for more information.\n\n## API endpoints\n\nThe Kùzu API server provides the following endpoints:\n\n### `GET /`:\n\nGet the status of the server.\n\n#### Example usage:\n\nWith `fetch` in JavaScript:\n\n```javascript\nfetch(\"http://localhost:8000\")\n  .then((response) =\u003e response.json())\n  .then((data) =\u003e console.log(data));\n```\n\nWith `curl` in the terminal:\n\n```bash\ncurl http://localhost:8000\n```\n\nWith `request` in Python:\n\n```python\nimport requests\nresponse = requests.get(\"http://localhost:8000\")\nprint(response.json())\n```\n\n#### Example response:\n\n```json\n{\n  \"status\": \"ok\",\n  \"version\": \"0.3.1\",\n  \"mode\": \"READ_WRITE\"\n}\n```\n\n### `GET /schema`:\n\nGet the schema of the database.\n\n#### Example usage:\n\nWith `fetch` in JavaScript:\n\n```javascript\nfetch(\"http://localhost:8000/schema\")\n  .then((response) =\u003e response.json())\n  .then((data) =\u003e console.log(data));\n```\n\nWith `curl` in the terminal:\n\n```bash\ncurl http://localhost:8000/schema\n```\n\nWith `request` in Python:\n\n```python\nimport requests\nresponse = requests.get(\"http://localhost:8000/schema\")\nprint(response.json())\n```\n\n#### Example response:\n\n```json\n{\n  \"nodeTables\": [\n    {\n      \"name\": \"City\",\n      \"comment\": \"\",\n      \"properties\": [\n        {\n          \"name\": \"name\",\n          \"type\": \"STRING\",\n          \"isPrimaryKey\": true\n        },\n        {\n          \"name\": \"population\",\n          \"type\": \"INT64\",\n          \"isPrimaryKey\": false\n        }\n      ]\n    },\n    {\n      \"name\": \"User\",\n      \"comment\": \"\",\n      \"properties\": [\n        {\n          \"name\": \"name\",\n          \"type\": \"STRING\",\n          \"isPrimaryKey\": true\n        },\n        {\n          \"name\": \"age\",\n          \"type\": \"INT64\",\n          \"isPrimaryKey\": false\n        }\n      ]\n    }\n  ],\n  \"relTables\": [\n    {\n      \"name\": \"Follows\",\n      \"comment\": \"\",\n      \"properties\": [\n        {\n          \"name\": \"since\",\n          \"type\": \"INT64\"\n        }\n      ],\n      \"src\": \"User\",\n      \"dst\": \"User\"\n    },\n    {\n      \"name\": \"LivesIn\",\n      \"comment\": \"\",\n      \"properties\": [],\n      \"src\": \"User\",\n      \"dst\": \"City\"\n    }\n  ],\n  \"relGroups\": [],\n  \"rdf\": []\n}\n```\n\n### `POST /cypher`:\n\nExecute a Cypher query and get the result. The request body should be a JSON object with a `query` field containing the Cypher query and an optional `params` field containing the parameters for the query (if the query is a parameterized query / prepared statement).\n\n#### Example usage:\n\nWith `fetch` in JavaScript:\n\n```javascript\nfetch(\"http://localhost:8000/cypher\", {\n  method: \"POST\",\n  headers: {\n    \"Content-Type\": \"application/json\",\n  },\n  body: JSON.stringify({\n    query: \"MATCH (u:User) WHERE u.age \u003e $a RETURN u\",\n    params: {\n      a: 20,\n    },\n  }),\n})\n  .then((response) =\u003e response.text())\n  .then((data) =\u003e console.log(data));\n```\n\nWith `curl` in the terminal:\n\n```bash\ncurl -X POST\\\n     -H \"Content-Type: application/json\" \\\n     -d '{\"query\":\"MATCH (u:User) WHERE u.age \u003e $a RETURN u\",\"params\":{\"a\":25}}' \\\n     http://localhost:8000/cypher\n```\n\nWith `request` in Python:\n\n```python\nimport requests\nresponse = requests.post(\"http://localhost:8000/cypher\", \\\n                         json={\n                          \"query\": \"MATCH (u:User) WHERE u.age \u003e $a RETURN u\",\n                          \"params\": {\"a\": 25}\n                          }\n                        )\nprint(response.json())\n```\n\n#### Example response:\n\n```json\n{\n  \"rows\": [\n    {\n      \"u\": {\n        \"name\": \"Adam\",\n        \"age\": 30,\n        \"_label\": \"User\",\n        \"_id\": { \"offset\": 0, \"table\": 0 }\n      }\n    },\n    {\n      \"u\": {\n        \"name\": \"Karissa\",\n        \"age\": 40,\n        \"_label\": \"User\",\n        \"_id\": { \"offset\": 1, \"table\": 0 }\n      }\n    },\n    {\n      \"u\": {\n        \"name\": \"Zhang\",\n        \"age\": 50,\n        \"_label\": \"User\",\n        \"_id\": { \"offset\": 2, \"table\": 0 }\n      }\n    }\n  ],\n  \"dataTypes\": { \"u\": \"NODE\" },\n  \"isSchemaChanged\": false\n}\n```\n\n## Deployment\n\nA [GitHub actions pipeline](.github/workflows/build-and-deploy.yml) has been configured to automatically build and deploy\nthe Docker image to [Docker Hub](https://hub.docker.com/) upon pushing to the master branch. The pipeline will build images\nfor both `amd64` and `arm64` platforms.\n\n## Contributing\n\nWe welcome contributions to Kùzu API Server. By contributing to Kùzu API Server, you agree that your contributions will be licensed under the [MIT License](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuzudb%2Fapi-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkuzudb%2Fapi-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuzudb%2Fapi-server/lists"}