Generate full-featured API servers for your database tables in seconds.
AutoREST is a database-agnostic RESTful API generator for Ruby. With just your database credentials, it scaffolds a live API server supporting CRUD operations — no Rails, no boilerplate.
Supported Databases:
- SQLite
- MySQL
- PostgreSQL
- Oracle
- 🛠 Generates RESTful APIs from your database schema
- 🔌 Pluggable DB adapter system
- 🎛 CLI interface powered by Thor
- 🗃 Supports major relational DBs via corresponding gems
- 🔥 Runs on Puma + Rack
Add this line to your application's Gemfile:
gem 'autorest'
And then execute:
$ bundle install
Or install it as a gem:
$ gem install autorest
Note: Depending on the DB you use, you may need to install additional gems manually:
sqlite3
mysql2
pg
ruby-oci8
To get your hand on AutoREST, run:
autorest boot sqlite://[path/to/sqlite.db]/[table_name]
If you want to try with MySQL/PostgreSQL/Oracle, run:
autorest boot mysql://[username]:[password]@[host]:[port]/[database]/[table_name]
for PostgreSQL (or) Oracle, use pg://
(or) orcl://
respectively instead of mysql://
Now you can access the server at http://localhost:7914
- Via Interactive CLI
$ autorest new
- Via YAML config file
$ autorest server <path/to/config>.yml
- Via DSN
$ autorest boot mysql://[username]:[password]@[host]:[port]/[database]/[table_name]
For more information visit AutoREST documentation.
db:
kind: :mysql # :sqlite, :mysql, :pg, :orcl
host: localhost
port: 3306
user: root
passwd: secret
name: mydb # for sqlite: path/to/sqlite.db, for oracle: SID
tables: [users, posts]
server:
host: 127.0.0.1
port: 8080
Once the server is running, you can access the following RESTful API endpoints for the selected tables:
GET /<table>
- Returns all rows from tableGET /<table>/:id
- Returns a single row by ID (or any primary key)POST /<table>
- Creates a new row in tablePUT /<table>/:id
- Updates an existing row by ID (or any primary key)PATCH /<table>/:id
- Updates an existing row by ID (or any primary key)DELETE /<table>/:id
- Deletes a row by ID (or any primary key)
The PATCH
method simply allows one to update a subset of the columns, whereas the PUT
method allows one to update all columns.
Contributions are welcome! While the basic functionality of this project works, there is a lot of room for improvement. If you have any suggestions or find any bugs, please open an issue or create a pull request.