# Python Client https://api-docs.lumar.io/docs/graphql-clients/python In this example we will be using [gql](https://github.com/graphql-python/gql) python GraphQL client. ### Install dependencies and fetch latest GraphQL schema ```bash $ pip install gql[all] $ curl https://api.lumar.io/schema.graphql > schema.graphql ``` ### Setup ENV variables for authenticating with Lumar API Creating [User key](/docs/graphql/authentication.md#creating-api-user-key) to use for API authentication. ``` export DEEPCRAWL_SECRET_ID="YourSecretId" export DEEPCRAWL_SECRET="YourSecret" ``` ### Create your script file In this example we will be logging in/creating session token and using it to query the API for my accounts list. ```python title="script.py" from gql import gql, Client from gql.transport.aiohttp import AIOHTTPTransport from graphql import build_schema import json import os transport = AIOHTTPTransport(url="https://api.lumar.io/graphql", headers={}) with open('./schema.graphql') as source: document = source.read() schema = build_schema(document) client = Client(transport=transport, schema=schema) login_mutation = gql( """ mutation LoginWithUserKey($secret: String!, $userKeyId: ObjectID!) { createSessionUsingUserKey(input: { userKeyId: $userKeyId, secret: $secret }) { token } } """ ) login_variables = { "secret": os.environ['DEEPCRAWL_SECRET'], "userKeyId": os.environ['DEEPCRAWL_SECRET_ID'] } login_result = client.execute(login_mutation, variable_values=login_variables) session_token = login_result['createSessionUsingUserKey']['token'] transport.headers['x-auth-token'] = session_token accounts_query = gql( """ query MyAccounts { me { accounts(first: 10) { totalCount nodes { id name } } } } """ ) accounts_result = client.execute(accounts_query) print(json.dumps(accounts_result)) ``` ### Run your script ```bash $ python script.py ``` #### Successfull run will print out something like: ```json { "me": { "accounts": { "totalCount": 1, "nodes": [{ "id": "TjAwN0FjY291bnQyMTkyMQ", "name": "Your account name" }] } } } ``` Code from this example can be found on our [Github](https://github.com/deepcrawl/api-docs-examples/tree/main/python).