Skip to content

Platform API

AdutP edited this page May 14, 2020 · 23 revisions

1. Retrieve Profile

Returns profile informations (picture/name/followers) for a platform.

GET http://sma-a4.herokuapp.com/<platform>/profile

Example: http://sma-a4.herokuapp.com/twitter/profile

Return: JSON like:

**Twitter**

{
    "followers": 0,
    "id": "AntonBarbu2",
    "name": "Anton Barbu"
}


**Linkedin**

{
    "followers": 1,
    "id": "Lw0RjmrEe_",
    "name": "Anton Barbu",
    "pages": [
        "urn:li:organization:53085711",
        "urn:li:organization:65326412"
    ],
    "pages_names": {
        "urn:li:organization:53085711": "Anton Barbu NonProfit",
        "urn:li:organization:65326412": "Anton Barbu"
    },
    "profile_picture": "https://media-exp1.licdn.com/dms/image/C4D03AQFJEccQPVg9nA/profile-displayphoto-shrink_800_800/0?e=1594857600&v=beta&t=CZdwAG2PY77XIGzykDfbzqCQnqULq126Sou1iWKNK-4"
}


**Tumblr**

{
    "followers": 0,
    "id": "octavian-blog",
    "name": "Untitled",
    "pages": [
        "octavian-blog.tumblr.com"
    ],
    "profile_picture": "https://assets.tumblr.com/images/default_avatar/sphere_closed_512.png"
}

2. Retrieve Posts

Returns posts from the Linkedin, Twitter, or Tumblr account.

GET http://sma-a4.herokuapp.com/<platform>/profile/posts

Example: http://sma-a4.herokuapp.com/linkedin/profile/posts

Return: JSON like:

{
    "posts": [
                { <post1> }, { <post2> }, ...
             ]
}

3. Retrieve Post Info

Returns information for a specific post.

GET http://sma-a4.herokuapp.com/<platform>/post/<post_id>

Example: http://sma-a4.herokuapp.com/linkedin/post/6660191712540938241

Return: JSON like:

{
    "comments_count": 0,
    "created_at": 1587913444.0,
    "id": "6660191712540938241",
    "likes": 0,
    "shares": 0,
    "text": "Test Share2!"
}

4. Platform Statistics

Returns statistics (likes/comments/shares average and sum) for a platform current week's posts.

GET http://sma-a4.herokuapp.com/<platform>/profile/posts/stats

Example: http://sma-a4.herokuapp.com/linkedin/profile/posts/stats

Return: JSON like:

{
    "comments_avg": 0.25,
    "comments_sum": 5,
    "likes_avg": 0.15,
    "likes_sum": 3,
    "shares_avg": 0.25,
    "shares_sum": 5
}

5. Post Ranking

Returns posts in descending order according to the number of likes.

GET http://sma-a4.herokuapp.com/<platform>/profile/posts/ranked

Example: http://sma-a4.herokuapp.com/twitter/profile/posts/ranked

Return: JSON like:

{
    "posts": [
        {
            "comments_count": 0,
            "created_at": 1588585518.0,
            "id": "1257244906105507840",
            "likes": 0,
            "shares": 0,
            "text": "Video1"
        }
    ]
}

6. Delete Post

Deletes a certain post.

DELETE http://sma-a4.herokuapp.com/<platform>/post/<post_id>

Example: http://sma-a4.herokuapp.com/linkedin/post/6660191712540938241

Return: JSON like:

{
    "message": "Post deleted."
}

7. Token

Returns a JWT token, signed with the key: v[ex+Tw74scKC8VS.

Example: http://sma-a4.herokuapp.com/token

8. Making a post

Creates a post, with an image, gif, video, or text. On Twitter, you can post only one gif(<15MB), one video, OR an image(<5MB) and a text.

This will post on the default page of your desired platform.

To change this default page see #13

To post on a specific Tumblr Blog / Linkedin Company see #9

POST https://sma-a4.herokuapp.com/<platform>/post

Form parameters(In Postman -> In body -> form-data): text, files[], files_url[]. The type of text and files_url[] is text. The type of files[] is File. https://assets.postman.com/postman-docs/form-file.jpg

Example: https://sma-a4.herokuapp.com/twitter/post

Return: JSON like:

{
    "message": "Posted successfully."
}

9. Post on specific Tumblr Blog / Linkedin Company

Exactly the same as #8 Making a post, but with ?page=<page_id> added as an URL argument.

Example: https://sma-a4.herokuapp.com/linkein/post?page=urn:li:organization:65326412

Example: https://sma-a4.herokuapp.com/tumblr/post?octavian-blog.tumblr.com

Return: JSON like:

{
    "message": "Posted successfully."
}

10. Retrieve Daily Follower Count

Returns the follower count history between [date_begin, date_end]. A new entry is added automatically every day at 23:30 (UTC-0), and every time a user makes a new post. The timestamp is a Unix Timestamp.

GET http://sma-a4.herokuapp.com/<platform>/profile/stats

Parameters (In Postman -> Params) :

date_begin - [default: 1 January 1970],

date_end - [default: current timestamp]

Both take a Unix Timestamp value.

Example: http://sma-a4.herokuapp.com/linkedin/profile/stats

Return: JSON like:

{
    "followers_count": [
        {
            "automatic": true,
            "followers": 1,
            "timestamp": 1589153450.618462
        },
        {
            "automatic": true,
            "followers": 1,
            "timestamp": 1589067062.466155
        },
        ...
}

11. Retrieve Daily Stats

Returns statistics (likes/comments/shares average and sum) for a platform's posts. Like #4, but timelined. A new entry is added automatically every day at 23:30 (UTC-0)

GET http://sma-a4.herokuapp.com/<platform>/profile/posts/stats/timeline

Parameters (In Postman -> Params) :

date_begin - [default: 1 January 1970],

date_end - [default: current timestamp]

Both take a Unix Timestamp value.

Example: http://sma-a4.herokuapp.com/linkedin/profile/posts/stats/timeline?date_begin=1588980671.537361&date_end=1589153450.618462

Return: JSON like:

{
        "entries": [
        {
            "comments_avg": 0.0,
            "comments_sum": 0,
            "likes_avg": 0.0,
            "likes_sum": 0,
            "shares_avg": 0.0,
            "shares_sum": 0,
            "timestamp": 1589153450.618462
        },
        {
            "comments_avg": 0.25,
            "comments_sum": 5,
            "likes_avg": 0.15,
            "likes_sum": 3,
            "shares_avg": 0.25,
            "shares_sum": 5,
            "timestamp": 1589067062.466155
        },
        {
            "comments_avg": 0.25,
            "comments_sum": 5,
            "likes_avg": 0.15,
            "likes_sum": 3,
            "shares_avg": 0.25,
            "shares_sum": 5,
            "timestamp": 1588980671.537361
        }
    ]
}

12. Retrieve Daily Follower Count

Returns the follower count history between [date_begin, date_end]. A new entry is added automatically every day at 23:30 (UTC-0), and every time a user makes a new post. The timestamp is a Unix Timestamp.

GET http://sma-a4.herokuapp.com/<platform>/profile/stats

Parameters (In Postman -> Params) :

date_begin - [default: 1 January 1970],

date_end - [default: current timestamp]

Both take a Unix Timestamp value.

Example: http://sma-a4.herokuapp.com/linkedin/profile/stats

Return: JSON like:

{
    "followers_count": [
        {
            "automatic": true,
            "followers": 1,
            "timestamp": 1589153450.618462
        },
        {
            "automatic": true,
            "followers": 1,
            "timestamp": 1589067062.466155
        },
        ...
}

13. Retrieve the default Tumblr Blog / Linkedin Company

The GET method returns the current default page. If a page has not been set, it returns null.

GET http://sma-a4.herokuapp.com/<platform>/linkedin/default_page

Example: http://sma-a4.herokuapp.com//linkedin/default_page

Return: JSON like:

{
    "default_page": "urn:li:organization:65326412"
}

POST / PUT http://sma-a4.herokuapp.com/<platform>/linkedin/default_page

Parameters (In Postman -> Body -> form-data) :

default_page - [<linkedin_urn> or <tumblr_blog_link>]

A list of companies can be found through //profile

Example: http://sma-a4.herokuapp.com/linkedin/default_page

default_page = urn:li:organization:53085711

Return: JSON like:

{
    "message": "Default page updated successfully."
}