(self, product_url, params={})
return req
Make an API query and return Requests response object.
Make an API query and return Requests response object.
Make an API query and return Requests response object .
def apiquery(self, product_url, params={}):
        """Make an API query and return Requests response object."""
        requesturl = self.config['host'] + product_url
        timestamp = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')
        signature = hmac.new(self.config['key'],
                             ''.join([self.config['username'], timestamp, product_url]),
                             digestmod=hashlib.sha1).hexdigest()
        params['timestamp'] = timestamp
        params['signature'] = signature
        params['api_username'] = self.config['username']
        if 'format' not in params.keys():
            params['format'] = self.config['dataformat']
        req = requests.get(requesturl, params=params)
        if req.status_code != requests.codes.ok:
            try:
                json_response = req.json()
                self.raise_best_exception(json_response)
            except KeyError:
                raise UnexpectedError(req.status_code, req.text)
        return req
def apiquery ( self , product_url , params = { } ) : requesturl = self . config [ 'host' ] + product_url timestamp = datetime . utcnow ( ) . strftime ( '%Y-%m-%dT%H:%M:%SZ' ) signature = hmac . new ( self . config [ 'key' ] , '' . join ( [ self . config [ 'username' ] , timestamp , product_url ] ) , digestmod = hashlib . sha1 ) . hexdigest ( ) params [ 'timestamp' ] = timestamp params [ 'signature' ] = signature params [ 'api_username' ] = self . config [ 'username' ] if 'format' not in params . keys ( ) : params [ 'format' ] = self . config [ 'dataformat' ] req = requests . get ( requesturl , params = params ) if req . status_code != requests . codes . ok : try : json_response = req . json ( ) self . raise_best_exception ( json_response ) except KeyError : raise UnexpectedError ( req . status_code , req . text ) return req