Skip to content

Instantly share code, notes, and snippets.

@dwwoelfel
Created July 12, 2018 17:41
Show Gist options
  • Save dwwoelfel/7433808db81a4a2f5cb128cc9af639c7 to your computer and use it in GitHub Desktop.
Save dwwoelfel/7433808db81a4a2f5cb128cc9af639c7 to your computer and use it in GitHub Desktop.
Python OneGraph Client
# pip3 install gql
# pip3 install requests
from gql import Client, gql
from gql.transport.requests import RequestsHTTPTransport
APP_ID = 'YOUR_APP_ID'
client = Client(retries=2,
transport=RequestsHTTPTransport(
url='https://serve.onegraph.com/dynamic?app_id=' + APP_ID,
use_json=True))
sampleQuery = gql('''
query StockQuote($ticker: String!) {
stockDemo {
quote(ticker: $ticker) {
symbol
open
close
latestPrice
}
}
}
''')
result = client.execute(sampleQuery, {"ticker": "AAPL"})
quote = result['stockDemo']['quote']
print('{} ({}) open: {}, close: {}'.format(
quote['symbol'],
quote['latestPrice'],
quote['open'],
quote['close']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment