Skip to content

Instantly share code, notes, and snippets.

@adiwids
Last active May 22, 2017 22:50
Show Gist options
  • Save adiwids/004a8b52a12d439884509fe072ec02c5 to your computer and use it in GitHub Desktop.
Save adiwids/004a8b52a12d439884509fe072ec02c5 to your computer and use it in GitHub Desktop.
Shuttersong Story API (alpha)

GET /api/stories

Fetch upto 30 stories in timeline from followed users.

Parameter Required?
access_token YES

Example cURL Request

curl -X GET \
  'http://localhost:3001/api/stories?access_token=4A4xHpx8nTxz29y3EzPy'

Example Response

Stories present Status: HTTP 200 Body:

[
    {
        "uuid": "test-unique-story-uid2",
        "title": "Story #2",
        "background_thumb_url": "/uploads/story/title_background_image/2/test-unique-story-uid2_th.jpg",
        "background_url": "/uploads/story/title_background_image/2/test-unique-story-uid2_med.jpg",
        "file_url": "/uploads/story/file/2/test-unique-story-uid2.mov",
        "mood": "Happy",
        "user": {
            "id": "c6d53d8f-0fb3-4012-8fe5-a09f9cce6dcc",
            "username": "user1",
            "picture_thumb_url": "default-mermaid.png",
            "verified": false,
            "public_shuttersong": true,
            "full_name": null,
            "username_color": null
        },
        "created_at": "2017-05-22T04:13:47-04:00"
    },
    {
        "uuid": "test-unique-story-uid16",
        "title": "Story #16",
        "background_thumb_url": "/uploads/story/title_background_image/16/test-unique-story-uid16_th.jpg",
        "background_url": "/uploads/story/title_background_image/16/test-unique-story-uid16_med.jpg",
        "file_url": "/uploads/story/file/16/test-unique-story-uid16.mov",
        "mood": "Attracted",
        "user": {
            "id": "2715d6d3-8e7b-47da-8290-12677bdb5a5d",
            "username": "user3",
            "picture_thumb_url": "default-mermaid.png",
            "verified": false,
            "public_shuttersong": true,
            "full_name": null,
            "username_color": null
        },
        "created_at": "2017-05-22T04:58:15-04:00"
    },
    {
        "uuid": "test-unique-story-uid4",
        "title": "Story #4",
        "background_thumb_url": "/uploads/story/title_background_image/4/test-unique-story-uid4_th.jpg",
        "background_url": "/uploads/story/title_background_image/4/test-unique-story-uid4_med.jpg",
        "file_url": "/uploads/story/file/4/test-unique-story-uid4.mov",
        "mood": "Happy",
        "user": {
            "id": "23d61e45-8ff2-4827-878c-f133932d4be6",
            "username": "user2",
            "picture_thumb_url": "default-mermaid.png",
            "verified": false,
            "public_shuttersong": true,
            "full_name": null,
            "username_color": null
        },
        "created_at": "2017-05-22T04:16:01-04:00"
    }
]

GET /api/stories/:uuid

Get detail of story specified by UUID parameter

Parameter Required?
access_token YES
uuid YES

Example cURL Request

curl -X GET \
  'http://localhost:3001/api/stories/test-unique-story-uid3?access_token=L9QQ2P4FsxsFySifzbgJ'

Example Response

Story found Status: HTTP 200 Body:

{
    "uuid": "test-unique-story-uid3",
    "title": "Treasure Hunt",
    "background_thumb_url": "/uploads/story/title_background_image/3/test-unique-story-uid3_th.jpg",
    "background_url": "/uploads/story/title_background_image/3/test-unique-story-uid3_med.jpg",
    "file_url": "/uploads/story/file/3/test-unique-story-uid3.mov",
    "mood": "Amused",
    "user": {
        "id": "e0051ec7-47be-4dfb-811f-4b5586f2a371",
        "username": "user2",
        "picture_thumb_url": "default-mermaid.png",
        "verified": false,
        "public_shuttersong": true,
        "full_name": null,
        "username_color": null
    },
    "created_at": "2017-05-22T04:13:47-04:00"
}

Story not found Status: HTTP 404 Body: empty

POST /api/stories

**

Parameter Required?
access_token YES
uuid YES
title YES
background YES
file YES
mood YES
send_to_all NO
recipient_ids[] YES if no/false send_to_all parameter sent

Example cURL Request

curl -X POST \
  http://localhost:3001/api/stories.json \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F access_token=L9QQ2P4FsxsFySifzbgJ \
  -F uuid=test-unique-story-uid1 \
  -F 'title=Abok Bae' \
  -F background=@00000004b164_931471fb8cbf.jpg \
  -F file=@boxxy_lense_blur.mov \
  -F mood=Happy \
  -F send_to_all=false \
  -F 'recipient_ids[]=e0051ec7-47be-4dfb-811f-4b5586f2a371' \
  -F 'recipient_ids[]=df235add-b265-46b8-990c-37566708218a'

Example Response

Story Posted Status: HTTP 200 Body:

{
    "uuid": "test-unique-story-uid1",
    "title": "Abok Bae",
    "background_thumb_url": "/uploads/story/title_background_image/1/test-unique-story-uid1_th.jpg",
    "background_url": "/uploads/story/title_background_image/1/test-unique-story-uid1_med.jpg",
    "file_url": "/uploads/story/file/1/test-unique-story-uid1.mov",
    "mood": "Happy",
    "user": {
        "id": "0977307b-6512-4298-b0cf-c8346ab37566",
        "username": "user1",
        "picture_thumb_url": "default-mermaid.png",
        "verified": false,
        "public_shuttersong": true,
        "full_name": null,
        "username_color": null
    },
    "created_at": "2017-05-22T04:13:47-04:00"
}

Story post failed, invalid parameter Status: HTTP 422 Body:

{
  "error": {
    "file": [
      "can't be blank"
    ]
  },
  "story": {
    "uuid": "test-unique-story-uid2",
    "title": "Abok Bae",
    "background_thumb_url": "/home/bocist-7/Workspaces/shuttersong/cake/tmp/uploads/1495093413-32684-3753/thumb_00000004b164_931471fb8cbf.jpg",
    "background_url": "/home/bocist-7/Workspaces/shuttersong/cake/tmp/uploads/1495093413-32684-3753/medium_00000004b164_931471fb8cbf.jpg",
    "file_url": null,
    "mood": "Happy",
    "user": {
      "id": "0977307b-6512-4298-b0cf-c8346ab37566",
      "username": "user1",
      "picture_thumb_url": "default-mermaid.png",
      "verified": false,
      "public_shuttersong": true,
      "full_name": null,
      "username_color": null
    }
  }
}

Request success, but UUID has been used Status: HTTP 200 Body: empty

PUT /api/stories/see/:uuid

Update seen timestamp of story on related user receipt record

Parameter Required?
access_token YES
uuid YES

Example cURL Request

curl -X PUT \
  'http://localhost:3001/api/stories/see/test-unique-story-uid3' \
  -d "access_token=L9QQ2P4FsxsFySifzbgJ"

Example Response

Success Status: HTTP 200 Body: empty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment