- Have a rotating example key in your docs that rotates once a week.
- Have the example API key return redacted data, example data, or old data instead of real data instead of failing out as an invalid key.
- Add something to the response that doesn't make it usable in production (e.g. a TTS API response can have some duck noises in the background for the example key)
- Limit the total number of requests per IP address to something that's usable for dev work but not usable in production
It reduces a LOT of friction for the user to be able to just curl something off your website instead of going through the whole registration process to get the first 200.
I've had a fair number of users send me feedback saying this isn't the best practice, I should use tokens in HTTP auth headers or use various other auth schemes.
But from my perspective, for an API that is offering really very simple functionality, using HTTPS & not handling user data etc. then this is quite OK - especially when you consider the benefits of how simple it is to get up and running.
I have quite a few university course conveners include my free API in their entry level CS classes because it's super fast & rewarding for students to go from finding my API to then having a JSON object in their code, no tokens required!
But it seems like in this case it's mostly a rate limiting and identification exercise and not a secure protection of user data so the impact of exposure is substantially lower. So it does seem reasonable here.
Though I hope that OP has documented all over the place "do as I say not as I do" so people don't copy this pattern.
I still think it's reasonable for my use case but perhaps I should add another auth scheme as an optional alternative for the user who is concerned about their key potentially being caught in logs.
Your point about the documentation is also a good one - I should probably add a specific page just about the authentication approach. Added to the to-do list! Thanks.
https://:[API_KEY]@v6.exchangerate-api.com/v6/latest/USD
If you only have an API key and not a token (username) and secret (password) I recommend passing the API key as a password as some logging solutions do log the basic auth username in the data recorded.
such a pain to debug, i'm not sure why they have such signing features. is it for security
Yes.
EDIT: specifically, it is do intercepting a request doesn’t allow you to issue new requests.
For example, S3. S3’s authentication scheme allow you create a limited used download link and passing to a untrusted user
It is because TLS client certificates do not exist.
In the end, I gave up, because I wasn’t willing to invest hours into learning all the idiosyncrasies. Ended up using Influxdata’s SaaS and got what I wanted going in about 15 minutes. To be fair, most of that time was also because their API docs didn’t actually work as posted and didn’t go through properly installing the client lib, which someone more experienced with Go probably would have gotten past more quickly.