troubleshooting: how to connect to Magento API from Python?

Created by Raphaƫl Valyi - http://www.akretion.com on on 2011-02-22
Keywords:
xmlrpc api

open a python console:
>>> import xmlrpclib
>>> socket = xmlrpclib.ServerProxy(magento_url + "/index.php/api/xmlrpc")
>>> session = socket.login(api_username, api_password)

how to retrieve a list of Magento oders?

>>> socket.call(session, "sales_order.list", [{'state': {'neq': 'canceled'}, 'store_id': {'eq': 10}, 'increment_id': {'to': 1000000446, 'from': 1000000247}}])

replace your from/to increment_id by what you want and find out the store_id you need, you can look at the ir_model_data table in OpenERP to find out which store_id is associated to which OpenERP shop.

how to get the detail of one sale order?

>>> socket.call(session, "sales_order.info", ['1000000247'])

how to get the detail of one customer?

>>> socket.call(session, "customer.info", ['7796'])

More?

Read Magento API detail:
http://www.magentocommerce.com/support/magento_core_api