Skip to content

Backend API Follower & Friends

Nhan Nguyen edited this page Mar 31, 2021 · 3 revisions

Friend & Follower & Friend Request

/service/author/{AUTHOR_ID}/followers/ to retrieve a list of authors who are their followers

  • Request method: GET
  • example response:
{
    # type of item in the items
    "type": "followers",      
    # list of followers
    "items":[
        {
            "type":"author",
            "id":"http://127.0.0.1:5454/author/1d698d25ff008f7538453c120f581471",
            "displayName":"Greg Johnson",
            "github": "http://github.com/gjohnson"
        },
        {
            "type":"author",
            "id":"http://127.0.0.1:5454/author/9de17f29c12e8f97bcbbd34cc908f1baba40658e",
            "displayName":"Lara Croft",
            "github": "http://github.com/laracroft"
        }
    ]
}
  • response status code:
    • 200: OK
    • 404: no followers found or incorrect id of author

/service/author/{AUTHOR_ID}/followers/{FOREIGN_AUTHOR_ID}/ to remove a follower/friend, add a follower/friend, or check if is follower (requires logged in)

  • Request method: PUT, DELETE, GET
  • Note:
    • if {FOREIGN_AUTHOR_ID} already followed {AUTHOR_ID}, PUT will be equivalent to {AUTHOR_ID} befriend and follow {FOREIGN_AUTHOR_ID}
    • if {AUTHOR_ID} and {FOREIGN_AUTHOR_ID} are friend, DELETE will be equivalent to {AUTHOR_ID} unfriend and unfollow {FOREIGN_AUTHOR_ID}
  • example response:
{
    "message": "success",
}
  • response status code:
    • 200: success, added as friends and followers
    • 200: unfollow and unfriend success
    • 200: success
    • 200: unfollow success
    • 404: author has no followers or incorrect id of author
    • 404: foreign id is not a follower
    • 404: invalid foreign id
    • 405: method not allowed
    • 400: author id and foreign author id are the same

/service/author/{AUTHOR_ID}/friends/ to retrieve a list of authors who are their friends

  • Request method: GET
  • example response:
{
    # type of item in the items
    "type": "friend",      
    # list of friends
    "items":[
        {
            "type":"author",
            "id":"http://127.0.0.1:5454/author/1d698d25ff008f7538453c120f581471",
            "displayName":"Greg Johnson",
            "github": "http://github.com/gjohnson"
        },
        {
            "type":"author",
            "id":"http://127.0.0.1:5454/author/9de17f29c12e8f97bcbbd34cc908f1baba40658e",
            "displayName":"Lara Croft",
            "github": "http://github.com/laracroft"
        }
    ]
}
  • response status code:
    • 200: OK
    • 404: no followers found or incorrect id of author
    • 405: method not allowed

/service/author/{AUTHOR_ID}/friends/{FOREIGN_AUTHOR_ID}/ to check if foreign_author_id is friend with author_id

  • Request method: GET, PUT
  • example response:
{
    # type of item in the items
    "message": "success",      
}
  • response status code:
    • 200: success
    • 404: author has no friends or incorrect id of author
    • 404: foreign id is not a follower
    • 404: invalid foreign id
    • 405: actor id is not in any existing sharing node. Contact admin server to add your node to our server
    • 400: author id and foreign author id are the same

/service/author/{AUTHOR_ID}/nonfollowers/ to retrieve a list of authors who are not their followers or friends (requires logged in)

  • Request method: GET
  • example response:
{
    # type of item in the items
    "type": "nonfollower",      
    # list of followers
    "items":[
        {
            "type":"author",
            "id":"http://127.0.0.1:5454/author/1d698d25ff008f7538453c120f581471",
            "displayName":"Greg Johnson",
            "github": "http://github.com/gjohnson"
        },
        {
            "type":"author",
            "id":"http://127.0.0.1:5454/author/9de17f29c12e8f97bcbbd34cc908f1baba40658e",
            "displayName":"Lara Croft",
            "github": "http://github.com/laracroft"
        }
    ]
}
  • response status code:
    • 200: OK
    • 404: no non-followers found
    • 405: method not allowed

Clone this wiki locally