How to connect API Key
# 🤝help
f
Hey! I am making a sports betting chatbot and have a good API key to use, but idk how to set it up to pull info effectively and accurately. Can someone help?
f
Hi, Do you have the code to do the API requests? Did you try bot variables or configuration variables?
e
Create a Configuration Variable to store the API Key you have. Now in the Code card where you make requests to the API, use the variable like this:
Copy code
js
const headers = {
 "Authorization": `Bearer ${env.SERVICE_API_KEY}`
}

https://cdn.discordapp.com/attachments/1134560786832957451/1134609081483661332/image.png

w
but, that SERVICE_API_KEY what is?, what is the procedence?
e
Hey @white-oxygen-62531, sorry for the late reply! That's just a name I used, you should name it accordingly to the service you are using
like BOTPRESS_API_KEY
so create a variable with a name like this, and paste the API key you have
then you can access the variable at any time with
env.BOTPRESS_API_KEY
w
Ok, I got it. Thanks. 🙂
e
Anytime, happy building! 🚀
7 Views