Skip to content

Instantly share code, notes, and snippets.

@sunny
Last active March 27, 2023 20:35
Show Gist options
  • Save sunny/7b1fe9b9db81467886e3ec954f21a64e to your computer and use it in GitHub Desktop.
Save sunny/7b1fe9b9db81467886e3ec954f21a64e to your computer and use it in GitHub Desktop.
# Example GraphQL call using https://github.com/prisma/python-graphql-client
from sgqlc.endpoint.http import HTTPEndpoint
import base64
query = '''
{
creationsBatch(limit: 3) {
results {
name(locale: EN)
url
creator {
nick
}
}
}
}
'''
variables = {}
user = 'USER'
password = 'PASSWORD'
token = base64.b64encode(str.encode(user + ':' + password)).decode()
headers = {
'Authorization': 'Basic ' + token,
'User-Agent': 'GraphQL API client'
}
url = 'https://cults3d.com/graphql'
endpoint = HTTPEndpoint(url, headers)
data = endpoint(query, variables)
data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment