Ejemplo n.º 1
0
    def __init__(self, key, secret, id):

        self._conn = api.hmac(key, secret)

        log.debug("[*] get initial info...")

        self._ad_id = id

        self.getMyAdInfo()

        log.debug(pprint.pformat(self._ad0))
Ejemplo n.º 2
0
def lbtcBalance(lbtcKey, lbtcSecret):
    '''usage: from lbcapi import api 
    lbcBalance(key, secret)
    returns balance as float'''
    hmac_key = lbtcKey
    hmac_secret = lbtcSecret
    conn = api.hmac(hmac_key, hmac_secret)
    lbcBal = conn.call('GET', '/api/wallet-balance/').json()
    ts = datetime.datetime.fromtimestamp(
        time.time()).strftime('%Y-%m-%d %H:%M:%S')
    balance = lbcBal["data"]['total']['balance']
    coinBalance = ['localbtc', 'income', float(balance), ts]
    coinBalance = [str(ele) for ele in coinBalance]
    return ','.join(coinBalance)
Ejemplo n.º 3
0
 def __init__(self):
     """Establish connection using keys.json file"""
     self.config = Config.get_monitorconfig()
     # Get keys and establish connection
     with open('./keys.json') as f:
         keys = json.load(f)
     self.__hmac_key = keys["READ"]["key"]
     self.__hmac_secret = keys["READ"]["secret"]
     self.__conn = api.hmac(self.__hmac_key, self.__hmac_secret)
     # Set email notification time
     self.set_reporttime(self.config["report_hours"],
                         self.config["report_minutes"],
                         self.config["report_tz"])
     # Set optimal rate status
     self.__optrate = {
         'rate': self.config["trans_threshold"],
         'time': datetime.datetime.utcnow() - datetime.timedelta(hours=1)
     }
Ejemplo n.º 4
0
    def __thread_worker(self, hmac, hmac_secret, method, url, on_finished_callback, repeat_if_failure):
        try:
            conn = api.hmac(hmac, hmac_secret)
            on_finished_callback(conn.call(method, url).json())
        except ConnectionError:
            if self.__request_failures_counter is 0:  # is first error
                self.on_error_occurred.emit('No network access')

            self.__request_failures_counter += 1
            if repeat_if_failure is True:
                thread = Timer(self.__REQUEST_REPEAT_DELAY_SEC,
                               function=self.__thread_worker, args=(hmac, hmac_secret, method, url,
                                                                    on_finished_callback, repeat_if_failure))
                thread.start()
        except Exception:
            self.on_error_occurred.emit('Internal API error!')
        else:
            self.__request_failures_counter = 0
Ejemplo n.º 5
0
def get_lbtc_balance():
    conn = api.hmac(hmac_key, hmac_secret)
    # NOTE TO VASKO: Using closed transactions for testing. should be open transactions.
    data = conn.call('GET', '/api/wallet-balance/').json()
    return data['data']['total']['balance']
Ejemplo n.º 6
0
def getLBTCData():
    conn = api.hmac(hmac_key, hmac_secret)
    # NOTE TO VASKO: Using closed transactions for testing. should be open transactions.
    return conn.call('GET', '/api/dashboard/').json()
Ejemplo n.º 7
0
from lbcapi import api
import requests

x = requests.get('https://localbitcoins.com/buy-bitcoins-online/.json')

conn = api.hmac("", "")
print(conn.call('GET', '/buy-bitcoins-online/.json').json())
Ejemplo n.º 8
0
 def connect(self):
     return api.hmac(self.read_key, self.read_sn)
Ejemplo n.º 9
0
from lbcapi import api

conn = api.hmac("hmac_key", "hmac_secret")
print(conn.call('GET', '/buy-bitcoins-online/.json').json())
Ejemplo n.º 10
0
def getLBTCData():
    conn = api.hmac(hmac_key, hmac_secret)
    return conn.call('GET', '/api/dashboard/').json()
Ejemplo n.º 11
0
def getLBTCUserName():
    conn = api.hmac(hmac_key, hmac_secret)
    data = conn.call('GET', '/api/myself/').json()
    myUserName = data['data']['username']
    print('Username: ' + myUserName)
    return myUserName
Ejemplo n.º 12
0
def call_api_get(ep):
    conn = api.hmac()
    resp = make_response(conn.call('GET', f'/api/{ep}/').json())
    resp.headers['Access-Control-Allow-Origin'] = '*'
    return resp
 def __init__(self, hmac_key, hmac_secret, usr_name, prv_money=0):
     self.hmac_key = hmac_key
     self.hmac_secret = hmac_secret
     self.conn = api.hmac(hmac_key, hmac_secret)
     self.usr_name = usr_name
     self.prv_money = prv_money
Ejemplo n.º 14
0
from lbcapi import api
import urllib.parse
import logging
import time
import datetime

HMAC_KEY = ''
HMAC_SECRET = ''

MAX_PRICE_INR = 3395000
MIN_PRICE_INR = 3393000

PROVIDER_IMPS = 'BANK_TRANSFER_IMPS'
SLEEP_TIME = 1

conn = api.hmac(HMAC_KEY, HMAC_SECRET)

date = datetime.datetime.now()
logging.basicConfig(filename='logFile{datetime_val}.log'.format(datetime_val=date.strftime("%d%m%Y%H%M%S")),
                    level=logging.DEBUG)


def get_current_ads_info():
    response = conn.call('GET', '/api/ads/').json()
    data = response['data']
    ad_list = data['ad_list']
    price_dict = {}

    for ad in ad_list:
        ad_data = ad['data']
        ad_id = ad_data['ad_id']
Ejemplo n.º 15
0
# coding: utf-8
from __future__ import unicode_literals

from lbcapi import api

HMAC_KEY = '25c00b2ac4357030a28507bde0316d8a'
HMAC_SECRET = 'd7f646c6ee45322db5910e46c55c82a427c6aa555d7172f2709b8d8f90a20ef5'

net = api.hmac(HMAC_KEY, HMAC_SECRET)
print net.call('GET', '/sell-bitcoins-online/usd/paypal/.json').json()

Ejemplo n.º 16
0
 def get_api_conn(self):
     if not hasattr(self, '_conn') or not self._conn:
         self._conn = api.hmac(self.api_key, self.api_secret)
     return self._conn
Ejemplo n.º 17
0
def get_lbtc_balance():
    conn = api.hmac(hmac_key, hmac_secret)
    data =  conn.call('GET', '/api/wallet-balance/').json()
    return data['data']['total']['balance']
Ejemplo n.º 18
0
def getRecievingLBTCAddress():
    conn = api.hmac(hmac_key, hmac_secret)
    data = conn.call('GET', '/api/wallet-addr/').json()
    return data['data']['address']
Ejemplo n.º 19
0
# encoding: utf-8

import sys

from lbcapi import api

import json

# Argumentos recibidos desde php (clave, clave secreta y ruta de la api)
hmac_key = sys.argv[1]

hmac_secret = sys.argv[2]

api_url = sys.argv[3]

# Cargamos los datos básicos del usuario correspondiente a la autenticación HCMAC
#~ conn = api.hmac(hmac_key, hmac_secret)
#~ conn = conn.call('GET', '/api/myself/').json()

# Cargamos los datos básicos del wallet correspondiente a la autenticación HCMAC
#~ conn = api.hmac(hmac_key, hmac_secret)
#~ conn = conn.call('GET', '/api/wallet/').json()

# Cargamos la lista de las transacciones cerradas correspondientes a la autenticación HCMAC
conn = api.hmac(hmac_key, hmac_secret)
conn = conn.call('GET', api_url).json()
# Convertimos el objeto python a formato json usando json.dumps,
# ya que sin esto el resultado sería una cadena con formato parecido pero incorrecto
conn = json.dumps(conn)
print conn