I have got a dataset with names of companies and I am trying to retrieve their SIC codes. Is there an API accessible via Python that'd allow me to do so?
OpenCorporates is an agregator that collects public company information from different national registries. It also contains SIC codes whenever available. Althought access to OC's API is paid, in the past they have provided time-limited free access for particular research purposes upon written request.
However, "whenever available" above is a caveat that depends on jurisdictions and it might turn out that it is limiting particularly for your personal focus. If you are interested in one particular jurisdiction and you're lucky, on OC you would be able to find the local registrar of interest and it would have its own publicly accessible API.