Fork me on GitHub

Redu is a social network where members are related to each other through a connection. A user can become a contact of another one via a connection request, which may be accepted or rejected. In the context of API, the relationship between users is called connection.

Attributes:

Link Description
id Unique identifier of contact
status Current status of connection. Example: requested
user User who is receiving connection requests
contact Contact of user

States:

When user requests a connection to a contact, the connection goes to state requested for the user, and pending for the contact. When the connection is accepted, both connections go to state accepted.

State Description
requested User requested the connection
pending User has a pending request for the connection
accepted Users are contacts

GET api/users/:user_id/connections

Returns a list with all connections of a specific user.

Parameters

Parameter Description Restrictions
:user_id User ID N/A
status Filter by connection state N/A

GET api/connections/:id

Returns the connection in question.

Parameters

Parameter Description Restrictions
:id Connection ID N/A

Example

Request

GET /api/users/jessicab/connections/12

Response

{
    "links": [
    { "rel": "self", "href": "http://redu.com.br/api/connections/6501" },
    { "rel": "user", "href": "http://redu.com.br/api/users/jessicab" },
    { "rel": "contact", "href": "http://redu.com.br/api/users/julianalucena" }],
    "id": 6501,
    "contact": {
        "links": [
        { "rel": "chats","href": "http://redu.com.br/api/users/julianalucena/chats" },
        { "rel": "connections", "href": "http://redu.com.br/api/users/julianalucena/connections" },
        { "rel": "contacts", "href": "http://redu.com.br/api/users/julianalucena/contacts" },
        { "rel": "self", "href": "http://redu.com.br/api/users/julianalucena" },
        { "rel": "statuses", "href": "http://redu.com.br/api/users/julianalucena/statuses" },
        { "rel": "timeline", "href": "http://redu.com.br/api/users/julianalucena/statuses/timeline" },
        { "rel": "enrollments", "href": "http://redu.com.br/api/users/julianalucena/enrollments" }],
        "thumbnails": [
        { "href": "http://s3.amazonaws.com/redu_uploads/users/avatars/8/thumb_32/2012-10-14_14.09.33.jpg?1355925772", "size": "32x32" },
        { "href": "http://s3.amazonaws.com/redu_uploads/users/avatars/8/thumb_110/2012-10-14_14.09.33.jpg?1355925772", "size": "110x110" }],
        "id": 8,
        "last_name": "Lucena",
        "login": "julianalucena",
        "first_name": "Juliana"
    },
    "user": {
        "links": [
        { "rel": "chats","href": "http://redu.com.br/api/users/jessicab/chats" },
        { "rel": "connections", "href": "http://redu.com.br/api/users/jessicab/connections" },
        { "rel": "contacts", "href": "http://redu.com.br/api/users/jessicab/contacts" },
        { "rel": "self", "href": "http://redu.com.br/api/users/jessicab" },
        { "rel": "statuses", "href": "http://redu.com.br/api/users/jessicab/statuses" },
        { "rel": "timeline", "href": "http://redu.com.br/api/users/jessicab/statuses/timeline" },
        { "rel": "enrollments", "href": "http://redu.com.br/api/users/jessicab/enrollments" }],
        "thumbnails": [
        { "href": "http://s3.amazonaws.com/redu_uploads/users/avatars/443/thumb_32/J%C3%A9ssica.jpg?1334865750", "size": "32x32" },
        { "href": "http://s3.amazonaws.com/redu_uploads/users/avatars/443/thumb_110/J%C3%A9ssica.jpg?1334865750", "size": "110x110" }],
        "id": 443,
        "last_name": "Barbalho",
        "login": "jessicab",
        "first_name": "Jéssica"
    },
    "status": "accepted"
}

POST /api/users/:user_id/connections

Creates a new connection with the user.

Parameters

Parameter Description Restrictions
:user_id ID of user in question N/A
connection[contact_id] ID of new contact N/A

PUT /api/connections/:connection_id

Accepts a connection request which is in pending state, turning it into accepted.

Parameters

Parameter Description Restrictions
:connection_id Connection ID N/A

DELETE /api/connections/:connection_id

Deletes a connection.

Parameters

Parameter Description Restrictions
:connection_id Connection ID N/A