Excel / Power Query

Excel 및 Power BI 에서 코드 없이 Veacon 데이터 불러오기.

Last updated: 2026-04-23

리서치·애널리스트 팀이 Excel/Power BI 에서 바로 Veacon 데이터를 DataFrame 처럼 활용할 수 있습니다.

Excel 365 (Windows)Power BI Desktop 에서 작동합니다. Mac Excel 은 Power Query 미지원 — Python + pandas.to_clipboard() 또는 CSV export 우회 권장.


1. 쿼리 추가

Excel: 데이터 → 데이터 가져오기 → 다른 원본에서 → 웹에서 Power BI: 홈 → 데이터 가져오기 → 웹

URL 입력:

https://veacon.io/api/v1/markets/pulse?region=%EA%B0%95%EB%82%A8%EA%B6%8C&category=office&period=2026-01

고급 클릭 → HTTP 요청 헤더:

X-API-Key : veacon_pk_live_...

확인 누르면 Power Query Editor 가 열립니다.


2. JSON → 테이블 변환

Power Query Editor 에서:

  1. data 필드 선택 → "List" 표시됨
  2. "To Table" → OK → 확장 아이콘 클릭 → 모든 필드 체크
  3. 각 열의 타입 지정:
    • avg_price, median_price, price_p25, price_p75소수
    • sample_size, total_views, total_bookings정수
    • demand_index, booking_conv_rate, occupancy_proxy소수
    • confidence텍스트
  4. 닫기 및 로드 → 시트에 테이블 생성

3. M 코드로 직접 작성 (고급)

Power Query Editor 의 고급 편집기에서:

m
let
    apiKey = "veacon_pk_live_...",
    region = "강남권",
    category = "office",
    period = "2026-01",
    url = "https://veacon.io/api/v1/markets/pulse?region="
          & Uri.EscapeDataString(region)
          & "&category=" & category
          & "&period=" & period,
    Source = Json.Document(
        Web.Contents(url, [Headers=[#"X-API-Key"=apiKey]])
    ),
    data = Source[data],
    asTable = Table.FromList(data, Splitter.SplitByNothing(), null, null, ExtractValues.UseFirstNamedItemOrValue),
    expanded = Table.ExpandRecordColumn(asTable, "Column1",
        {"region","category","period","avg_price","median_price","price_p25","price_p75","sample_size","total_views","demand_index","confidence"}
    )
in
    expanded

4. 매개변수화 (여러 기간 일괄)

Parameters 를 써서 기간/지역을 시트 셀에서 받음:

m
let
    apiKey = Excel.CurrentWorkbook(){[Name="ApiKey"]}[Content]{0}[Column1],
    region = Excel.CurrentWorkbook(){[Name="Region"]}[Content]{0}[Column1],
    periods = {"2026-01","2026-02","2026-03"},

    fetchOne = (p) =>
        let
            url = "https://veacon.io/api/v1/markets/pulse?region="
                  & Uri.EscapeDataString(region)
                  & "&category=office&period=" & p,
            r = Json.Document(Web.Contents(url, [Headers=[#"X-API-Key"=apiKey]]))
        in r[data],

    allRows = List.Combine(List.Transform(periods, fetchOne)),
    asTable = Table.FromRecords(allRows)
in
    asTable

이제 워크시트에 ApiKey, Region 이라는 이름의 셀을 만들고 값을 넣으면 자동 반영.


5. 새로 고침

  • Excel: 데이터 → 모두 새로 고침 (Ctrl+Alt+F5)
  • Power BI: 홈 → 새로 고침

주의: Rate limit 절약을 위해 자동 새로 고침 주기는 1시간 이상 권장.


6. API Key 안전 저장

워크북에 평문 저장 금지 — 파일 공유 시 유출됨.

대안:

  1. 환경 변수 사용: Power Query 의 System.Environment (Power BI 엔터프라이즈)
  2. 별도 파라미터 파일: API Key 를 C:\veacon-key.txt 에 저장하고 파일 참조
  3. Power BI Service: 데이터 원본 자격 증명으로 별도 관리
m
// 예: 로컬 파일에서 키 로드
let
    apiKey = Text.Trim(Text.FromBinary(File.Contents("C:\veacon-key.txt")))

7. 에러 처리

Power Query 는 HTTP 4xx/5xx 을 에러로 던집니다. try ... otherwise 로 catch:

m
let
    result = try Json.Document(Web.Contents(url, [Headers=[#"X-API-Key"=apiKey]]))
             otherwise null,
    data = if result = null then {} else result[data]
in
    data

8. 샘플 Excel 템플릿

veacon-excel-template.xlsx (준비 중 — P6 에서 공개 예정)

현재는 위 M 코드를 직접 붙여넣어 사용하세요.


참고