|
|
> This is the legacy api of the original passwords app by Fallon Turner.
|
|
|
> The rewritten passwords app provides an implementation of this api, but does not recommend using it.
|
|
|
> With the implementation of client side encryption in the app, this api will start to return incomplete data.
|
|
|
> If you are planning to use the passwords api in your own application, please use the new api instead.
|
|
|
|
|
|
How To Use The RESTful API (for extensions and other apps that use Passwords)
|
|
|
This app supports using an API. You can remotely get the list of passwords or edit and save them.
|
|
|
Methods
|
|
|
|
|
|
Supported methods are GET, POST, DELETE and PUT. You can use HEAD and OPTIONS to view all information of the API on your own server.
|
|
|
|
|
|
|Method |Scope |Semantics|
|
|
|
|---|---|---|
|
|
|
|GET |collection |Retrieve all resources in a collection|
|
|
|
|GET |resource |Retrieve a single resource|
|
|
|
|HEAD |collection |Retrieve all resources in a collection (header only)|
|
|
|
|HEAD |resource |Retrieve a single resource (header only)|
|
|
|
|POST |collection |Create a new resource in a collection|
|
|
|
|PUT |resource |Update a resource|
|
|
|
|DELETE |resource |Delete a resource|
|
|
|
|OPTIONS|any |Return available HTTP methods and other options|
|
|
|
|
|
|
An example to use HEAD method to check the app on a server:
|
|
|
|
|
|
`curl -i -X HEAD -u username https://[nextcloud]/index.php/apps/passwords/api/0.1/passwords`
|
|
|
|
|
|
## Commands
|
|
|
Every command requires Nextcloud authentication. Without a username and password of an existing user, the API will return: CORS requires basic auth.
|
|
|
|
|
|
The basic URL is the location of the app, followed by /api/0.1/[type], so:
|
|
|
```
|
|
|
Passwords: https://[nextcloud]/index.php/apps/passwords/api/0.1/passwords
|
|
|
Categories: https://[nextcloud]/index.php/apps/passwords/api/0.1/categories
|
|
|
```
|
|
|
|
|
|
Using these URLs will produce a decrypted JSON string.
|
|
|
|
|
|
|
|
|
#### Getting the app version
|
|
|
`curl -u [user] https://[nextcloud]/index.php/apps/passwords/api/0.1/version`
|
|
|
|
|
|
This will return a string like "17.2".
|
|
|
|
|
|
|
|
|
#### Getting all passwords of a user
|
|
|
`curl -u [user] https://[nextcloud]/index.php/apps/passwords/api/0.1/passwords`
|
|
|
|
|
|
|
|
|
#### Getting a single password of a user
|
|
|
Taking into account that the password with database ID = 61 belongs to [user]:
|
|
|
|
|
|
`curl -u [user] https://[nextcloud]/index.php/apps/passwords/api/0.1/passwords/61`
|
|
|
|
|
|
|
|
|
#### Saving a password for a user
|
|
|
For saving this:
|
|
|
```
|
|
|
{
|
|
|
"website": "testsite.com",
|
|
|
"pass": "newpassword",
|
|
|
"loginname": "username",
|
|
|
"address": "www.testsite.com",
|
|
|
"notes": "my new notes"
|
|
|
}
|
|
|
```
|
|
|
use this (note that all " within the JSON object must be written as \\"):
|
|
|
```
|
|
|
curl -u [user] -H "Content-Type: application/json" -X POST -d "{\"website\":\"testsite.com\",\"pass\":\"newpassword\",\"loginname\":\"username\",\"address\": \"www.testsite.com\", \"notes\": \"my new notes\"}" https://[nextcloud]/index.php/apps/passwords/api/0.1/passwords
|
|
|
```
|
|
|
|
|
|
|
|
|
#### Getting all categories of a user
|
|
|
`curl -u [user] https://[nextcloud]/index.php/apps/passwords/api/0.1/categories`
|
|
|
|
|
|
|
|
|
#### Getting a single category of a user
|
|
|
Taking into account that the category with database ID = 3 belongs to [user]:
|
|
|
|
|
|
`curl -u [user] https://[nextcloud]/index.php/apps/passwords/api/0.1/categories/3`
|
|
|
|
|
|
|
|
|
#### Saving a category for a user
|
|
|
> Categories will be mapped to tags.
|
|
|
|
|
|
Category colours must be hexadecimal and must not be preceded by a # character. The format will be checked for validity server-side.
|
|
|
For saving this:
|
|
|
```
|
|
|
{
|
|
|
"category_name": "My category",
|
|
|
"category_colour": "aa0000",
|
|
|
}
|
|
|
```
|
|
|
use this (note that all " within the JSON object must be written as \\"):
|
|
|
```
|
|
|
curl -u [user] -H "Content-Type: application/json" -X POST -d "{\"category_name\":\"My category\",\"category_colour\":\"aa0000\"}" https://[nextcloud]/index.php/apps/passwords/api/0.1/passwords
|
|
|
``` |
|
|
\ No newline at end of file |