IDEAS home Printed from
   My bibliography  Save this paper

Stata–Python API for bulk data download: Example with UN Comtrade


  • Ka Lok Wong

    (Geneva Graduate Institute)


This presentation aims to guide the audience through the bulk download of Comtrade data via a Stata–Python integration setup that has been made available since Stata 16. Though this presentation is explicitly about the UN Comtrade dataset, the methodology employed is generalizable to other data platforms that allow API downloads. The UN Comtrade Database is one of the best sources when it comes to bilateral trade data by product code. As of early 2022, it covers more country-year observations than the World Trade 1 Organization and the International Trade Centre. However, tailoring the raw data to each researcher’s needs is often time-consuming. Using the Comtrade API with my Stata–Python setup would allow researchers to tailor their downloaded data to their desired specification. In addition, employing this setup significantly reduces human error when compared with the manual downloading and cleaning of Comtrade data.

Suggested Citation

  • Ka Lok Wong, 2022. "Stata–Python API for bulk data download: Example with UN Comtrade," Swiss Stata Conference 2022 03, Stata Users Group.
  • Handle: RePEc:boc:csug22:03

    Download full text from publisher

    File URL:
    Download Restriction: no

    More about this item

    NEP fields

    This paper has been announced in the following NEP Reports:


    Access and download statistics


    All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:boc:csug22:03. See general information about how to correct material in RePEc.

    If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

    We have no bibliographic references for this item. You can help adding them by using this form .

    If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.

    For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: Christopher F Baum (email available below). General contact details of provider: .

    Please note that corrections may take a couple of weeks to filter through the various RePEc services.

    IDEAS is a RePEc service. RePEc uses bibliographic data supplied by the respective publishers.