Skip to main content
Question

Help with Code by Zapier using Python

  • March 13, 2024
  • 1 reply
  • 39 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

 

Did this topic help you find an answer to your question?
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

Troy Tessalone
Forum|alt.badge.img+14

Hi @arsalan.nawazish 

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