How to best use an API

About programming and getting involved with Linux Mint development
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
MaxBaktBrood
Level 1
Level 1
Posts: 27
Joined: Mon Mar 23, 2020 10:10 am
Location: Gelderland
Contact:

How to best use an API

Post by MaxBaktBrood »

Hello everyone,

The past months I've been using an API service for a website project. It's working well, but there's this single frustrating barrier that's holding me back. See, to use the API, I need to log in to it. This is accomplished by sending an API-key inside of a request header. I'm able to do that, but now my private API key is visible to everyone who can access the developer tools...
So I want to hide my API-key. I'm thinking of creating an API on my own that only passes though the data given by the API service I need. Is this the best method? And if so, how do I host this API?

If this barrier is lifted, my project is ready to be published. It would mean a lot to me!

Thanks in advance,

Max
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
jmorris84
Level 3
Level 3
Posts: 185
Joined: Mon Mar 19, 2012 6:40 pm

Re: How to best use an API

Post by jmorris84 »

Put the key in another file as a variable and have your code call that variable or however you have the key sitting in the file. This way the key isn't visible to those reading your code and they only see the name of a variable or call to a file for the key and not the key itself.

Lots of resources online for how to do this.
Locked

Return to “Programming & Development”