← 전체로 돌아가기
스킬 api

gspread API 연동

gspread API 연동 위해 GCP 계정, 서비스 계정 다시 팜.

gspreadgoogle-sheetsapigcpservice-account

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

GCP에서 새 프로젝트 생성.

Google Sheets API enable.

Service account 발급.

Service account 들어가서 key 추가, JSON 파일로 받음.

Google Sheet에 서비스 계정 이메일 공유. [서비스 계정 이메일] (예: urustin@haranggotgam.iam.gserviceaccount.com)

파이썬에서 gspread 사용:

import gspread

gc = gspread.service_account(filename='[json 파일 경로]')
sh = gc.open('[스프레드시트 이름]')

# 워크시트 선택
worksheet = sh.get_worksheet([인덱스]) # 0부터 시작
# 또는
worksheet = sh.worksheet('[시트 이름]')
  • gc.open('[스프레드시트 이름]'): 스프레드시트 이름으로 열기.
  • sh.get_worksheet([인덱스]): 인덱스로 워크시트 선택.
  • sh.worksheet('[시트 이름]'): 이름으로 워크시트 선택.

여기서 배울 것

  1. GCP에서 새 프로젝트 파는 것부터 시작.
  2. Google Sheets API는 따로 enable 해야 함.
  3. Service account 만들고 JSON 키 받아야 함.
  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)