returns 'False' if invalid command or if no APIKey or Secret is specified (if command is "private") returns {"error":" "} if API error
(self, command, args={})
| 43 | # Main Api Function # |
| 44 | ##################### |
| 45 | def api(self, command, args={}): |
| 46 | """ |
| 47 | returns 'False' if invalid command or if no APIKey or Secret is specified (if command is "private") |
| 48 | returns {"error":"<error message>"} if API error |
| 49 | """ |
| 50 | if command in PUBLIC_COMMANDS: |
| 51 | url = 'https://poloniex.com/public?' |
| 52 | args['command'] = command |
| 53 | ret = urlopen(Request(url + urlencode(args))) |
| 54 | return json.loads(ret.read().decode(encoding='UTF-8')) |
| 55 | else: |
| 56 | return False |