Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Access GitHub GraphQL queries easily in Python
Dillon Barnes
Dillon Barnes

Posted on

     

Access GitHub GraphQL queries easily in Python

Hi!

In this post I'm going to share a Python package that aims to make it easy to use GitHub's GraphQL API in projects. No more fiddling around with queries and turning them into Python dictionaries! Interested? Read on!

What is it?

Recently, I've been developing a package for Python calledpygitapi. This package will utilise the GitHub GraphQL API to get data for the user.BitBucket and GitLab support are planned for future releases.

The main aim of the package is to make it easy to use the GraphQL API and get the info you need.

Installation

To install via pip, do the following:

pip install --upgrade pygitapi
Enter fullscreen modeExit fullscreen mode

Usage

For full information on the functions, check out thedocumentation. However, here's a small sample of what you can do.

frompygitapiimportHubAPIimportjsonh=HubAPI('PERSONAL_ACCESS_TOKEN')response=h.user_info('DillonB07')print(json.dumps(response,indent=4))print(f'Portfolio -{response["user"]["websiteUrl"]}')
Enter fullscreen modeExit fullscreen mode

This returns the following:

{"user":{"avatarUrl":"https://avatars.githubusercontent.com/u/83948303?v=4","bio":"An aspiring web developer who likes making weird and useless projects","company":"Replit Coder | Hobby Coder","email":"dillonbarnes07@gmail.com","followers":{"totalCount":7},"following":{"totalCount":17},"isCampusExpert":false,"isDeveloperProgramMember":true,"issues":{"totalCount":60},"itemShowcase":{"hasPinnedItems":true,"items":{"nodes":[{"name":"GitAPI"},{"name":"Portfolio"},{"name":"QAPI"},{"name":"Dizzle"},{"name":"Spotter"},{"name":"FlaskBoilerplate"}]}},"location":"GMT, Leicester","login":"DillonB07","name":"Dillon Barnes","organizations":{"nodes":[],"totalCount":0},"pullRequests":{"totalCount":38},"repositories":{"totalCount":41},"starredRepositories":{"totalCount":76},"status":null,"twitterUsername":null,"url":"https://github.com/DillonB07","websiteUrl":"https://dillonb07.is-a.dev"}}Portfolio-https://dillonb07.is-a.dev
Enter fullscreen modeExit fullscreen mode

Links:

Thanks for reading! I hope that this package will be useful to you. If there are any features that you'd like to see added, write a comment below, or create an issue on GitHub.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

An aspiring web developer who enjoys working with Python, HTML, CSS, React and NextJS. I'm learning Machine Learning.
  • Location
    Leicester, England
  • Joined

More fromDillon Barnes

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp