Skip to content

Commit 0993f18

Browse files
rustyconoverclaude
andcommitted
Clean up docs/README.md to point to query.farm docs
Trim docs/README.md down to a short intro, install instructions, and a link to the full documentation at query.farm. Move the build-from-source/dev-setup content into a new docs/BUILDING.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 16883a6 commit 0993f18

2 files changed

Lines changed: 57 additions & 229 deletions

File tree

‎docs/BUILDING.md‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Building and Testing
2+
3+
## Cloning the Repository
4+
5+
Clone the repository and all its submodules
6+
7+
```bash
8+
git clone --recurse-submodules git@github.com:Query-farm/httpserver.git
9+
```
10+
11+
If you've already cloned it without submodules, initialize them with:
12+
13+
```bash
14+
git submodule update --init --recursive
15+
```
16+
17+
## Setting up CLion
18+
19+
**Opening project:**
20+
Configuring CLion with the extension template requires a little work. Firstly, make sure that the DuckDB submodule is available.
21+
Then make sure to open `./duckdb/CMakeLists.txt` (so not the top level `CMakeLists.txt` file from this repo) as a project in CLion.
22+
Now to fix your project path go to `tools->CMake->Change Project Root`([docs](https://www.jetbrains.com/help/clion/change-project-root-directory.html)) to set the project root to the root dir of this repo.
23+
24+
**Debugging:**
25+
To set up debugging in CLion, there are two simple steps required. Firstly, in `CLion -> Settings / Preferences -> Build, Execution, Deploy -> CMake` you will need to add the desired builds (e.g. Debug, Release, RelDebug, etc). There's different ways to configure this, but the easiest is to leave all empty, except the `build path`, which needs to be set to `../build/{build type}`. Now on a clean repository you will first need to run `make {build type}` to initialize the CMake build directory. After running make, you will be able to (re)build from CLion by using the build target we just created. If you use the CLion editor, you can create a CLion CMake profiles matching the CMake variables that are described in the makefile, and then you don't need to invoke the Makefile.
26+
27+
The second step is to configure the unittest runner as a run/debug configuration. To do this, go to `Run -> Edit Configurations` and click `+ -> Cmake Application`. The target and executable should be `unittest`. This will run all the DuckDB tests. To specify only running the extension specific tests, add `--test-dir ../../.. [sql]` to the `Program Arguments`. Note that it is recommended to use the `unittest` executable for testing/development within CLion. The actual DuckDB CLI currently does not reliably work as a run target in CLion.
28+
29+
## Testing
30+
31+
To run the E2E test install all packages necessary:
32+
33+
```bash
34+
pip install -r requirements.txt
35+
```
36+
37+
Then run the test suite:
38+
39+
```bash
40+
pytest pytest test_http_api
41+
```

‎docs/README.md‎

Lines changed: 16 additions & 229 deletions
Original file line numberDiff line numberDiff line change
@@ -1,245 +1,32 @@
1-
<img width="200" height="200" alt="image" src="https://github.com/user-attachments/assets/a0a844c8-f8b2-40ae-8d6a-78722574cacf" />
2-
1+
<p align="center">
2+
<a href="https://query.farm">
3+
<picture>
4+
<source media="(prefers-color-scheme: dark)" srcset="https://query.farm/media-kit/logo/wordmark-dark.svg">
5+
<img alt="Query.Farm" src="https://query.farm/media-kit/logo/wordmark-light.svg" height="64">
6+
</picture>
7+
</a>
8+
</p>
39

410
# DuckDB HTTP Server Extension
5-
This extension transforms **DuckDB** instances into tiny multi-player **HTTP OLAP API** services.<br>
6-
Supports Authentication _(Basic Auth or X-Token)_ and includes the _play_ SQL user interface.
7-
8-
> This DuckDB extension was created by [Query.Farm](https://query.farm/), where we develop and maintain many extensions that expand DuckDB’s capabilities by connecting it to new data sources, formats, and features. You can explore our full collection at [Query.Farm](https://query.farm/)
9-
10-
### Features
1111

12-
- Turn any [DuckDB](https://duckdb.org) instance into an **HTTP OLAP API** Server
13-
- Use the embedded **Play User Interface** to query and visualize data
14-
- Pair with [chsql](https://community-extensions.duckdb.org/extensions/chsql.html) extension for **ClickHouse flavoured SQL**
15-
- Work with local and remote datasets including [MotherDuck](https://motherduck.com) 🐤
16-
- _100% Opensource, ready to use and extend by the Community!_
12+
[![DuckDB](https://img.shields.io/badge/DuckDB-community_extension-fdf1e0?logo=duckdb&logoColor=fff000)](https://duckdb.org/community_extensions/extensions/httpserver.html)
13+
[![v1.5 build](https://github.com/Query-farm/httpserver/actions/workflows/MainDistributionPipeline.yml/badge.svg?branch=v1.5)](https://github.com/Query-farm/httpserver/actions/workflows/MainDistributionPipeline.yml?query=branch%3Av1.5)
1714

18-
<br>
15+
This extension transforms **DuckDB** instances into tiny multi-player **HTTP OLAP API** services. Supports Authentication (Basic Auth or X-Token) and includes the *play* SQL user interface.
1916

20-
![image](https://github.com/user-attachments/assets/e930a8d2-b3e4-454e-ba12-e5e91b30bfbe)
17+
## Documentation
2118

22-
#### Extension Functions
23-
- `httpserve_start(host, port, auth)`: starts the server using provided parameters
24-
- `httpserve_stop()`: stops the server thread
19+
Full documentation, including installation, usage, the function reference, and cookbook examples, is available at:
2520

26-
#### Notes
21+
**[https://query.farm/products/extensions/httpserver](https://query.farm/products/extensions/httpserver)**
2722

28-
🛑 Run DuckDB in `-readonly` mode for enhanced security
23+
## Installation
2924

30-
<br>
31-
32-
### 📦 [Installation](https://community-extensions.duckdb.org/extensions/httpserver.html)
3325
```sql
3426
INSTALL httpserver FROM community;
3527
LOAD httpserver;
3628
```
3729

38-
### 🔌 Usage
39-
Start the HTTP server providing the `host`, `port` and `auth` parameters.<br>
40-
> * If you want no authentication, just pass an empty string as parameter.<br>
41-
> * If you want the API run in foreground set `DUCKDB_HTTPSERVER_FOREGROUND=1`
42-
> * If you want logs set `DUCKDB_HTTPSERVER_DEBUG` or `DUCKDB_HTTPSERVER_SYSLOG`
43-
44-
#### Basic Auth
45-
```sql
46-
D SELECT httpserve_start('localhost', 9999, 'user:pass');
47-
48-
┌───────────────────────────────────────────────┐
49-
│ httpserve_start('0.0.0.0', 9999, 'user:pass') │
50-
│ varchar │
51-
├───────────────────────────────────────────────┤
52-
│ HTTP server started on 0.0.0.0:9999 │
53-
└───────────────────────────────────────────────┘
54-
```
55-
```bash
56-
curl -X POST -d "SELECT 'hello', version()" "http://user:pass@localhost:9999/"
57-
```
58-
59-
#### Token Auth
60-
```sql
61-
SELECT httpserve_start('localhost', 9999, 'supersecretkey');
62-
63-
┌───────────────────────────────────────────────┐
64-
│ httpserve_start('0.0.0.0', 9999, 'secretkey') │
65-
│ varchar │
66-
├───────────────────────────────────────────────┤
67-
│ HTTP server started on 0.0.0.0:9999 │
68-
└───────────────────────────────────────────────┘
69-
```
70-
71-
Query your endpoint using the `X-API-Key` token:
72-
73-
```bash
74-
curl -X POST --header "X-API-Key: secretkey" -d "SELECT 'hello', version()" "http://localhost:9999/"
75-
```
76-
77-
You can perform the same action from DuckDB using HTTP `extra_http_headers`:
78-
79-
```sql
80-
D CREATE SECRET extra_http_headers (
81-
TYPE HTTP,
82-
EXTRA_HTTP_HEADERS MAP{
83-
'X-API-Key': 'secret'
84-
}
85-
);
86-
87-
D SELECT * FROM duck_flock('SELECT version()', ['http://localhost:9999']);
88-
┌─────────────┐
89-
│ "version"() │
90-
│ varchar │
91-
├─────────────┤
92-
│ v1.1.3 │
93-
└─────────────┘
94-
```
95-
96-
97-
98-
#### 👉 QUERY UI
99-
Browse to your endpoint and use the built-in quackplay interface _(experimental)_
100-
101-
![image](https://github.com/user-attachments/assets/0ee751d0-7360-4d3d-949d-3fb930634ebd)
102-
103-
#### 👉 QUERY API
104-
Query your API endpoint using curl GET/POST requests
105-
106-
```bash
107-
curl -X POST -d "SELECT 'hello', version()" "http://localhost:9999/?default_format=JSONCompact"
108-
```
109-
```json
110-
{
111-
"meta": [
112-
{
113-
"name": "'hello'",
114-
"type": "String"
115-
},
116-
{
117-
"name": "\"version\"()",
118-
"type": "String"
119-
}
120-
],
121-
"data": [
122-
[
123-
"hello",
124-
"v1.1.3"
125-
]
126-
],
127-
"rows": 1,
128-
"statistics": {
129-
"elapsed": 0.01,
130-
"rows_read": 1,
131-
"bytes_read": 0
132-
}
133-
}
134-
```
135-
136-
#### 👉 CROSS-OVER EXAMPLES
137-
138-
You can now have DuckDB instances query each other and... _themselves!_
139-
140-
```sql
141-
D LOAD json;
142-
D LOAD httpfs;
143-
D SELECT httpserve_start('0.0.0.0', 9999, '');
144-
┌─────────────────────────────────────┐
145-
│ httpserve_start('0.0.0.0', 9999) │
146-
│ varchar │
147-
├─────────────────────────────────────┤
148-
│ HTTP server started on 0.0.0.0:9999 │
149-
└─────────────────────────────────────┘
150-
D SELECT * FROM read_json_auto('http://localhost:9999/?q=SELECT version()');
151-
┌─────────────┐
152-
│ "version"() │
153-
│ varchar │
154-
├─────────────┤
155-
│ v1.1.3 │
156-
└─────────────┘
157-
```
158-
159-
#### Flock Macro by @carlopi
160-
Check out this flocking macro from fellow _Italo-Amsterdammer_ @carlopi @ DuckDB Labs
161-
162-
![image](https://github.com/user-attachments/assets/b409ec0e-86e0-4a8d-822c-377ddbae524d)
163-
164-
* a DuckDB CLI, running httpserver extension
165-
* a DuckDB from Python, running httpserver extension
166-
* a DuckDB from the Web, querying all 3 DuckDB at the same time
167-
168-
<br>
169-
170-
<hr>
171-
172-
<br>
173-
174-
### API Documentation
175-
176-
#### Endpoints Overview
177-
178-
| Endpoint | Methods | Description |
179-
|----------|---------|-------------|
180-
| `/` | GET, POST | Query API endpoint |
181-
| `/ping` | GET | Health check endpoint |
182-
183-
#### Detailed Endpoint Specifications
184-
185-
##### Query API
186-
187-
**Methods:** `GET`, `POST`
188-
189-
**Parameters:**
190-
191-
| Parameter | Description | Supported Values |
192-
|-----------|-------------|-------------------|
193-
| `default_format` | Specifies the output format | `JSONEachRow`, `JSONCompact` |
194-
| `query` | The DuckDB SQL query to execute | Any valid DuckDB SQL query |
195-
196-
##### Notes
197-
198-
- Ensure that your queries are properly formatted and escaped when sending them as part of the request.
199-
- The root endpoint (`/`) supports both GET and POST methods, but POST is recommended for complex queries or when the query length exceeds URL length limitations.
200-
- Always specify the `default_format` parameter to ensure consistent output formatting.
201-
202-
<br>
203-
20430
## Development
20531

206-
### Cloning the Repository
207-
208-
Clone the repository and all its submodules
209-
210-
```bash
211-
git clone <your-fork-url>
212-
git submodule update --init --recursive
213-
```
214-
215-
### Setting up CLion
216-
**Opening project:**
217-
Configuring CLion with the extension template requires a little work. Firstly, make sure that the DuckDB submodule is available.
218-
Then make sure to open `./duckdb/CMakeLists.txt` (so not the top level `CMakeLists.txt` file from this repo) as a project in CLion.
219-
Now to fix your project path go to `tools->CMake->Change Project Root`([docs](https://www.jetbrains.com/help/clion/change-project-root-directory.html)) to set the project root to the root dir of this repo.
220-
221-
**Debugging:**
222-
To set up debugging in CLion, there are two simple steps required. Firstly, in `CLion -> Settings / Preferences -> Build, Execution, Deploy -> CMake` you will need to add the desired builds (e.g. Debug, Release, RelDebug, etc). There's different ways to configure this, but the easiest is to leave all empty, except the `build path`, which needs to be set to `../build/{build type}`. Now on a clean repository you will first need to run `make {build type}` to initialize the CMake build directory. After running make, you will be able to (re)build from CLion by using the build target we just created. If you use the CLion editor, you can create a CLion CMake profiles matching the CMake variables that are described in the makefile, and then you don't need to invoke the Makefile.
223-
224-
The second step is to configure the unittest runner as a run/debug configuration. To do this, go to `Run -> Edit Configurations` and click `+ -> Cmake Application`. The target and executable should be `unittest`. This will run all the DuckDB tests. To specify only running the extension specific tests, add `--test-dir ../../.. [sql]` to the `Program Arguments`. Note that it is recommended to use the `unittest` executable for testing/development within CLion. The actual DuckDB CLI currently does not reliably work as a run target in CLion.
225-
226-
227-
### Testing
228-
229-
To run the E2E test install all packages necessary:
230-
231-
```bash
232-
pip install -r requirements.txt
233-
```
234-
235-
Then run the test suite:
236-
237-
```bash
238-
pytest pytest test_http_api
239-
```
240-
241-
##### :black_joker: Disclaimers
242-
243-
[^1]: DuckDB ® is a trademark of DuckDB Foundation. All rights reserved by their respective owners. [^1]
244-
[^2]: ClickHouse ® is a trademark of ClickHouse Inc. No direct affiliation or endorsement. [^2]
245-
[^3]: Released under the MIT license. See LICENSE for details. All rights reserved by their respective owners. [^3]
32+
For instructions on building the extension from source and running its tests, see [BUILDING.md](BUILDING.md).

0 commit comments

Comments
 (0)