Last active
April 20, 2017 18:36
-
-
Save sonpython/8362c7a0f569421916f62dd1f08b95a5 to your computer and use it in GitHub Desktop.
eoddata.com soap API wrapper
This file contains hidden or 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
from zeep import Client | |
WSDL_URL = 'http://ws.eoddata.com/data.asmx?wsdl' | |
class Eoddata(): | |
''' | |
usage: | |
eod = Eoddata(username,password) | |
result = eod.send_request(action='Membership') | |
list action here: http://ws.eoddata.com/data.asmx | |
''' | |
def __init__(self, *args, **kwargs): | |
for k, v in kwargs.iteritems(): | |
setattr(self, k, v) | |
self.client = Client(WSDL_URL) | |
self.login_result = self.client.service.Login(Username=self.username, Password=self.username) | |
self.Token = self.login_result['Token'] | |
def send_request(self, *args, **kwargs): | |
kwargs['Token'] = self.Token | |
action = kwargs['action'] | |
del kwargs['action'] | |
result = getattr(self.client.service, action)(**kwargs) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment