<commit_before>import requests

BASE_URL = "http://api.foodessentials.com/"
DEFAULT_PARAMS = {'appid': 'h3hw38z6ucxzy67rbjpyk8jy',
                  'f': 'json'}

def get(method, params):
    r = requests.get(BASE_URL+method, params=params)
    return r

def label(sid, barcode):
    params = DEFAULT_PARAMS.copy()
    params['sid'] = sid
    params['u'] = barcode
    return get('label', params)

def createsession(user_id, device_id, version):
    params = DEFAULT_PARAMS.copy()
    params['uid'] = user_id
    params['devid'] = device_id
    params['v'] = version
    return get('createsession', params)<commit_msg>added get_ingredients<commit_after>import requests

BASE_URL = "http://api.foodessentials.com/"
DEFAULT_PARAMS = {'appid': 'h3hw38z6ucxzy67rbjpyk8jy',
                  'f': 'json'}
SESSION_ID = _tomsession()


def _tomsession():
    return createsession('tom', 'test')


def get(method, params):
    r = requests.get(BASE_URL+method, params=params, data={'api_key': params['appid']})
    return r


def label(sid, barcode):
    params = DEFAULT_PARAMS.copy()
    params['sid'] = sid
    params['u'] = barcode
    return get('label', params)


def createsession(user_id, device_id):
    params = DEFAULT_PARAMS.copy()
    params['uid'] = user_id
    params['devid'] = device_id
    return get('createsession', params).json()['session_id']


def get_ingredients(barcode):
    r = label(SESSION_ID, barcode)
    return r.json()
{'fraction_non_alphanumeric': 0.14760914760914762, 'fraction_numerical': 0.009702009702009701, 'mean_word_length': 4.031358885017422, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1702855', 'n_tokens_mistral': 505, 'n_tokens_neox': 491, 'n_words': 101}