Videgain
Videgain

Reputation: 195

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?

Upvotes: 3

Views: 14260

Answers (2)

Yugal
Yugal

Reputation: 79

By default we don't have OS in Colab. Explicitly mention

import os
os.environ[#Your key name] = #API key in " " or ' '

I have issue for OPENAI Key, example as below:

import os
os.environ['OPENAI_API_KEY'] =  "##########################"

Upvotes: 1

SilentCloud
SilentCloud

Reputation: 1985

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!

Upvotes: 3

Related Questions