2020-11-11 11:47:10 +01:00
|
|
|
---
|
|
|
|
title: Administration from the API or an external application
|
|
|
|
template: docs
|
|
|
|
taxonomy:
|
|
|
|
category: docs
|
2021-02-06 18:22:00 +01:00
|
|
|
routes:
|
|
|
|
default: '/admin_api'
|
2020-11-11 11:47:10 +01:00
|
|
|
---
|
2019-01-03 17:44:33 +01:00
|
|
|
|
2022-08-06 14:21:10 +02:00
|
|
|
All command line actions can also be ran from the web API. The API is available at https://your.server/yunohost/api.
|
2019-01-03 17:44:33 +01:00
|
|
|
|
2022-08-06 14:21:10 +02:00
|
|
|
## Test with curl
|
|
|
|
You must first retrieve a login cookie thanks to the /login route to perform the other actions.
|
2019-01-03 17:44:33 +01:00
|
|
|
|
|
|
|
```bash
|
|
|
|
# Login (with admin password)
|
|
|
|
curl -k -H "X-Requested-With: customscript" \
|
2022-08-06 14:21:10 +02:00
|
|
|
-d "credentials=supersecretpassword" \
|
2019-01-03 17:44:33 +01:00
|
|
|
-dump-header headers \
|
|
|
|
https://your.server/yunohost/api/login
|
|
|
|
|
|
|
|
# GET example
|
|
|
|
curl -k -i -H "Accept: application/json" \
|
|
|
|
-H "Content-Type: application/json" \
|
2022-08-06 14:21:10 +02:00
|
|
|
-H 'Cookie: yunohost.admin="XXXXXXXX"' \
|
2019-01-03 17:44:33 +01:00
|
|
|
-L -b headers -X GET https://your.server/yunohost/api/ROUTE \
|
|
|
|
| grep } | python -mjson.tool
|
|
|
|
```
|
|
|
|
|
2022-08-06 14:21:10 +02:00
|
|
|
## Test with our swagger doc
|
2019-01-03 17:44:33 +01:00
|
|
|
|
2022-08-06 14:21:10 +02:00
|
|
|
1. Login on the [Webadmin of demo.yunohost.org](https://demo.yunohost.org/yunohost/admin/)
|
|
|
|
2. Use the `Try it out` button on the API endpoint you want to test
|
2019-01-03 17:44:33 +01:00
|
|
|
|
2022-08-06 14:21:10 +02:00
|
|
|
<div id="swagger-ui"></div>
|
|
|
|
<style>
|
|
|
|
#swagger-ui .topbar {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/user/themes/yunohost-docs/css/swagger-ui.css" />
|
|
|
|
<script src="/user/themes/yunohost-docs/js/swagger-ui-bundle.js" charset="UTF-8"> </script>
|
|
|
|
<script src="/user/themes/yunohost-docs/js/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
|
|
|
|
<script src="/user/themes/yunohost-docs/js/openapi.js" type="text/javascript" language="javascript"></script>
|
|
|
|
<script>
|
|
|
|
window.onload = function() {
|
|
|
|
//<editor-fold desc="Changeable Configuration Block">
|
|
|
|
// the following lines will be replaced by docker/configurator, when it runs in a docker-container
|
|
|
|
window.ui = SwaggerUIBundle({
|
|
|
|
spec: openapiJSON,
|
|
|
|
dom_id: '#swagger-ui',
|
|
|
|
deepLinking: true,
|
|
|
|
displayOperationId: true,
|
|
|
|
validatorUrl: null,
|
|
|
|
presets: [
|
|
|
|
SwaggerUIBundle.presets.apis,
|
|
|
|
SwaggerUIStandalonePreset
|
|
|
|
],
|
|
|
|
layout: "StandaloneLayout"
|
|
|
|
});
|
2019-01-03 17:44:33 +01:00
|
|
|
|
2022-08-06 14:21:10 +02:00
|
|
|
//</editor-fold>
|
|
|
|
};
|
2019-01-03 17:44:33 +01:00
|
|
|
|
2022-08-06 14:21:10 +02:00
|
|
|
</script>
|
2019-01-03 17:44:33 +01:00
|
|
|
|