@@ -0,0 +1,2056 @@
+from urllib import urlencode%0Afrom urllib2 import urlopen%0Afrom base64 import encodestring%0Afrom hashlib import sha1%0Aimport hmac%0Afrom pprint import pprint%0Afrom base64 import b64encode%0Aimport time%0Aimport json%0Aimport md5%0A%0A%0AAPI_SERVER = %22http://test.goodscloud.net%22%0AAPI_SERVER = %22http://localhost:5000%22%0A%0A%0Adef login(email, password):%0A    data = (('email', email), ('password', password),)%0A    session = json.loads(urlopen(API_SERVER + '/session', urlencode(data)).read())%0A    assert session%5B'email'%5D == email, %22Login failed%22%0A    return session%0A%0A%0Adef signed_request(path, method, params, auth, post_data=None):%0A    # the request is valid for 10 seconds%0A    expires = time.strftime('%25Y-%25m-%25dT%25H:%25M:%25SZ',%0A                            time.gmtime(time.time() + 10))%0A    params += %5B('key', auth%5B'app_key'%5D), ('token', auth%5B'app_token'%5D),%0A               ('expires', expires), %5D%0A    # parameters are sorted, but not urlencoded, for md5 digest%0A    str_params = '&'.join((%22%25s=%25s%22 %25 (a, b) for a, b in sorted(params)))%0A%0A    sign_str = '%5Cn'.join(%5B%0A        method,%0A        path,%0A        md5.new(str_params).hexdigest(),%0A        md5.new(post_data or '').hexdigest(),%0A        auth%5B'app_token'%5D,%0A        expires%0A    %5D)%0A%0A    sign = b64encode(hmac.new(str(auth%5B'app_secret'%5D),%0A                              sign_str.encode('utf-8'),%0A                              sha1).digest()).rstrip('=')%0A    params += %5B('sign', sign)%5D%0A%0A    url = API_SERVER + path + '?' + urlencode(params)%0A    return urlopen(url, post_data)%0A%0A%0Aif __name__ == %22__main__%22:%0A    # log in to get session data%0A    email = %22user1@example.org%22%0A    password = %22secret%22%0A    session = login(email, password)%0A%0A    # search for products with this GTIN%0A    gtin = %2200000000%22%0A    query = json.dumps(%7B'filters': %5B%7B%22name%22: %22gtin%22, %22op%22: %22eq%22, %22val%22: gtin%7D%5D%7D)%0A    result = signed_request('/api/internal/company_product',%0A                            'GET',%0A                            %5B('q', query),%5D,%0A                            session%5B'auth'%5D%0A                            ).read()%0A    data = json.loads(result)%0A    pprint(data)%0A

Add Python binding