Skip to content

Konnection API Endpoints

keanweng97 edited this page Mar 22, 2021 · 14 revisions

Last Updated: Feb 19, 2021

Index

User

://service/author/create/

  • Methods:
    • POST: Create a new user
      • Accepted payload: { "username":"abc", "password":"password" }
      • Returned payload: {"username":"abc",}

://service/author/auth/

  • Methods:
    • POST: Log in and get login token
      • Accepted payload: { "username":"abc", "password":"password" }
      • Returned payload: { "token":"dsfjosjfjsdlfnksanfk-noawenfon",}

://service/author/me/

  • Methods:
    • GET: Get current user profile
      • Accepted Header: "Authorization: Token <ACCESS_TOKEN>"
      • Returned payload:
        {
          "username": "testing12",
          "type": "UserType.author",
          "id": "xxxxxxxxxxx",
          "host": "",
          "displayName": "",
          "URL": "",
          "github": ""
        }
        

://service/author/{AUTHOR_ID}/

  • Methods:
    • PUT: Update author profile
      • Accepted Header: "Authorization: Token <ACCESS_TOKEN>"
      • Returned payload:
        {
          "username": "testing12",
          "type": "UserType.author",
          "id": "xxxxxxxxxxx",
          "host": "",
          "displayName": "new display name",
          "URL": "",
          "github": "new GitHub account URL"
        }
        

Post

://service/author/{AUTHOR_ID}/posts/

  • Methods:
    • GET: get a list of posts made by the author (paginated)
    • POST: create a new post
  • Notes:
    • Currently no pagination is implemented
    • You can only get your own posts or another user's public posts

://service/author/{AUTHOR_ID}/posts/{POST_ID}

  • Methods:
    • GET: get the public post
    • POST: update the post
    • DELETE: remove the post
    • PUT: create a post with that post_id

Current accepted payload:

{
  "title": "Title",                         # max 100 chars
  "source": "http://example.com/source",    # type: url
  "origin": "http://example.com/origin",    # type: url
  "description": "A brief description",     # max 250 chars
  "contentType": "text/html",               # max 18 chars
  "content": "<h1>hello</h1>",              # upper limit of 1GB
  "visibility": "PUBLIC",                   # default: PUBLIC
  "unlisted": False                         # default: False
}

Current returned payload:

{
  "type": "post",
  "title": "New Title",
  "id": "http://127.0.0.1:8000/author/ce350c18-4c0e-447b-b829-27685a6c37b9/posts/9fdf860d-7f23-4c34-857e-11af1ad9e20c/",
  "source": "",
  "origin": "",
  "description": "here is the description",
  "contentType": "text/markdown",
  "content": null,
  "author": {
    "type": "UserType.superuser",
    "id": "http://127.0.0.1:8000/author/ce350c18-4c0e-447b-b829-27685a6c37b9",
    "host": "http://127.0.0.1:8000",
    "displayName": "",
    "URL": "",
    "github": ""
  },
  "count": 0,
  "size": 0,
  "published": "2021-02-18T07:21:52.915800Z",
  "visibility": "PUBLIC",
  "unlisted": false
}
  • Accepted values:
    • contentType: text/markdown, text/plain, text/html, application/base64, image/png;base64, image/jpeg;base64
    • visibility: PUBLIC, FRIENDS

Followers

://service/author/{AUTHOR_ID}/followers

  • Methods:
    • GET: get a list of authors who are their followers

://service/author/{AUTHOR_ID}/followers/{FOREIGN_AUTHOR_ID}

  • Methods;
    • DELETE: remove a follower
    • PUT: Add a follower (must be authenticated)
    • GET check if follower

Current returned payload:

{
    "type": "followers",
    "items": [
        {
            "username": "abc123",
            "type": "Author",
            "id": "63248785-c0b0-4e54-b2e9-4477ewfhiwefniwuen",
            "host": "http://127.0.0.1:8000",
            "displayName": "",
            "url": "",
            "github": ""
        },
        ...
    ]
}

Inbox

://service/author/{AUTHOR_ID}/inbox

Methods:

  • GET: get a list of posts sent to {AUTHOR_ID}, only if you are authenticated as that Author
  • POST: send a post (type: Post, Follow, Like) to the Author
  • DELETE: empties the Inbox

GET

No payload required but has to be authenticated.

POST

Posts
  • Can send public Posts and whatever Posts I can see to my friends
  • Sent Posts cannot be modified even if the original Post is modified

Payload:

{
  "type": "post",
  "id": POST_ID    # must be valid UUID
}
Likes (not yet implemented)

Payload:

{
  "type": "like",
}

DELETE

No payload required but has to be authenticated.

Sharing

://service/author/{AUTHOR_ID}/posts/{POST_ID}/share

  • Methods:
    • POST: Author shares a Post with POST_ID to Author's friends

Payload:

{
  "from": UUID,     # UUID of Author that is sharing the post
  "share_to": UUID  # UUID of Author's friend that will be receiving the post
}