Search code examples
pythongoogle-colaboratoryapi-key

Setting an API Key in google colab


I have been working in Python for a short time and know I am trying to use and API that needs a key. I have been given a key consisting in a bunch of numbers and letters. When I search through the internet in order to learn how to "implement" the key I just get opinion and tips but no one talks about how to do it itself. I am using Google Colab.

Could you help me or direct me to some place where it is explained, please?


Solution

  • Here you have the code that you can use directly in Colab:

    !pip install eiapy
    import os
    os.environ['EIA_KEY'] = you_API
    
    from eiapy import Series
    cal_to_mex = Series('EBA.CISO-CFE.ID.H')
    cal_to_mex.last(5)
    

    The last 3 lines are taken from the example at this link. I tried it now and it works for me!