Question

Help with Code by Zapier using Python

  • 13 March 2024
  • 1 reply
  • 17 views

I was using the Code by Zapier function, I was running a python script which calls a GitHub api to get contributors from a repo, but the response I’m getting is only of one of the contributors, am I doing something wrong, here’s the script attached below

 

import requests

def get_contributors(repo_url):
parts = repo_url.strip('/').split('/')
owner = parts[-2]
repo = parts[-1]

url = f'https://api.github.com/repos/{owner}/{repo}/contributors'
headers = {'Accept': 'application/vnd.github.v3+json'}
response = requests.get(url, headers=headers)

if response.status_code == 200:
contributors = response.json()
return contributors
else:
print(f"Failed to retrieve contributors. Status code: {response.status_code}")
return None

repo_url = input_data['repo_url']

contributors = get_contributors(repo_url)

return contributors

 


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Userlevel 7
Badge +14

Hi @arsalan.nawazish 

Help articles to reference for using Code app: https://zapier.com/apps/code/help