API 목록

내 알림 목록 조회 API

Curl request

$ curl 'http://localhost:8080/api/v1/notifications/me?page=1&size=10' -i -X GET \
    -H 'X-USER-ID: 1'

HTTP request

GET /api/v1/notifications/me?page=1&size=10 HTTP/1.1
X-USER-ID: 1
Host: localhost:8080

HTTP response

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

{
  "success" : true,
  "code" : "SUCCESS",
  "message" : "",
  "data" : {
    "notifications" : [ {
      "userId" : 1,
      "title" : "알림 제목",
      "content" : "알림 본문",
      "readAt" : "2024-03-13T14:29:11.703958333Z",
      "createdAt" : "2024-03-13T14:29:11.703985233Z",
      "data" : {
        "type" : "comment",
        "commentId" : 1,
        "articleId" : 1
      }
    }, {
      "userId" : 1,
      "title" : "알림 제목",
      "content" : "알림 본문",
      "readAt" : null,
      "createdAt" : "2024-03-13T14:29:11.704471046Z",
      "data" : {
        "type" : "articleLike",
        "articleId" : 1
      }
    } ],
    "page" : 1,
    "size" : 10,
    "totalPages" : 1,
    "numberOfElements" : 1,
    "totalElements" : 1
  }
}

HTTPie request

$ http GET 'http://localhost:8080/api/v1/notifications/me?page=1&size=10' \
    'X-USER-ID:1'

Query parameters

Parameter Description

page

페이지

size

페이지 사이즈

Request body

Request headers

Name Description

x-user-id

로그인한 유저 id

Response body

{
  "success" : true,
  "code" : "SUCCESS",
  "message" : "",
  "data" : {
    "notifications" : [ {
      "userId" : 1,
      "title" : "알림 제목",
      "content" : "알림 본문",
      "readAt" : "2024-03-13T14:29:11.703958333Z",
      "createdAt" : "2024-03-13T14:29:11.703985233Z",
      "data" : {
        "type" : "comment",
        "commentId" : 1,
        "articleId" : 1
      }
    }, {
      "userId" : 1,
      "title" : "알림 제목",
      "content" : "알림 본문",
      "readAt" : null,
      "createdAt" : "2024-03-13T14:29:11.704471046Z",
      "data" : {
        "type" : "articleLike",
        "articleId" : 1
      }
    } ],
    "page" : 1,
    "size" : 10,
    "totalPages" : 1,
    "numberOfElements" : 1,
    "totalElements" : 1
  }
}

Response fields

Path Type Description

success

Boolean

성공 여부

code

String

결과 코드

message

String

메시지

data.page

Number

페이지

data.size

Number

페이지 사이즈

data.totalPages

Number

총 페이지 수

data.numberOfElements

Number

반환된 데이터 개수

data.totalElements

Number

전체 데이터 개수

data.notifications

Array

알림 목록

data.notifications[].userId

Number

사용자 id

data.notifications[].title

String

알림 제목

data.notifications[].content

String

알림 본문

data.notifications[].readAt

String

읽은 시간

data.notifications[].createdAt

String

알림 생성 시간

data.notifications[].data

Object

알림 동적 데이터

data.notifications[].data.type

String

알림 데이터 타입

알림 확인 API

Curl request

$ curl 'http://localhost:8080/api/v1/notifications/me/read' -i -X PUT \
    -H 'X-USER-ID: 1'

HTTP request

PUT /api/v1/notifications/me/read HTTP/1.1
X-USER-ID: 1
Host: localhost:8080
Content-Type: application/x-www-form-urlencoded

HTTP response

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

{
  "success" : true,
  "code" : "SUCCESS",
  "message" : "",
  "data" : 3
}

HTTPie request

$ http PUT 'http://localhost:8080/api/v1/notifications/me/read' \
    'X-USER-ID:1'

Request body

Request headers

Name Description

x-user-id

로그인한 유저 id

Response body

{
  "success" : true,
  "code" : "SUCCESS",
  "message" : "",
  "data" : 3
}

Response fields

Path Type Description

success

Boolean

성공 여부

code

String

결과 코드

message

String

메시지

data

Number

확인한 알림 갯수

확인하지 않은 알림 유무 API

Curl request

$ curl 'http://localhost:8080/api/v1/notifications/me/unread' -i -X GET \
    -H 'X-USER-ID: 1'

HTTP request

GET /api/v1/notifications/me/unread HTTP/1.1
X-USER-ID: 1
Host: localhost:8080

HTTP response

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

{
  "success" : true,
  "code" : "SUCCESS",
  "message" : "",
  "data" : true
}

HTTPie request

$ http GET 'http://localhost:8080/api/v1/notifications/me/unread' \
    'X-USER-ID:1'

Request body

Request headers

Name Description

x-user-id

로그인한 유저 id

Response body

{
  "success" : true,
  "code" : "SUCCESS",
  "message" : "",
  "data" : true
}

Response fields

Path Type Description

success

Boolean

성공 여부

code

String

결과 코드

message

String

메시지

data

Boolean

확인하지 않은 알림 존재 유무