Labelbox

Python Hello World

Here is an example of how to run a Labelbox graphql query in a python script. The below file will print out your user information.

# Two things to run this script
# 1. run "pip install graphqlclient"
# 2. Fill in <API-KEY-HERE> (https://app.labelbox.com/settings/apikey)

import json
from graphqlclient import GraphQLClient
client = GraphQLClient('https://api.labelbox.com/graphql')
client.inject_token('Bearer <API-KEY-HERE>')

def me():
    res_str = client.execute("""
    query GetUserInformation {
      user {
        id
        email
        organization{
          id
        }
      }
    }
    """)

    res = json.loads(res_str)
    return res['data']['user']

if __name__ == "__main__":
  user_info = me()  
  print(user_info)