Skip to content

Instantly share code, notes, and snippets.

@maplethorpej
Created May 1, 2018 02:06
Show Gist options
  • Save maplethorpej/260bcd5fcdfa0b301f948f42e68e0d1c to your computer and use it in GitHub Desktop.
Save maplethorpej/260bcd5fcdfa0b301f948f42e68e0d1c to your computer and use it in GitHub Desktop.
A Python wrapper around the Nomics API.
import requests
class Nomics:
base_url = 'https://api.nomics.com/v1'
api_key = None
def __init__(self, api_key):
self.api_key = api_key
def url(self, endpoint):
return '{}/{}?key={}'.format(self.base_url, endpoint, self.api_key)
def get_markets(self):
url = self.url('markets')
response = requests.get(url)
data = response.json()
return data
def get_prices(self):
url = self.url('prices')
response = requests.get(url)
data = response.json()
return data
def get_candles(self, interval, currency):
params = {
"interval": interval,
"currency": currency
}
url = self.url('candles')
response = requests.get(url, params=params)
data = response.json()
return data
def get_exchange_candles(self, interval, exchange, market):
params = {
"interval": interval,
"exchange": exchange,
"market": market
}
url = self.url('exchange_candles')
response = requests.get(url, params=params)
data = response.json()
return data
def get_dashboard(self):
url = self.url('dashboard')
response = requests.get(url)
data = response.json()
return data
def get_sparkline(self):
url = self.url('sparkline')
response = requests.get(url)
data = response.json()
return data
def get_exchange_rates(self):
url = self.url('exchange-rates')
response = requests.get(url)
data = response.json()
return data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment