Back to Shiori

Auth

docs/API.md

1.8.05.7 KB
Original Source

This is a brief explanation of Shiori's API. For more examples you can import this collection in Postman.

⚠️ This is the documentation for the old API. This API is deprecated and will be removed in the future. Please refer and start migrating to the API v1 instead.

<!-- TOC --> <!-- /TOC -->

Auth

Log in

Most actions require a session id. For that, you'll need to log in using your username and password.

Request infoValue
Endpoint/api/login
MethodPOST

Body:

json
{
	"username": "shiori",
	"password": "gopher",
	"remember": true,
	"owner": true
}

It will return your session ID in a JSON:

json
{
    "session": "YOUR_SESSION_ID",
    "account": {
        "id": 1,
        "username": "shiori",
        "owner": true
    }
}

Log out

Log out of a session ID.

Request infoValue
Endpoint/api/logout
MethodPOST
X-Session-Id HeadersessionId

Bookmarks

Get bookmarks

Gets the last 30 bookmarks (last page).

Request infoValue
Endpoint/api/bookmarks
MethodGET
X-Session-Id HeadersessionId

Returns:

json
{
    "bookmarks": [
        {
            "id": 825,
            "url": "https://interesting_cool_article.com",
            "title": "Cool Interesting Article",
            "excerpt": "An interesting and cool article indeed!",
            "author": "",
            "public": 0,
            "modified": "2020-12-06 00:00:00",
            "imageURL": "",
            "hasContent": true,
            "hasArchive": true,
            "tags": [
                {
                    "id": 7,
                    "name": "TAG"
                }
            ],
            "createArchive": false
        },
    ],
    "maxPage": 19,
    "page": 1
}

Add bookmark

Add a bookmark. For some reason, Shiori ignores the provided title and excerpt, and instead fetches them automatically. Note the tag format, a regular JSON list will result in an error.

Request infoValue
Endpoint/api/bookmarks
MethodPOST
X-Session-Id HeadersessionId

Body:

json
{
	"url": "https://interesting_cool_article.com",
	"createArchive": true,
	"public": 1,
	"tags": [{"name": "Interesting"}, {"name": "Cool"}],
	"title": "Cool Interesting Article",
	"excerpt": "An interesting and cool article indeed!"
}

Returns:

json
{
    "id": 827,
    "url": "https://interesting_cool_article.com",
    "title": "TITLE",
    "excerpt": "EXCERPT",
    "author": "AUTHOR",
    "public": 1,
    "modified": "DATE",
    "html": "HTML",
    "imageURL": "/bookmark/827/thumb",
    "hasContent": false,
    "hasArchive": true,
    "tags": [
        {
             "name": "Interesting"
        },
        {
             "name": "Cool"
        }
    ],
    "createArchive": true
}

Edit bookmark

Modifies a bookmark, by ID.

Request infoValue
Endpoint/api/bookmarks
MethodPUT
X-Session-Id HeadersessionId

Body:

json
{
    "id": 3,
    "url": "https://interesting_cool_article.com",
    "title": "Cool Interesting Article",
    "excerpt": "An interesting and cool article indeed!",
    "author": "AUTHOR",
    "public": 1,
    "modified": "2019-09-22 00:00:00",
    "imageURL": "/bookmark/3/thumb",
    "hasContent": false,
    "hasArchive": false,
    "tags": [],
    "createArchive": false
}

After providing the ID, provide the modified fields. The syntax is the same as adding.

Delete bookmark

Deletes a list of bookmarks, by their IDs.

Request infoValue
Endpoint/api/bookmarks
MethodDEL
X-Session-Id HeadersessionId

Body:

json
[1, 2, 3]

Tags

Get tags

Gets the list of tags, their IDs and the number of entries that have those tags.

Request infoValue
Endpoint/api/tags
MethodGET
X-Session-Id HeadersessionId

Returns:

json
[
    {
        "id": 1,
        "name": "Cool",
        "nBookmarks": 1
    },
    {
        "id": 2,
        "name": "Interesting",
        "nBookmarks": 1
    }

Rename tag

Renames a tag, provided its ID.

Request infoValue
Endpoint/api/tags
MethodPUT
X-Session-Id HeadersessionId

Body:

json
{
    "id": 1,
    "name": "TAG_NEW_NAME"
}

Accounts

List accounts

Gets the list of all user accounts, their IDs, and whether or not they are owners.

Request infoValue
Endpoint/api/accounts
MethodGET
X-Session-Id HeadersessionId

Returns:

json
[
    {
        "id": 1,
        "username": "shiori",
        "owner": true
    }
]

Create account

Creates a new user.

Request infoValue
Endpoint/api/accounts
MethodPOST
X-Session-Id HeadersessionId
Body:
json
{
	"username": "shiori2",
	"password": "gopher",
	"owner": false
}

Edit account

Changes an account's password or owner status.

Request infoValue
Endpoint/api/accounts
MethodPUT
X-Session-Id HeadersessionId
Body:
json
{
	"username": "shiori",
	"oldPassword": "gopher",
	"newPassword": "gopher",
	"owner": true
}

Delete accounts

Deletes a list of users.

Request infoValue
Endpoint/api/accounts
MethodDEL
X-Session-Id HeadersessionId

Body:

json
["shiori", "shiori2"]