doc/pages/02.administer/60.extend/30.api/admin_api.md
OniriCorpe 7a01793062
Improve markdown formatting of pages, a lot of them are improperly formatted (#2429)
* Revert "Revert "markdown format""

* fix formating

* fix readme

* add .markdownlint.json

* add markdownlint-rules-grav-pages

* add markdownlint-rules-grav-pages files

* add license for Markdown Lint Rules for Grav Pages

* fix [figure] mess

* fix [figure] mess 2

* fix [figure] mess 3

* maj .gitignore

* various fixes

* fix markdownlint-rules-grav-pages

* second formater pass

* various manual fixes

* add .markdownlintignore

* markdownlintignore: auto-generated pages

* disable proper-names for html_elements

* another bunch of various markdown fixes

* Update pages/02.administer/10.install/20.dns_config/dns_config.es.md

Co-authored-by: tituspijean <titus+yunohost@pijean.ovh>

---------

Co-authored-by: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com>
Co-authored-by: tituspijean <titus+yunohost@pijean.ovh>
2024-03-23 08:59:52 +01:00

67 lines
2 KiB
Markdown

---
title: Administration from the API or an external application
template: docs
taxonomy:
category: docs
routes:
default: '/admin_api'
---
All command line actions can also be ran from the web API. The API is available at <https://your.server/yunohost/api>.
## Test with curl
You must first retrieve a login cookie thanks to the /login route to perform the other actions.
```bash
# Login (with admin password)
curl -k -H "X-Requested-With: customscript" \
-d "credentials=supersecretpassword" \
-dump-header headers \
https://your.server/yunohost/api/login
# GET example
curl -k -i -H "Accept: application/json" \
-H "Content-Type: application/json" \
-H 'Cookie: yunohost.admin="XXXXXXXX"' \
-L -b headers -X GET https://your.server/yunohost/api/ROUTE \
| grep } | python -mjson.tool
```
## Test with our swagger doc
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
<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
],
withCredentials: true,
layout: "StandaloneLayout"
});
//</editor-fold>
};
</script>