← 전체로 돌아가기
스킬 api

gspread API 연동 설정

gspread로 구글 시트 연동을 위한 GCP API 설정 가이드.

gspreadgoogle-sheets-apigcppythonapi-authentication

gspread로 구글 시트를 파이썬에서 연동하려면 GCP API 설정이 필수야.

  • GCP 설정 & Sheets API 활성화

    • GCP 콘솔에서 프로젝트 생성/선택 후, 'API 및 서비스' -> '라이브러리'에서 'Google Sheets API'를 활성화해.
  • 서비스 계정 생성 & JSON 키 발급

    • 'API 및 서비스' -> '사용자 인증 정보'로 가서 '서비스 계정'을 만들고, 생성된 계정에서 '키' 탭 -> '새 키 만들기' -> 'JSON'으로 키 파일을 다운로드해.
  • 구글 시트 공유

    • 다운받은 JSON 키 파일 내 client_email을 구글 시트의 '공유' 설정에서 '편집자' 권한으로 추가해야 함.
  • Python 코드 예시 ```python import gspread

    gc = gspread.service_account(filename='your-service-account-key.json') spreadsheet = gc.open("Your Spreadsheet Name") worksheet = spreadsheet.worksheet("Sheet1") # 또는 .get_worksheet(0) print(worksheet.get_all_values()) ```

여기서 배울 것

  1. Google Cloud Platform(GCP)에서 서비스 계정 생성 방법
  2. Google Sheets API 활성화 절차
  3. gspread 라이브러리를 이용한 구글 시트 접근 방법
  4. 서비스 계정 키를 통한 인증 및 시트 공유 설정
원본 파일 보기 (.claude/skills/tn-gspread-api-setup/SKILL.md)
---
name: gspread API 연동 설정
description: This skill should be used when the user asks to set up `gspread` for programmatic access to Google Sheets, including creating a Google Cloud Platform service account, enabling the Google Sheets API, and generating API keys for authentication.
version: 1.0.0
source: /home/son/prj/resume/backup_notes_260317/notion/Tech Note/gspread API fa15bdd395364395a9e1ba8d55534a4d.md
---

# gspread API

기존 계정이 날아감 (클라우드 콘솔 오래 안써서 삭제됨)

![Screenshot 2026-01-03 at 11.13.23 AM.png](gspread%20API/Screenshot_2026-01-03_at_11.13.23_AM.png)

![Screenshot 2026-01-03 at 12.08.51 PM.png](gspread%20API/Screenshot_2026-01-03_at_12.08.51_PM.png)

gcp에서 새로 생성

![Screenshot 2026-01-03 at 12.09.08 PM.png](gspread%20API/Screenshot_2026-01-03_at_12.09.08_PM.png)

api enable

![Screenshot 2026-01-03 at 12.09.37 PM.png](gspread%20API/Screenshot_2026-01-03_at_12.09.37_PM.png)

service account 발급

![Screenshot 2026-01-03 at 12.09.58 PM.png](gspread%20API/Screenshot_2026-01-03_at_12.09.58_PM.png)

![Screenshot 2026-01-03 at 12.10.16 PM.png](gspread%20API/Screenshot_2026-01-03_at_12.10.16_PM.png)

service account 들어가서 add key하면 json으로 받을 수 있음.

share authority

**urustin@haranggotgam.iam.gserviceaccount.com**

(previously activate google sheets api / get key and iam account)

select sheet :

.get_worksheet(index) / worksheet(’string’)

![Screenshot 2024-01-29 at 9.54.19 AM.png](gspread%20API/Screenshot_2024-01-29_at_9.54.19_AM.png)