Created
July 12, 2018 17:41
-
-
Save dwwoelfel/7433808db81a4a2f5cb128cc9af639c7 to your computer and use it in GitHub Desktop.
Python OneGraph Client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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