I have a code to get video urls given a channel ID that I get from the API as well, but the main part uses the requests component.
I tried running it on a channel with 3500 videos, but for some reason running it once or twice used up 6100 credits. How is this being calculated? I don't have more than 161 requests total and they're all simple search requests.
def get_video_urls(api_key, channel_id): base_url = 'https://www.googleapis.com/youtube/v3' search_url = f'{base_url}/search' video_urls = [] next_page_token = '' while True: response = requests.get(search_url, params={'key': api_key,'channelId': channel_id,'part': 'id','order': 'date','maxResults': 50,'pageToken': next_page_token }) if response.status_code != 200: print(f'Error: {response.status_code} - {response.text}') break data = response.json() for item in data.get('items', []): if item['id']['kind'] == 'youtube#video': video_id = item['id']['videoId'] video_urls.append(f'https://www.youtube.com/watch?v={video_id}') next_page_token = data.get('nextPageToken', None) if not next_page_token: break return video_urlsI tried minimizing search parameters or changing maxResults, but they don't seem to have much of an effect. Moreover the credit usage changes a lot, yesterday I capped after running it on a smaller channel twice.