Github API Search Code Trouble Shooting(?)

2024. 7. 9. 23:03·인턴 메모

Code Search Rate Limit (Error Code: 402)

This endpoint requires you to authenticate and limits you to 10 requests per minute.
  • 분당 10개의 요청을 할 경우 1분 동안 락이 걸리게 됨

 

> GitHub API의 각 Rate Limit 확인하는 방법

  • 다음의 API 요청을 보낸다 (단순 rate limit API이다)
$ curl -L \
-H "Authorization: Bearer github_pat_toooooooooookeeeeeeeeeeeeeen" \
"https://api.github.com/rate_limit"
  • 응답
{
  "resources": {
    "core": {
      "limit": 5000,
      "used": 0,
      "remaining": 5000,
      "reset": 1720514138
    },
    "search": {
      "limit": 30,
      "used": 0,
      "remaining": 30,
      "reset": 1720510598
    },
    "graphql": {
      "limit": 5000,
      "used": 0,
      "remaining": 5000,
      "reset": 1720514138
    },
    "integration_manifest": {
      "limit": 5000,
      "used": 0,
      "remaining": 5000,
      "reset": 1720514138
    },
    "source_import": {
      "limit": 100,
      "used": 0,
      "remaining": 100,
      "reset": 1720510598
    },
    "code_scanning_upload": {
      "limit": 1000,
      "used": 0,
      "remaining": 1000,
      "reset": 1720514138
    },
    "actions_runner_registration": {
      "limit": 10000,
      "used": 0,
      "remaining": 10000,
      "reset": 1720514138
    },
    "scim": {
      "limit": 15000,
      "used": 0,
      "remaining": 15000,
      "reset": 1720514138
    },
    "dependency_snapshots": {
      "limit": 100,
      "used": 0,
      "remaining": 100,
      "reset": 1720510598
    },
    "audit_log": {
      "limit": 1750,
      "used": 0,
      "remaining": 1750,
      "reset": 1720514138
    },
    "audit_log_streaming": {
      "limit": 15,
      "used": 0,
      "remaining": 15,
      "reset": 1720514138
    },
    "code_search": {
      "limit": 10,
      "used": 3,
      "remaining": 7,
      "reset": 1720510593
    }
  },
  "rate": {
    "limit": 5000,
    "used": 0,
    "remaining": 5000,
    "reset": 1720514138
  }
}
  • 현재 code search API만 사용하기 때문에 빨간 글씨 부분만 확인하면 됨
  • 현재 분당 10번 중 3번을 사용했음을 알 수 있음

 

> 해결법

  • Rate Limit을 초과할 경우 1분을 기다리는 단순 무식한 방식으로 사용 중

 


Result Access Limit (Error Code: 422)

Cannot access beyond the first 1000 results
  • 검색 결과가 1000개가 넘어갈 경우 100개씩 페이지네이션으로 10페이지 즉, 1000개까지만 검색이 가능함

 

> 해결법

https://stackoverflow.com/questions/37602893/github-search-limit-results

  • 스택오버플로우의 글을 통해 생성 날짜를 기준으로 나눠 1000개 아래의 결과를 여러 번 탐색하는 꼼수를 알게 됨
  • 하지만 현재 GitHub API에서 더 이상 생성 날짜 조건을 지원하지 않는 것으로 보임
  • 특정 language와 extension을 기준으로 묶고, 앞의 조건을 모두 제외한 나머지 파일로 나눠 탐색하는 방법으로 사용 중
    • language (e.g. java, python, c, …) 각각 탐색
    • extention (e.g. json, txt, md, …) 각각 탐색
    • 앞의 탐색 조건을 모두 부합하지 않는 나머지 파일 탐색
  • + 각 언어별로 1000개가 넘어갈 경우에는 답이 없음 -> 해결 필요

'인턴 메모' 카테고리의 다른 글

Kafka 정리  (0) 2024.07.29
GitHub Code Crawling (Selenium)  (0) 2024.07.21
GitHub File SHA Hash Test  (0) 2024.07.05
인턴 기간 중 트러블슈팅 메모 (계속해서 수정)  (0) 2024.07.05
Github API - Search Code  (1) 2024.07.04
'인턴 메모' 카테고리의 다른 글
  • Kafka 정리
  • GitHub Code Crawling (Selenium)
  • GitHub File SHA Hash Test
  • 인턴 기간 중 트러블슈팅 메모 (계속해서 수정)
csb0710
csb0710
  • csb0710
    데모장
    csb0710
  • 전체
    오늘
    어제
    • 분류 전체보기 (51)
      • 스프링부트 메모 (6)
      • 개발 메모 (3)
      • 클라우드 메모 (10)
      • 설치&설정 메모 (2)
      • 알고리즘 메모 (18)
      • 인턴 메모 (7)
      • 데이터베이스 메모 (3)
      • 책 메모 (1)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    서버 연결
    ELK Stack
    티스토리챌린지
    submodule
    코드트리조별과제
    이지퍼블리싱
    그리디
    디비설정
    코드트리
    오블완
    서버배포
    백준
    스프링부트
    디비설치
    .gitmodules
    코딩테스트
    알고리즘
    자동 답변 봇
    서버생성
    GitHub
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.2
csb0710
Github API Search Code Trouble Shooting(?)
상단으로

티스토리툴바