Skip to content

Follower API

timvm1108 edited this page Mar 29, 2021 · 13 revisions

Endpoints:

/author/<str:author_id>/followers

Accepted Methods:

  • GET
    • Description: Returns a list of authors that follow the author specified in the URL.
    • Request Body: No Body Required
    • Sample Response:
{
    "type": "followers",
    "items": [
        {
            "type": "author",
            "id": "http://team6-project-socialdistrib.herokuapp.com/author/21d2d52bf3c34b84a45951d53b472a08",
            "host": "team6-project-socialdistrib.herokuapp.com",
            "displayName": "Jeff",
            "url": "http://team6-project-socialdistrib.herokuapp.com/author/21d2d52bf3c34b84a45951d53b472a08",
            "github": "https://github.com/Jeff"
        },
        {
            "type": "author",
            "id": "http://team6-project-socialdistrib.herokuapp.com/author/6978b496f79d59fa9aa9648bf88dbaaf",
            "host": "team6-project-socialdistrib.herokuapp.com",
            "displayName": "Jim",
            "url": "http://team6-project-socialdistrib.herokuapp.com/author/6978b496f79d59fa9aa9648bf88dbaaf",
            "github": "https://github.com/Jim"
        }
    ]
}

/author/<str:author_id>/followers/<str:foreign_id>

Accepted Methods:

  • GET
    • Description: Retrieves the follow object if the author foreign_id follows the author author_id, regardless of whether or not they are friends.
    • Request Body: No Body Required
    • Sample Response:
{
    "type": "Follow",
    "summary": "Jeff wants to follow Jim",
    "actor": {
        "type": "author",
        "id": "http://team6-project-socialdistrib.herokuapp.com/author/21d2d52bf3c34b84a45951d53b472a08",
        "host": "team6-project-socialdistrib.herokuapp.com",
        "displayName": "Jeff",
        "url": "http://team6-project-socialdistrib.herokuapp.com/author/21d2d52bf3c34b84a45951d53b472a08",
        "github": "https://github.com/Jeff"
    },
    "object": {
        "type": "author",
        "id": "http://team6-project-socialdistrib.herokuapp.com/author/6978b496f79d59fa9aa9648bf88dbaaf",
        "host": "team6-project-socialdistrib.herokuapp.com",
        "displayName": "Jim",
        "url": "http://team6-project-socialdistrib.herokuapp.com/author/6978b496f79d59fa9aa9648bf88dbaaf",
        "github": "https://github.com/Jim"
    }
}
  • PUT
    • Description: Creates a follow between the authors where foreign_id wants to follow author_id. This will check if the reciprocal follow already exists and sets them to be friends.
    • Request Body:
      • Field Name: Value:
        Type (Optional) "Follow"
        actor (Required) Should contain a valid author object
        object (Required) Should contain a valid author object
    • Sample Response:
{
    "type": "Follow",
    "summary": "Jeff wants to follow Jim",
    "actor": {
        "type": "author",
        "id": "http://team6-project-socialdistrib.herokuapp.com/author/21d2d52bf3c34b84a45951d53b472a08",
        "host": "team6-project-socialdistrib.herokuapp.com",
        "displayName": "Jeff",
        "url": "http://team6-project-socialdistrib.herokuapp.com/author/21d2d52bf3c34b84a45951d53b472a08",
        "github": "https://github.com/Jeff"
    },
    "object": {
        "type": "author",
        "id": "http://team6-project-socialdistrib.herokuapp.com/author/6978b496f79d59fa9aa9648bf88dbaaf",
        "host": "team6-project-socialdistrib.herokuapp.com",
        "displayName": "Jim",
        "url": "http://team6-project-socialdistrib.herokuapp.com/author/6978b496f79d59fa9aa9648bf88dbaaf",
        "github": "https://github.com/Jim"
    }
}
  • DELETE
    • Description: Delete foreign_id as a follower of author_id. This will undo friend status if a reciprocal follow exists. This will also not delete author_id as a follower of foreign_id, if such a follow exists.
    • Request Body: No Body Required
    • Sample Response:
{
    "type": "Follow",
    "summary": "Jeff wants to follow Jim",
    "actor": {
        "type": "author",
        "id": "http://team6-project-socialdistrib.herokuapp.com/author/21d2d52bf3c34b84a45951d53b472a08",
        "host": "team6-project-socialdistrib.herokuapp.com",
        "displayName": "Jeff",
        "url": "http://team6-project-socialdistrib.herokuapp.com/author/21d2d52bf3c34b84a45951d53b472a08",
        "github": "https://github.com/Jeff"
    },
    "object": {
        "type": "author",
        "id": "http://team6-project-socialdistrib.herokuapp.com/author/6978b496f79d59fa9aa9648bf88dbaaf",
        "host": "team6-project-socialdistrib.herokuapp.com",
        "displayName": "Jim",
        "url": "http://team6-project-socialdistrib.herokuapp.com/author/6978b496f79d59fa9aa9648bf88dbaaf",
        "github": "https://github.com/Jim"
    }
}

Clone this wiki locally