You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs_src/src/pages/documentation/en/api_reference/index.mdx
+18-21Lines changed: 18 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,46 +5,43 @@ Once upon a time in the city of Gotham, there was a powerful superhero named Rob
5
5
6
6
One day, Batman approached Robyn for help with building a web application. Batman had heard about Robyn's powerful features and wanted to harness them to create a remarkable application. Batman was looking for an ally and in Robyn, he found the best one!
7
7
8
-
9
8
## Installing Robyn
10
9
11
-
12
10
Robyn is a Python library that you can install using `pip` or `conda`
13
11
14
12
<CodeGrouptitle="installation">
15
13
16
-
```bash {{ title: 'pip' }}
17
-
pip install robyn
18
-
```
14
+
```bash {{ title: 'pip' }}
15
+
pip install robyn
16
+
```
17
+
18
+
```bash {{ title: 'conda' }}
19
+
conda install robyn -c conda-forge
20
+
```
19
21
20
-
```bash {{ title: 'conda' }}
21
-
conda install robyn -c conda-forge
22
-
```
23
22
</CodeGroup>
24
23
25
-
While there are other more extensions of Robyn like
24
+
Robyn also ships optional extras for templating, Pydantic validation, project scaffolding with `robyn-config`, and a combined `all` bundle:
26
25
27
26
<CodeGrouptitle="installation">
28
27
29
-
```bash {{ title: 'pip' }}
30
-
pip install "robyn[templating]"
31
-
```
32
-
33
-
```bash {{ title: 'conda' }}
34
-
conda install "robyn[templating]" -c conda-forge
35
-
```
36
-
</CodeGroup>
28
+
```bash {{ title: 'pip' }}
29
+
pip install "robyn[templating]"
30
+
pip install "robyn[pydantic]"
31
+
pip install "robyn[robyn-config]"
32
+
pip install "robyn[all]"
33
+
```
37
34
35
+
```bash {{ title: 'conda' }}
36
+
conda install "robyn[templating]" -c conda-forge
37
+
```
38
38
39
+
</CodeGroup>
39
40
40
41
It is recommended to install the base package first and then install the extensions as needed.
41
42
42
43
## What's next?
43
44
44
45
Now, we can start using Robyn to build our application.
|`text`|`str`| Response body as a decoded string |
53
+
|`content`|`bytes`| Raw response body|
54
+
|`headers`|`Headers`| Response headers|
55
+
|`ok`|`bool`|`True` if status is 2xx|
55
56
56
57
`TestResponse` also has a `.json()` method that parses the body as JSON.
57
58
@@ -73,6 +74,7 @@ Every request method returns a `TestResponse` with the following properties:
73
74
assert data[0]["name"] =="Batman"
74
75
```
75
76
</CodeGroup>
77
+
76
78
</Col>
77
79
</Row>
78
80
@@ -100,6 +102,7 @@ Use `json_data` to send JSON payloads — the client automatically sets `Content
100
102
assert response.json()["name"] =="Batarang"
101
103
```
102
104
</CodeGroup>
105
+
103
106
</Col>
104
107
</Row>
105
108
@@ -122,10 +125,10 @@ You can also send raw string or bytes bodies, custom headers, query parameters,
122
125
assert response.ok
123
126
```
124
127
</CodeGroup>
128
+
125
129
</Col>
126
130
</Row>
127
131
128
-
129
132
### Path Parameters
130
133
131
134
Routes with path parameters work exactly as they do in production. The `TestClient` matches the route pattern and extracts parameters automatically.
@@ -148,10 +151,10 @@ Path parameters are resolved from the URL and passed to your handler through the
148
151
assert response.json()["user_id"] ==42
149
152
```
150
153
</CodeGroup>
154
+
151
155
</Col>
152
156
</Row>
153
157
154
-
155
158
### Testing Middleware
156
159
157
160
The `TestClient` replicates the full request pipeline — before middlewares, the handler, global response headers, and after middlewares — in the same order as the Rust runtime.
@@ -185,10 +188,10 @@ Middlewares that modify the request or response are executed just like in produc
185
188
assert response.headers.get("X-Server") =="Robyn"
186
189
```
187
190
</CodeGroup>
191
+
188
192
</Col>
189
193
</Row>
190
194
191
-
192
195
### Using as a Context Manager
193
196
194
197
`TestClient` implements the context manager protocol. When used with `with`, the internal event loop is automatically cleaned up:
@@ -208,10 +211,10 @@ Middlewares that modify the request or response are executed just like in produc
208
211
# event loop is closed here
209
212
```
210
213
</CodeGroup>
214
+
211
215
</Col>
212
216
</Row>
213
217
214
-
215
218
### Running Tests with pytest
216
219
217
220
Since `TestClient` doesn't start a server, tests run as fast as regular unit tests. Use `pytest` directly — no special plugins or fixtures required.
@@ -262,6 +265,7 @@ A typical test file:
262
265
assert response.status_code ==404
263
266
```
264
267
</CodeGroup>
268
+
265
269
</Col>
266
270
</Row>
267
271
@@ -271,25 +275,24 @@ Run with:
271
275
pytest test_app.py -v
272
276
```
273
277
274
-
275
278
### Available Methods
276
279
277
-
| Method | Signature |
278
-
| --- | --- |
279
-
|`client.get(path, **kw)`| GET request |
280
-
|`client.post(path, json_data=None, **kw)`| POST request |
281
-
|`client.put(path, json_data=None, **kw)`| PUT request |
Robyn is a versatile and extensible web framework that allows anyone to make plugins over the top of Robyn.
@@ -34,6 +42,164 @@ In this example, robyn-rate-limits is used to enforce a rate limit of 3 requests
34
42
35
43
The plugin integrates seamlessly with the Robyn web framework, enhancing the security and stability of your application by preventing excessive requests from a single client.
36
44
45
+
### Robyn Config
46
+
47
+
- Description: A CLI companion for bootstrapping and maintaining production-ready Robyn applications. It can create new projects, add business entities, scaffold an admin panel, and wire an observability stack into an existing app.
`robyn-config create` gives you explicit choices for the two main architecture branches:
71
+
72
+
-**DDD** for domain, application, infrastructure, and presentation layers.
73
+
-**MVC** for views, repositories, models, and URL routing.
74
+
75
+
It also lets you choose the database layer and package manager:
76
+
77
+
-**SQLAlchemy** or **Tortoise ORM** for persistence.
78
+
-**uv** by default, or **poetry** with `--package-manager poetry`.
79
+
80
+
#### Add Business Logic
81
+
82
+
Inside a generated project, add a new entity and let `robyn-config` place the files in the correct design-specific layers:
83
+
84
+
```bash
85
+
cd my-service
86
+
robyn-config add product
87
+
```
88
+
89
+
This generates the model, repository, route/controller code, and application wiring for the selected architecture. Custom generation paths can be configured in `[tool.robyn-config.add]` inside the generated project's `pyproject.toml`.
90
+
91
+
#### Add an Admin Panel
92
+
93
+
```bash
94
+
cd my-service
95
+
robyn-config adminpanel
96
+
97
+
# Override the default admin/admin bootstrap credentials
The admin panel scaffolding adds an ORM-aware admin module, registers it with the application, discovers available project models, and exposes CRUD views for those models.
# Start the application stack and observability stack
153
+
docker compose up -d
154
+
docker compose -f docker-compose.monitoring.yml up -d
155
+
```
156
+
157
+
The monitoring command adds a `/metrics` endpoint, installs `prometheus-client`, and provisions Docker Compose assets for Grafana Alloy, Loki, Prometheus, and Grafana. Grafana is available at `http://localhost:3000` with dashboards for logs and process metrics.
0 commit comments