Getting started with Python
Alerts API querying example with Python
Request code
import requests
API_KEY = "<REPLACE_WITH_YOUR_KEY>"
API_ENDPOINT = "https://api.craft.co/v1/query"
GRAPHQL_QUERY = """
query getAlerts($first: Int!) {
alerts(first: $first) {
id
dataset
variable
}
}
"""
request_headers= { "x-craft-api-key": API_KEY }
request_data = {
"query": GRAPHQL_QUERY,
"variables": { "first": 3 }
}
response = requests.post(API_ENDPOINT, json=request_data, headers=request_headers, timeout=30)
response_data = response.json()
print(response_data)Response
Read more
Last updated
Was this helpful?