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: content/docs/1_guide/20_api/3_data/guide.txt
+1-1
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@ Title: Data
2
2
3
3
----
4
4
5
-
Intro: Once you start (link: docs/guide/api/introduction#further-customize-the-api text: customizing the API) and adding your own API endpoints, there is a lot to know about how to interact with data in the callback functions.
5
+
Intro: Once you start (link: docs/guide/api#further-customize-the-api text: customizing the API) and adding your own API endpoints, there is a lot to know about how to interact with data in the callback functions.
Copy file name to clipboardexpand all lines: content/docs/1_guide/20_api/guide.txt
+81-1
Original file line number
Diff line number
Diff line change
@@ -10,4 +10,84 @@ Category: Extending Kirby
10
10
11
11
----
12
12
13
-
Icon: cloud
13
+
Intro: Kirby's REST API is used by the (glossary: Panel) to connect between the (glossary: Vue) frontend and the PHP backend. It offers full access to your site, pages, files, users and more. You can use it for your SPA or mobile applications built on top of Kirby.
14
+
15
+
----
16
+
17
+
Text:
18
+
19
+
## Endpoints
20
+
There are a large number of endpoints, split into the following areas:
21
+
22
+
(reference: api)
23
+
24
+
## Authentication
25
+
26
+
Every API request requires authentication. We offer session-based authentication or HTTP Basic auth. (link: docs/guide/api/authentication text: Read more ›)
27
+
28
+
## Language
29
+
In a (link: docs/guide/languages text: multi-language site) it is necessary to specify the language for which you want to use the API. This is done by sending an `X-Language` header containing the desired language code with your request.
30
+
31
+
## Errors
32
+
33
+
### Example error
34
+
35
+
```js
36
+
{
37
+
"status": "error",
38
+
"message": "The page \"example\" cannot be found",
39
+
"code": 404
40
+
}
41
+
```
42
+
43
+
### In debug mode
44
+
45
+
When debug mode is activated in your config, you will get a more detailed error response with the exception type, file and line.
46
+
47
+
```js
48
+
{
49
+
"status": "error",
50
+
"exception": "Exception",
51
+
"message": "The page \"example\" cannot be found",
52
+
"file": "config/api/data.php",
53
+
"line": 46,
54
+
"code": 500
55
+
}
56
+
```
57
+
58
+
To activate the debug mode, add the following to your config:
59
+
60
+
```php "/site/config/config.php"
61
+
return [
62
+
'debug' => true
63
+
];
64
+
```
65
+
66
+
<warning>
67
+
Please make sure to disable `debug` mode in production! Displaying PHP errors on a public server can be a serious security risk:
68
+
69
+
- Error messages are displayed with detailed information about the code structure (e.g. file path, class, method)
70
+
- With Whoops enabled, there will be even more detailed information about the code structure
71
+
- Detailed error messages for login failures could leak information to attackers
72
+
73
+
In a production environment, always log errors to your PHP error logs.
74
+
</warning>
75
+
76
+
77
+
## Custom API location
78
+
79
+
Kirby can be configured to host the API at a different location. This can be set up in your config.
80
+
81
+
```php "/site/config/config.php"
82
+
return [
83
+
'api' => [
84
+
'slug' => 'rest'
85
+
]
86
+
];
87
+
```
88
+
89
+
All API endpoints are now available at `https://yourdomain.com/rest`. The Panel will automatically switch to the new API location.
90
+
91
+
## Further customize the API
92
+
93
+
Find out how you can define custom endpoints, data functions, models etc. either via your (link: docs/reference/system/options/api text: config options ›) or (link: docs/reference/plugins/extensions/api text: in a plugin ›).
Copy file name to clipboardexpand all lines: content/docs/2_reference/7_plugins/1_extensions/0_api/reference-extension.txt
+1-1
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ Kirby::plugin('my/api', [
35
35
36
36
Your new endpoint is now available at `https://yourdomain.com/api/my-endpoint` and will return a json encoded version of the returned array.
37
37
38
-
The endpoint is automatically protected with the same authentication layer as our own endpoints. It will also move when you (link: docs/guide/api/introduction#custom-api-location text: change the API slug).
38
+
The endpoint is automatically protected with the same authentication layer as our own endpoints. It will also move when you (link: docs/guide/api#custom-api-location text: change the API slug).
Copy file name to clipboardexpand all lines: content/docs/2_reference/7_plugins/1_extensions/0_fields/reference-extension.txt
+1-1
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ Text:
14
14
15
15
## What makes a field plugin?
16
16
17
-
Our Kirby panel is built with (glossary: vue) and speaks to our (link: docs/guide/api/introduction text: REST API). Your field plugin needs to consist out of **three parts**:
17
+
Our Kirby panel is built with (glossary: vue) and speaks to our (link: docs/guide/api text: REST API). Your field plugin needs to consist out of **three parts**:
Copy file name to clipboardexpand all lines: content/releases/3-0/default.txt
+1-1
Original file line number
Diff line number
Diff line change
@@ -76,7 +76,7 @@ We've overhauled our entire plugin system and built a more reliable and consiste
76
76
77
77
Kirby 3 has a built in REST API. You can comfortably create and edit your content in the Panel, and then consume your content in SPAs, mobile applications or static site generators.
78
78
79
-
(link: docs/guide/api/introduction text: Learn more ›)
0 commit comments