Graygram Documentation

REST API Reference

REST API Overview

Image Request

Endpoint: https://www.graygram.com

GET /photos/(photo_id)/(int: width)x(int: height)

Get the binary of resized image. The value of (width) and (height) must be equal.

Error Response

The error response contains a json object named error. This object contains optional message and optional field.

Example response:

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
  "error": {
    "message": "Missing parameter",
    "field": "username"
  }
}

Authentication

Login

POST /login/username

Login using username and password.

Example request:

POST /login/username HTTP/1.1
Accept: application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "username": "devxoul",
  "photo": null,
  "created_at": "2017-02-21T16:59:35+0000",
  "id": 1
}
Form Parameters:
 
  • username – Username of the user
  • password – Password of the user
Status Codes:

Join

POST /join/username

Create a new user with username and password.

Example request:

POST /join/username HTTP/1.1
Accept: application/json

Example response:

HTTP/1.1 201 OK
Content-Type: application/json

{
  "username": "devxoul",
  "photo": null,
  "created_at": "2017-02-21T16:59:35+0000",
  "id": 1
}
Form Parameters:
 
  • username – Username of the user
  • password – Password of the user
Status Codes:

Logout

GET /logout

Logout from the current session.

Example request:

GET /logout HTTP/1.1
Accept: application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{}

Feed

GET /feed

Example request:

GET /feed HTTP/1.1
Accept: application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "data": [
    {
      "message": "생 마르탱 운하에서 본 할머니와 할아버지",
      "id": 14,
      "is_liked": false,
      "like_count": 0,
      "user": {
        "created_at": "2017-02-07T09:23:13+0000",
        "photo": {
          "id": "d7394923-cf39-4c78-891a-8714eb615ea7"
        },
        "username": "devxoul",
        "id": 1
      },
      "created_at": "2017-01-27T19:52:32+0000",
      "photo": {
        "id": "69e892b4-7dbd-403c-92fc-07f199c2be35"
      }
    },
    {
      "message": "서울의 한 골목",
      "id": 13,
      "is_liked": false,
      "like_count": 0,
      "user": {
        "created_at": "2017-02-07T09:23:13+0000",
        "photo": {
          "id": "d7394923-cf39-4c78-891a-8714eb615ea7"
        },
        "username": "devxoul",
        "id": 1
      },
      "created_at": "2017-01-27T19:52:02+0000",
      "photo": {
        "id": "1e6833e2-f041-49be-9e4a-5691d084910d"
      }
    }
  ],
  "paging": {
    "next": "https://www.graygram.com/feed?limit=2&offset=2"
  },
}
Query Parameters:
 
  • limit
  • offset
Response JSON Object:
 
  • data (array) – Array of Post
  • paging.next (string) – (Optional) Next page URL

Post

Get Post

GET /posts/(post_id)

Get a single post.

Example JSON response:

{
  "message": "생 마르탱 운하에서 본 할머니와 할아버지",
  "id": 14,
  "is_liked": false,
  "like_count": 0,
  "user": {
    "created_at": "2017-02-07T09:23:13+0000",
    "photo": {
      "id": "d7394923-cf39-4c78-891a-8714eb615ea7"
    },
    "username": "devxoul",
    "id": 1
  },
  "created_at": "2017-01-27T19:52:32+0000",
  "photo": {
    "id": "69e892b4-7dbd-403c-92fc-07f199c2be35"
  }
}
Response JSON Object:
 
  • id (int) –
  • photo (Photo) –
  • message (string) – A message (Optional)
  • user (User) – Post author
  • created_at (date) –
Status Codes:

Create Post

POST /posts

Create a post

Example JSON response:

{
  "message": "생 마르탱 운하에서 본 할머니와 할아버지",
  "id": 14,
  "is_liked": false,
  "like_count": 0,
  "user": {
    "created_at": "2017-02-07T09:23:13+0000",
    "photo": {
      "id": "d7394923-cf39-4c78-891a-8714eb615ea7"
    },
    "username": "devxoul",
    "id": 1
  },
  "created_at": "2017-01-27T19:52:32+0000",
  "photo": {
    "id": "69e892b4-7dbd-403c-92fc-07f199c2be35"
  }
}
Form Parameters:
 
  • photo – An image file
  • message – A message (Optional)
Status Codes:

Edit Post

PUT /posts/(post_id)

Edit the post

Example JSON response:

{
  "message": "생 마르탱 운하에서 본 할머니와 할아버지",
  "id": 14,
  "is_liked": false,
  "like_count": 0,
  "user": {
    "created_at": "2017-02-07T09:23:13+0000",
    "photo": {
      "id": "d7394923-cf39-4c78-891a-8714eb615ea7"
    },
    "username": "devxoul",
    "id": 1
  },
  "created_at": "2017-01-27T19:52:32+0000",
  "photo": {
    "id": "69e892b4-7dbd-403c-92fc-07f199c2be35"
  }
}
Form Parameters:
 
  • message – New message (Optional)
Status Codes:
PATCH /posts/(post_id)

Edit the post

Example JSON response:

{
  "message": "생 마르탱 운하에서 본 할머니와 할아버지",
  "id": 14,
  "is_liked": false,
  "like_count": 0,
  "user": {
    "created_at": "2017-02-07T09:23:13+0000",
    "photo": {
      "id": "d7394923-cf39-4c78-891a-8714eb615ea7"
    },
    "username": "devxoul",
    "id": 1
  },
  "created_at": "2017-01-27T19:52:32+0000",
  "photo": {
    "id": "69e892b4-7dbd-403c-92fc-07f199c2be35"
  }
}
Form Parameters:
 
  • message – New message (Optional)
Status Codes:

Delete Post

DELETE /posts/(post_id)

Delete the post

Example JSON response:

{}
Status Codes:

Like Post

POST /posts/(post_id)/likes

Like the post

Example JSON response:

{}
Status Codes:

Unlike Post

DELETE /posts/(post_id)/likes

Unlike the post

Example JSON response:

{}
Status Codes:

User

Get My Profile

GET /me

Get my profile

Example JSON response:

{
  "username": "devxoul",
  "photo": null,
  "created_at": "2017-02-21T16:59:35+0000",
  "id": 1
}
Status Codes: