/search-blog

입력된 검색어로 카카오, 네이버 등 블로그 검색 Open API를 활용하여 '블로그 검색 서비스'를 제공합니다.

Primary LanguageKotlin

Blog Search API

(깃허브 : https://github.com/Haeya/search-blog)

(다운로드 : https://drive.google.com/file/d/1PBZhS2l8Ez3MyLN1w6IqfEr00VvzqHTJ/view?usp=share_link)


Description

입력된 검색어로 카카오, 네이버 블로그 검색 Open API를 활용하여 '블로그 검색 서비스'를 제공합니다.

Endpoint

GET /blog

Request Parameters

Name Type Required Default Description
query string Yes N/A 검색어
sort string No accuracy 검색 결과 정렬 기준 (accuracy - 정확도순, recency - 최신순)
page integer No 1 페이지 번호
size integer No 10 한 페이지에 보여질 검색 결과 수

Response

  • data
    • body
      • documents: 검색 결과 리스트
    • statusCodeValue: API 결과 코드 Value
    • statusCode: API 결과 코드
  • message: API 호출 메시지

Example Request

GET '/blog?query=test&sort=recency&page=1&size=10'

Example Response

  • kakao api
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
    "data": {
        "headers": {},
        "body": {
          "documents": [
              {
                  "blogname": "test blog",
                  "contents": "test data입니다...",
                  "datetime": "2023-03-22T01:01:01.000+09:00",
                  "thumbnail": "",
                  "title": "test data입니다.",
                  "url": "http://blog.naver.com/test/1"
              },
              ...,
              {
                  "blogname": "test blog",
                  "contents": "test data입니다...",
                  "datetime": "2023-03-22T01:01:01.000+09:00",
                  "thumbnail": "",
                  "title": "test data입니다.",
                  "url": "http://blog.naver.com/test/10"
              },
              ...
          ],
          "pagination": {
                "page": 1,
                "size": 10,
                "totalCount": 20,
                "totalPages": 2
          }
        },
        "statusCodeValue": 200,
        "statusCode": "OK"
    },
    "message": "success"
}
  • naver api: kakao api의 결과 코드가 200이 아닌 경우
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
    "data": {
        "headers": {},
        "body": {
          "documents": [
              {
                  "title": "test data입니다.",
                  "link": "https://blog.naver.com/test/1",
                  "description": "test data입니다...",
                  "bloggername": "testblogger",
                  "bloggerlink": "blog.naver.com/test",
                  "postdate": "20230322"
              },
              ...,
              {
                  "title": "test data입니다.",
                  "link": "https://blog.naver.com/test/10",
                  "description": "test data입니다...",
                  "bloggername": "testblogger",
                  "bloggerlink": "blog.naver.com/test",
                  "postdate": "20230322"
              }
          ],
          "pagination": {
                "page": 1,
                "size": 10,
                "totalCount": 20,
                "totalPages": 2
          }
        },
        "statusCodeValue": 200,
        "statusCode": "OK"
    },
    "message": "success"
}

Description

많이 검색된 순서대로 최대 10개의 검색어를 반환합니다.

Endpoint

GET /keyword

Request Parameters

Name Type Required Default Description
size integer No 10 키워드 목록에 포함될 최대 검색어 수

Response

  • data
    • keywords: 인기 검색어
    • count: 검색어 별 검색된 횟수
  • message: API 호출 메시지

Example Request

GET '/keyword?size=4'

Example Response

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8

{
  "data": [
    {
      "keyword": "spring boot",
      "count": 30
    },
    {
      "keyword": "kotlin",
      "count": 25
    },
    {
      "keyword": "restful api",
      "count": 20
    },
    {
      "keyword": "java",
      "count": 10
    }
  ],
  "message": "success"
}