ROAPI automatically spins up read-only APIs for static datasets without requiring you to write a single line of code. It builds on top of Apache Arrow and Datafusion. The core of its design can be boiled down to the following:
- Query frontends to translate SQL, FlightSQL, GraphQL and REST API queries into Datafusion plans.
- Datafusion for query plan execution.
- Data layer to load datasets from a variety of sources and formats with automatic schema inference.
- Response encoding layer to serialize intermediate Arrow record batch into various formats requested by client.
See below for a high level diagram:
Check out Github release page for pre-built binaries for each platform. Pre-built docker images are also available at ghcr.io/roapi/roapi.
Spin up APIs for test_data/uk_cities_with_headers.csv and test_data/spacex_launches.json:
Or using docker:
Query data using the builtin web UI at http://localhost:8080/ui:
Query data using SQL, GraphQL or REST via curl:
Get inferred schema for all tables:
For MySQL and SQLite, specify the table argument like below:
Want dynamic register data? Add parameter -d to command. --table parameter cannot be ignored for now.
Then post config to /api/table register data.
For windows, full scheme(file:// or filesystem://) must filled, and use double quote(") instead of single quote(') to escape windows cmdline limit:
You can also configure multiple table sources using YAML or Toml config, which supports more advanced format specific table options:
To run serve tables using config file:
See config documentation for more options including using Google spreadsheet as a table source.
By default, ROAPI encodes responses in JSON format, but you can request different encodings by specifying the ACCEPT header:
You can query tables through REST API by sending GET requests to /api/tables/{table_name}. Query operators are specified as query params.
REST query frontend currently supports the following query operators:
- columns
- sort
- limit
- filter
To sort column col1 in ascending order and col2 in descending order, set query param to: sort=col1,-col2.
To find all rows with col1 equal to string 'foo', set query param to: filter[col1]='foo'. You can also do basic comparisons with filters, for example predicate 0 <= col2 < 5 can be expressed as filter[col2]gte=0&filter[col2]lt=5.
To query tables using GraphQL, send the query through POST request to /api/graphql endpoint.
GraphQL query frontend supports the same set of operators supported by REST query frontend. Here how is you can apply various operators in a query:
To query tables using a subset of standard SQL, send the query through POST request to /api/sql endpoint. This is the only query interface that supports table joins.
You can pick two columns from a table to use a key and value to create a quick keyvalue store API by adding the following lines to the config:
Key value lookup can be done through simple HTTP GET requests:
ROAPI can present itself as a Postgres server so users can use Postgres clients to issue SQL queries.
Query layer:
- REST API GET
- GraphQL
- SQL
- join between tables
- access to array elements by index
- access to nested struct fields by key
- column index
- protocol
- Postgres
- FlightSQL
- Key value lookup
Response serialization:
- JSON application/json
- Arrow application/vnd.apache.arrow.stream
- Parquet application/vnd.apache.parquet
- msgpack
Data layer:
- filesystem
- HTTP/HTTPS
- S3
- GCS
- Azure Storage
- Google spreadsheet
- MySQL
- SQLite
- Postgres
- Airtable
- Data format
- CSV
- JSON
- NDJSON
- parquet
- xls, xlsx, xlsb, ods: https://github.com/tafia/calamine
- DeltaLake
Misc:
- auto gen OpenAPI doc for rest layer
- query input type conversion based on table schema
- stream arrow encoding response
- authentication layer
The core of ROAPI, including query front-ends and data layer, lives in the self-contained columnq crate. It takes queries and outputs Arrow record batches. Data sources will also be loaded and stored in memory as Arrow record batches.
The roapi crate wraps columnq with a multi-protocol query layer. It serializes Arrow record batches produced by columnq into different formats based on client request.
To log all FlightSQL requests in console, set RUST_LOG=tower_http=trace.
- Vscode
- Ensure this extension is installed on your vs code ms-vscode-remote.remote-containers
Once done you will see prompt from left side to reopen the project in dev container or open command palette and search for open with remote container:
- install dependencies
- connect to database from your local using db client of choice using the following credentials
once done create table so you can map it in -t arg or consider using sample in .devcontainer/db-migration.sql to populate some tables with data
- run cargo command with mysql db as feature
otherwise if you are looking for other features you have to select appropriate one from roapi/Cargo.toml
.png)




