https://github.com/rest-go/rest
Rest serves a fully RESTful API from any SQL database
https://github.com/rest-go/rest
api-server automatic-api database golang mysql no-code postgres restful-api sql sqlite
Last synced: 9 months ago
JSON representation
Rest serves a fully RESTful API from any SQL database
- Host: GitHub
- URL: https://github.com/rest-go/rest
- Owner: rest-go
- License: apache-2.0
- Created: 2023-01-02T02:41:38.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-31T05:10:16.000Z (about 1 year ago)
- Last Synced: 2025-03-28T15:09:59.770Z (9 months ago)
- Topics: api-server, automatic-api, database, golang, mysql, no-code, postgres, restful-api, sql, sqlite
- Language: Go
- Homepage: https://rest-go.com
- Size: 186 KB
- Stars: 116
- Watchers: 5
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-repositories - rest-go/rest - Rest serves a fully RESTful API from any SQL database (Go)
- awesome-starred - rest-go/rest - Rest serves a fully RESTful API from any SQL database (golang)
README
# Rest

[](https://codecov.io/gh/rest-go/rest)
[](https://hub.docker.com/r/restgo/rest)
[](https://discord.gg/vawh9RSzQ9)
Rest serves a fully RESTful API from any SQL database, PostgreSQL, MySQL, and SQLite are supported for now.
Visit https://rest-go.com for the full documentation, examples, and guides.
## Getting Started
### Start with Docker
run the server and connect to an existing database
```bash
# connect to postgres
docker run -p 3000:3000 restgo/rest -db.url "postgres://user:passwd@localhost:5432/db"
# connect to sqlite file with volume
docker run -p 3000:3000 -v $(pwd):/data restgo/rest -db.url "sqlite:///data/my.db"
```
### Use API
Assume there is a `todos` table in the database with `id`, and `title` fields:
```bash
# Create a todo item
curl -XPOST "localhost:3000/todos" -d '{"title": "setup api server", "done": false}'
# Read
curl -XGET "localhost:3000/todos/1"
# Update
curl -XPUT "localhost:3000/todos/1" -d '{"title": "setup api server", "done": true}'
# Delete
curl -XDELETE "localhost:3000/todos/1"
```
## Use the binary
### Precompiled binaries
Precompiled binaries for released versions are available on the [Releases page](https://github.com/rest-go/rest/releases), download it to your local machine, and running it directly is the fastest way to use Rest.
### Go install
If you are familiar with Golang, you can use go install
```bash
go install github.com/rest-go/rest
```
### Run server
``` bash
rest -db.url "mysql://username:password@tcp(localhost:3306)/db"
```
## Use it as a Go library
It also works to embed the rest server into an existing Go HTTP server
``` bash
go get github.com/rest-go/rest
```
```go
package main
import (
"log"
"net/http"
"github.com/rest-go/rest/pkg/server"
)
func main() {
h := server.New(&server.DBConfig{URL: "sqlite://my.db"}, server.Prefix("/admin"))
http.Handle("/admin/", h)
log.Fatal(http.ListenAndServe(":3001", nil))
}
```