Query Prismatic's API with Python
Several GraphQL client libraries exist. In this example, we'll use gql.
Install the Python GraphQL client with
pip install gql
Replace YOUR_TOKEN
with the authorization token you generated previously
from gql import gql, Client
from gql.transport.requests import RequestsHTTPTransport
token = 'YOUR_TOKEN'
api_endpoint = 'https://app.prismatic.io/api/'
transport = RequestsHTTPTransport(
url=api_endpoint,
headers={'Authorization': f'Bearer {token}'}
)
client = Client(transport=transport)
query = gql('''
query {
components {
nodes {
label
description
key
}
}
}
''')
result = client.execute(query)
print(result)