Skip to content

Followers API Documentation

IanSeng edited this page Apr 15, 2021 · 14 revisions

API used to manage all aspects of user/author's followers on Konnection. It offers endpoints so users can follow, unfollow, check if follower and follower list.

1.Author Followers List

Endpoints

GET: /api/author/{author_id}/followers

Getting an author's follower list.

Endpoint Requirements

  1. Provide Token in the header for authentication purpose
  2. Logged in user must be approved by admin

Request Header

Request Header Required / optional Description Type
Authorization required Authentication Token String

Sample header --header "Authorization: Token 7ccf51cf9b2b518d789bdeaf5de1db0e530e1ab5"

Accepted Payload

Note: Only JSON object is accepted

Payload Required / optional Description Type More
type Optional Action Type JSON field
summary Optional Description of the action JSON Field
actor Required Author object that is going to follow another author JSON Object Please ensure that correct author object is passed. Required fields:
type, id, url, host displayName, and github
object Required Author object that is being followed JSON Object Please ensure that correct author object is passed. Required fields:
type, id, url, host displayName, and github

Sample Payload

{
    "type": "Follow",      
    "summary":"AuthorA wants to follow AuthorB",
    "actor":{
        "type":"author",                                                        
        "id":"1d698d25ff008f7538453c120f581471",
        "url":"http://127.0.0.1:5454/author/1d698d25ff008f7538453c120f581471",
        "host":"http://team6/",
        "displayName":"AuthorA",
        "github": ""
    },
    "object":{
        "type":"author",
        "id":"9de17f29c12e8f97bcbbd34cc908f1baba40658e",
        "host":"https://konnection-client.herokuapp.com",
        "displayName":"AuthorB",
        "url":"",
        "github": "http://github.com/AuthorB"
    }
}

Sample Response

The following is a sample response from the endpoint:

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

Response Status Code

  • 200 OK: If all requirements are fulfilled
  • 400 Bad Request: If the author ID is invalid
  • 401 Unauthorized: If basic auth or token is not provided

2.Checking if B Follow A

Endpoints

GET: /api/author/{authorA_id}/followers/{authorB_id}

Checking if author B follows author A

Endpoint Requirements

  1. Provide Token in the header for authentication purpose
  2. Logged in user must be approved by admin

Request Header

Request Header Required / optional Description Type
Authorization required Authentication Token String

Sample header --header "Authorization: Token 7ccf51cf9b2b518d789bdeaf5de1db0e530e1ab5"

Accepted Payload

Note: Only JSON object is accepted

Payload Required / optional Description Type More
type Optional Action Type JSON field
summary Optional Description of the action JSON Field
actor Required Author object that is going to follow another author JSON Object Please ensure that correct author object is passed. Required fields:
type, id, url, host displayName, and github
object Required Author object that is being followed JSON Object Please ensure that correct author object is passed. Required fields:
type, id, url, host displayName, and github

Sample Payload

{
    "type": "Follow",      
    "summary":"AuthorA wants to follow AuthorB",
    "actor":{
        "type":"author",                                                        
        "id":"1d698d25ff008f7538453c120f581471",
        "url":"http://127.0.0.1:5454/author/1d698d25ff008f7538453c120f581471",
        "host":"http://team6/",
        "displayName":"AuthorA",
        "github": ""
    },
    "object":{
        "type":"author",
        "id":"9de17f29c12e8f97bcbbd34cc908f1baba40658e",
        "host":"https://konnection-client.herokuapp.com",
        "displayName":"AuthorB",
        "url":"",
        "github": "http://github.com/AuthorB"
    }
}

Sample Response

The following is a sample response from the endpoint:

{
    "type": "follower",
    "items": [
        {
            "status": true,
            "author": "author A uuid",
            "follower": "author B uuid"
        }
    ]
}

Response Status Code

  • 200 OK: If all requirements are fulfilled
  • 400 Bad Request: If either of the author IDs is invalid
  • 401 Unauthorized: If basic auth or token is not provided

3.B follow A

Endpoints

PUT: /api/author/{authorA_id}/followers/{authorB_id}/

Author B follows A and author B will be the follower of author A. This endpoint is equivalent to sending friend request and the response object will be added to the inbox.

Endpoint Requirements

  1. Provide Token in the header for authentication purpose
  2. Logged in user must be approved by admin

Request Header

Request Header Required / optional Description Type
Authorization required Authentication Token String

Sample header --header "Authorization: Token 7ccf51cf9b2b518d789bdeaf5de1db0e530e1ab5"

Accepted Payload

Note: Only JSON object is accepted

Payload Required / optional Description Type More
type Optional Action Type JSON field
summary Optional Description of the action JSON Field
actor Required Author object that is going to follow another author JSON Object Please ensure that correct author object is passed. Required fields:
type, id, url, host displayName, and github
object Required Author object that is being followed JSON Object Please ensure that correct author object is passed. Required fields:
type, id, url, host displayName, and github

Sample Payload

{
    "type": "Follow",      
    "summary":"AuthorA wants to follow AuthorB",
    "actor":{
        "type":"author",                                                        
        "id":"1d698d25ff008f7538453c120f581471",
        "url":"http://127.0.0.1:5454/author/1d698d25ff008f7538453c120f581471",
        "host":"http://team6/",
        "displayName":"AuthorA",
        "github": ""
    },
    "object":{
        "type":"author",
        "id":"9de17f29c12e8f97bcbbd34cc908f1baba40658e",
        "host":"https://konnection-client.herokuapp.com",
        "displayName":"AuthorB",
        "url":"",
        "github": "http://github.com/AuthorB"
    }
}

Response Status Code

  • 200 OK: If all requirements are fulfilled
  • 400 Bad Request: If either of the author IDs is invalid
  • 401 Unauthorized: If basic auth or token is not provided
  • 404 Not Found: If the author you are trying to follow is invalid

Sample Response

The following is a sample response from the endpoint:

{
    "type": "follower",
    "items": [
        {
            "status": true,
            "author": "author A uuid",
            "follower": "author B uuid"
        }
    ]
}

4.B unfollow A

Endpoints

DELETE: /api/author/{authorA_id}/followers/{authorB_id}

Author B unfollows author A.

Endpoint Requirements

  1. Provide Token in the header for authentication purpose
  2. Logged in user must be approved by admin

Request Header

Request Header Required / optional Description Type
Authorization required Authentication Token String

Sample header --header "Authorization: Token 7ccf51cf9b2b518d789bdeaf5de1db0e530e1ab5"

Sample Response

The following is a sample response from the endpoint:

{
    "type": "unfollow",
    "items": [
        {
            "status": false,
            "author": "author A uuid",
            "follower": "author B uuid"
        }
    ]
}

Response Status Code

  • 200 OK: If all requirements are fulfilled
  • 400 Bad Request: If either of the author IDs is invalid
  • 401 Unauthorized: If basic auth or token is not provided