{"id":22892384,"url":"https://github.com/b4fun/sqlite-rest","last_synced_at":"2025-05-07T18:09:31.265Z","repository":{"id":38353209,"uuid":"494999315","full_name":"b4fun/sqlite-rest","owner":"b4fun","description":"sqlite-rest adds a RESTful API to any SQLite database","archived":false,"fork":false,"pushed_at":"2025-05-05T09:50:08.000Z","size":231,"stargazers_count":48,"open_issues_count":12,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-07T18:09:25.387Z","etag":null,"topics":["api","database","golang","postgrest","rest","sql","sqlite","sqlite-rest","sqlite3"],"latest_commit_sha":null,"homepage":"","language":"Go","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/b4fun.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":"2022-05-22T08:16:59.000Z","updated_at":"2025-05-01T15:23:37.000Z","dependencies_parsed_at":"2025-02-07T05:29:25.484Z","dependency_job_id":null,"html_url":"https://github.com/b4fun/sqlite-rest","commit_stats":{"total_commits":92,"total_committers":3,"mean_commits":"30.666666666666668","dds":0.5108695652173914,"last_synced_commit":"46168ff753418dab9b703b5a5f17133d80f78645"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b4fun%2Fsqlite-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b4fun%2Fsqlite-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b4fun%2Fsqlite-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b4fun%2Fsqlite-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/b4fun","download_url":"https://codeload.github.com/b4fun/sqlite-rest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252931555,"owners_count":21827112,"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":["api","database","golang","postgrest","rest","sql","sqlite","sqlite-rest","sqlite3"],"created_at":"2024-12-13T22:59:46.901Z","updated_at":"2025-05-07T18:09:31.234Z","avatar_url":"https://github.com/b4fun.png","language":"Go","readme":"\u003ch3 align=\"center\"\u003e\n\u003ca href=\"https://github.com/b4fun/sqlite-rest\"\u003e\n\u003cimg src=\"docs/assets/logo.svg\" width=\"180px\" height=\"auto\" style=\"inline-block\"\u003e\n\u003c/a\u003e\n\u003c/h3\u003e\n\n\u003ch4 align=\"center\"\u003e\nServe a RESTful API from any SQLite database\n\u003c/h4\u003e\n\n**sqlite-rest** is similar to [PostgREST][postgrest], but for [SQLite][sqlite]. It's a standalone web server that adds a RESTful API to any SQLite database.\n\n[PostgREST]: https://postgrest.org/en/stable/\n[SQLite]: https://www.sqlite.org/\n\n## Installation\n\n### Build From Source\n\n```\n$ go install github.com/b4fun/sqlite-rest@latest\n$ sqlite-rest\n\u003comitted help output\u003e\n```\n\n### Using docker image\n\n```\n$ docker run -it --rm ghcr.io/b4fun/sqlite-rest/server:main\n\u003comitted help output\u003e\n```\n\n## Quick Start\n\nSuppose we are serving a book store database with the following schema:\n\n```sql\nCREATE TABLE books (\n  id INTEGER PRIMARY KEY,\n  title TEXT NOT NULL,\n  author TEXT NOT NULL,\n  price REAL NOT NULL\n);\n```\n\n### Create a database\n\n```\n$ sqlite3 bookstore.sqlite3 \u003c examples/bookstore/data.sql\n```\n\n### Start server\n\n```\n$ echo -n \"topsecret\" \u003e test.token\n$ sqlite-rest serve --auth-token-file test.token --security-allow-table books --db-dsn ./bookstore.sqlite3\n{\"level\":\"info\",\"ts\":1672528510.825417,\"logger\":\"db-server\",\"caller\":\"sqlite-rest/server.go:121\",\"msg\":\"server started\",\"addr\":\":8080\"}\n... \u003comitted logs\u003e\n```\n\n### Generate authentication token\n\n**NOTE: the following steps create a sample token for testing only, please use a strong password in production.**\n\n- Visit https://jwt.io/\n- Choose `HS256` as the algorithm\n- Enter `topsecret` as the secret\n- Copy the encoded JWT from the encoded output\n- Export the token as an environment variable\n\n  ```\n  $ export AUTH_TOKEN=\u003cencoded jwt\u003e\n  ```\n\n\n### Querying\n\n**Querying by book id**\n\n```\n$ curl -H \"Authorization: Bearer $AUTH_TOKEN\" http://127.0.0.1:8080/books?id=eq.1\n[\n {\n  \"author\": \"Stephen King\",\n  \"id\": 1,\n  \"price\": 23.54,\n  \"title\": \"Fairy Tale\"\n }\n]\n```\n\n**Querying by book price**\n\n```\n$ curl -H \"Authorization: Bearer $AUTH_TOKEN\" http://127.0.0.1:8080/books?price=lt.10\n[\n {\n  \"author\": \"Alice Hoffman\",\n  \"id\": 2,\n  \"price\": 1.99,\n  \"title\": \"The Bookstore Sisters: A Short Story\"\n },\n {\n  \"author\": \"Caroline Peckham\",\n  \"id\": 4,\n  \"price\": 8.99,\n  \"title\": \"Zodiac Academy 8: Sorrow and Starlight\"\n }\n]\n```\n\n## Features\n\n### Parity with PostgRest\n\nsqlite-rest aims to implement the same API as PostgRest. But currently not all of them are being implemented. Below is a list that features supported in sqlite-rest. If you need support for implementing a feature absent in the list, feel free to create an issue :smile:\n\n- Tables and Views\n  - [x] Horizontal Filtering (Rows)\n  - [x] Vrtical Filtering (Columns)\n  - [x] Unicode support\n  - [x] Ordering\n  - [x] Limit and Pagination\n  - [x] Exact Count\n- Insertions\n  - [x] Specifying Columns\n- [x] Updates\n- [x] Upsert\n- [x] Deletions\n\n### Authentication\n\nsqlite-rest provides built-in JWT based authentication. To use `HS256` / `HS384` / `HS512` algorithm, please specific the token file to read from via `--auth-token-file` flag. To use `RS256` / `RS384` / `RS512` algorithm, please specify the public key via `--auth-rsa-public-key` flag.\n\n### Tables/Views Access\n\nBy default, sqlite-rest exposes **no** tables/views from accessing. To allow access to specific tables/views, please use `--security-allow-table` flag:\n\n**one table**\n\n```\n--security-allow-table books\n```\n\n**multiple tables**\n\n```\n--security-allow-table books,authors\n```\n\n### Metrics\n\nsqlite-rest exposes metrics via [Prometheus][prometheus] format. By default, these metrics are exposed via `:8081/metrics` endpoint. To change the endpoint, please use `--metrics-addr` flag. To disable metrics, specific `--metrics-addr` to `\"\"`.\n\nRecorded metrics can be found in [metrics.go](metrics.go).\n\n[prometheus]: https://prometheus.io/\n\n### Database Migrations\n\nsqlite-rest supports database migrations via [golang-migrate][golang-migrate].\n\n**Apply migrations**\n\n```\n$ sqlite-rest migrate --db-dsn ./bookstore.sqlite3 ./examples/migrations\n{\"level\":\"info\",\"ts\":1672614524.2731035,\"logger\":\"db-migrator.up\",\"caller\":\"sqlite-rest/migrate.go:136\",\"msg\":\"applying operation\"}\n{\"level\":\"info\",\"ts\":1672614524.3081956,\"logger\":\"db-migrator.up\",\"caller\":\"sqlite-rest/migrate.go:140\",\"msg\":\"applied operation\"}\n```\n\n**Rollback migrations**\n\n```\n$ sqlite-rest migrate --db-dsn ./bookstore.sqlite3 --direction down --step 1 ./examples/migrations\n```\n\n[golang-migrate]: https://github.com/golang-migrate/migrate\n\n## License\n\nMIT","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb4fun%2Fsqlite-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fb4fun%2Fsqlite-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb4fun%2Fsqlite-rest/lists"}