Created
January 20, 2021 08:48
-
-
Save Darkflib/a419472135561ae65d855e04ae514a28 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from gql import Client, gql | |
| from gql.transport.aiohttp import AIOHTTPTransport | |
| import json | |
| import pprint | |
| pp = pprint.PrettyPrinter(indent=2) | |
| # Select your transport with a defined url endpoint | |
| transport = AIOHTTPTransport(url="https://api.github.com/graphql", headers={'Authorization': 'bearer 11111111111111111111111111abc'}) | |
| # Create a GraphQL client using the defined transport | |
| client = Client(transport=transport, fetch_schema_from_transport=True ) | |
| # Provide a GraphQL query | |
| query = gql("""query($from:String, $org:String!) { | |
| rateLimit { | |
| limit # Your maximum budget. Your budget is reset to this every hour. | |
| cost # The cost of this query. | |
| remaining # How much of your API budget remains. | |
| resetAt # The time (in UTC epoch seconds) when your budget will reset. | |
| }, | |
| organization(login: $org) { | |
| membersWithRole(first: 100, after: $from) { | |
| totalCount, | |
| pageInfo { | |
| hasNextPage | |
| endCursor | |
| }, | |
| edges{ | |
| hasTwoFactorEnabled, | |
| node{ | |
| name | |
| id | |
| login | |
| company | |
| createdAt | |
| location | |
| publicKeys { | |
| totalCount | |
| }, | |
| status { | |
| id, | |
| createdAt, | |
| emoji, | |
| expiresAt, | |
| message | |
| }, | |
| updatedAt, | |
| websiteUrl | |
| } | |
| } | |
| } | |
| } | |
| }""" | |
| ) | |
| params={"org": "somerandomorg"} | |
| result = client.execute(query, variable_values=params) | |
| #pp.pprint(result) | |
| users=result['organization']['membersWithRole']['edges'] | |
| pageinfo=result['organization']['membersWithRole']['pageInfo'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment