Files
fnx_web/res/include/md/api.md

62 lines
2.0 KiB
Markdown
Raw Normal View History

2021-09-27 21:00:37 +02:00
# API documentation
2026-06-10 23:53:03 +02:00
Methods for using Nova programmatically.
2021-09-27 21:00:37 +02:00
## Authentication
2021-09-21 22:47:13 +02:00
All methods which create, modify or delete a resource require an API key. API
keys can be obtained from your user account's [API keys page](/user/api_keys).
2021-09-21 22:47:13 +02:00
To use the API key you need to enter it in the password field of [HTTP Basic
Access
Authentication](https://en.wikipedia.org/wiki/Basic_access_authentication). The
username field does not matter, it can be empty or anything else.
Example usage in JavaScript:
```js
const resp = await fetch(
2026-06-10 23:53:03 +02:00
"https://nova.storage/api/user/files",
2021-09-21 22:47:13 +02:00
headers: {
"Authorization": "Basic "+btoa(":"+api_key),
// The btoa function encodes the key to Base64
},
)
if(resp.status >= 400) {
throw new Error(await resp.json())
}
result = await resp.json()
```
Some JSON responses include fields which end in "_href" (some people don't know
this, but "href" stands for "Hypertext Reference", the more you know). These
point to different places in the API, which you can retrieve with a GET request.
The path is to be appended to the API URL, so "/file/someid/thumbnail" becomes
"{{apiUrl}}/file/someid/thumbnail".
The base URL for the API is "{{apiUrl}}", all paths below are relative to that
URL.
2021-09-27 21:00:37 +02:00
## curl example
2026-06-10 23:53:03 +02:00
To upload files to Nova you will need an API key. Get an API key from the
[API keys page](/user/api_keys) and enter it in the command. Replace the example
API key here with your own:
2021-09-27 21:00:37 +02:00
2024-02-15 18:46:46 +01:00
`curl -T "file_name.txt" -u :5f45f184-64bb-4eaa-be19-4a5f0459db49
2026-06-10 23:53:03 +02:00
https://nova.storage/api/file/`
2021-09-27 21:00:37 +02:00
2021-09-21 22:47:13 +02:00
## Form value order
I recommend you put files at the end of every file upload form. By doing this
2026-06-10 23:53:03 +02:00
the Nova server can respond to malformed requests before the file upload
2021-09-21 22:47:13 +02:00
finishes and this may save you a lot of time and bandwidth when uploading large
files. Make sure your HTTP client has support for premature responses,
2026-06-10 23:53:03 +02:00
Nova uses them a lot. If the server responds before your request is
2021-09-21 22:47:13 +02:00
finished it will always indicate an error and you may abort the connection.
{{template "api_file.md"}}
{{template "api_list.md"}}
{{template "api_user.md"}}