Forum Discussion

peter's avatar
peter
Icon for Cato Employee rankCato Employee
2 months ago

A simple example in Python

import json
import ssl
import urllib.parse
import urllib.request

headers = {
    "x-api-key": MY_API_KEY,
    "Content-Type": "application/json"
}

body = {
    "operationName": "accountSnapshot",
    "variables": {"accountID":MY_ACCOUNT_ID},
    "query": '''
query accountSnapshot($accountID:ID!) {
    accountSnapshot(accountID:$accountID) {
        id
    }
}'''
}

request = urllib.request.Request(url='https://api.catonetworks.com/api/v1/graphql2', 
                                 data=json.dumps(body).encode("ascii"),
                                 headers=headers)
response = urllib.request.urlopen(request, context=ssl._create_unverified_context())

print(json.loads(response.read().decode("utf-8","replace")))

 

  • giorgio's avatar
    giorgio
    Icon for Community Manager rankCommunity Manager

    Well that looks pretty neat! Any thoughts on the overall experience with the community peter ?

    • peter's avatar
      peter
      Icon for Cato Employee rankCato Employee

      Hey Giorgio I like the new community and I think it will be a great place to have API conversations.