Skip to main content

Getting Stated with Python Project

Installation#

WARNING: Please note that the following documentation describes the current version which is currently only available as a pre-release and needs to be installed with

$ pip install --pre gql[all]

NOTE: See also the documentation to install GQL with less extra dependencies

note

Always remember to replace API_SECRET with the correct value that you copied from apito console. Go to this page if you do not know where to find your api secrets for your project

Basic usage#

from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport
# Select your transport with a defined url endpoint
transport = AIOHTTPTransport(url="https://api.apito.io/secured/graphql", headers={'Authorization': 'Bearer API_SECRET'})
# Create a GraphQL client using the defined transport
client = Client(transport=transport, fetch_schema_from_transport=True)
# Provide a GraphQL query
query = gql(
"""
query getContinents {
continents {
code
name
}
}
"""
)
# Execute the query on the transport
result = client.execute(query)
print(result)

Detailed Guide#

For a detailed guide, be sure to check out the official github page here