🌐
Contentful
contentful.com › guides › api › api-key
What is an API key? | Contentful
APIs serve to let different software modules communicate with each other — a process which typically entails a transfer of data or functionality. The Google Maps platform, for example, uses API keys to enable requests for map data from other ...
🌐
Swagger
swagger.io › docs › specification › v3_0 › authentication › api-keys
API Keys | Swagger Docs
In OpenAPI 3.0, API keys are described as follows: ... This example defines an API key named X-API-Key sent as a request header X-API-Key: <key>. The key name ApiKeyAuth is an arbitrary name for the security scheme (not to be confused with the API key name, which is specified by the name key).
🌐
Apidog
apidog.com › blog › what-is-an-api-key
What Is an API key? A Comprehensive Guide
July 29, 2025 - Limited Scope API Keys: These API ... Example: The Twitter API offers a limited scope API key that restricts access to specific areas of the Twitter API, such as read-only access to user timelines or direct messaging...
🌐
Esri Developer
developers.arcgis.com › documentation › security-and-authentication › api-key-authentication
Introduction to API key authentication | Documentation | Esri Developer
Paste the API key access token into your application. Your application uses the API key as an access token to access secure resources.
🌐
Google Cloud
cloud.google.com › application development › cloud endpoints › openapi › why and when to use api keys
Why and when to use API keys | Cloud Endpoints with OpenAPI | Google Cloud Documentation
Once the key is stolen, it has no expiration, so it may be used indefinitely, unless the project owner revokes or regenerates the key. While the restrictions you can set on an API key mitigate this, there are better approaches for authorization. For examples, see Authenticating users.
🌐
Oracle
docs.oracle.com › en-us › iaas › Content › API › Concepts › apisigningkey.htm
Required Keys and OCIDs
6 days ago - If you haven't already, create a .oci directory to store the credentials. For example: ... Note We recommend that you use a passphrase for your key. openssl genrsa -out %HOMEDRIVE%%HOMEPATH%\.oci\oci_api_key.pem -aes128 -passout stdin 2048
🌐
Stoplight
blog.stoplight.io › home › api keys: api authentication methods & examples
API Keys: API Authentication Methods & Examples | Stoplight
November 10, 2023 - A popular method for early APIs, passing an API key through a query string in a URL is certainly easy. However, this method can risk API key exposure since, despite encryption, the parameters can be stored in web server logs. curl -X GET "https://example.com/endpoint/?api_key=abcdef12345"
🌐
PubNub
pubnub.com › pubnub blog › what is an api key and how to use it?
What is an API Key and how to use it?
April 24, 2024 - For example, the Google Maps API key contains information that allows developers to access the functionality of the API to integrate it with their application without the end user needing to access Google Maps separately.
Find elsewhere
🌐
Twilio
twilio.com › docs › sendgrid › ui › account-and-settings › api-keys
API Keys | SendGrid Docs | Twilio
Another benefit of this approach is the ability to set API keys with different permissions in different environments such as development, staging, and production without changing the code you deploy to those environments. The examples below show how to store your key in a variable named SENDGRID_API_KEY.
🌐
Stripe
docs.stripe.com › keys
API keys | Stripe Documentation
3 weeks ago - The following table shows randomly generated examples of secret and publishable keys: Anyone can use your live mode secret key to make an API call on behalf of your account, such as creating a charge or performing a refund.
🌐
Google
docs.cloud.google.com › application development › api keys api documentation › api keys overview
API Keys Overview | API Keys API Documentation | Google Cloud Documentation
API keys that are embedded in code can be accidentally exposed to the public. For example, you may forget to remove the keys from code that you share.
🌐
Kong Inc.
konghq.com › home › blog › learning center › what are api keys? overview and use cases
What are API Keys? Examples and Use Cases | Kong Inc.
May 22, 2023 - These keys allow builders and businesses to maintain control and monitor access over services and ensure security. In this post, well further explain what API keys are, what they're used for, the types of API keys, and how to generate an API key.
🌐
Fortinet
fortinet.com › resources › cyberglossary › api-key
What Is an API Key? | API Key Definition | Fortinet
They are commonly used on Internet-of-Things (IoT) applications and websites to gather and process data or enable users to input information. For example, users can get a Google API key or YouTube API keys, which are accessible through an API ...
🌐
HERE Technologies
here.com › docs › bundle › identity-and-access-management-developer-guide › page › topics › plat-using-apikeys.html
API keys
October 2, 2025 - Skip to main contentSkip to search · Powered by Zoomin Software. For more details please contactZoomin · ©2025 HERE · Contact usConsent PreferencesGDPRTermsSecurityPrivacyPrivacy CharterModern Slavery StatementDo Not Sell My Personal Information · Other Sites · here.comHERE platformDeveloper ...
🌐
Okta Developer
developer.okta.com › blog › 2021 › 02 › 03 › api-key-best-practices-and-examples
API Key Best Practices and Examples | Okta Developer
February 3, 2021 - If that code contains an API key, then anyone who reads the question can see and use the key! One solution is to put the key into a property file. An obvious, but very poor choice would be to put it into the Info.plist file. This is a poor choice because Info.plist will almost certainly get checked into a repository, which may be public. A better option is to create a separate property file, in our example Weather/Open-WeatheMap-Info.plist:
🌐
Google AI
ai.google.dev › gemini api › using gemini api keys
Using Gemini API keys | Google AI for Developers
November 5, 2025 - For initial testing, you can hard code an API key, but this should only be temporary since it's not secure. You can find examples for hard coding the API key in Providing API key explicitly section.
🌐
Mailchimp
mailchimp.com › help › about-api-keys
About API Keys | Mailchimp
API keys allow other apps access to your account without a password. Learn how to locate and generate API keys for your Mailchimp Marketing account.
🌐
Firebase
firebase.google.com › documentation › learn about using and managing api keys for firebase
Learn about using and managing API keys for Firebase | Firebase Documentation
October 20, 2025 - In the API restrictions section, select Restrict key, then add to the list all of the APIs to which you want the API key to have access. Make sure to not include the API for which you're creating a separate API key (in this example, Super Service API).
🌐
Apipheny
apipheny.io › what-is-an-api-key
What’s an API Key? API Key & Value Meaning [Explained] – Apipheny
When dealing with APIs, you may encounter something called an API key. They’re sort of like passwords which let APIs confirm your identity. Once an API knows you’re legitimate, you can get through and use the API’s full set of features. Example of an API key: 1f9ba190-c513-471b-a573-...
🌐
Reddit
reddit.com › r/learnprogramming › how are api keys used in sites for authentication, and what prevents someone unauthorized from just copying them from the url or body to make their own requests?
r/learnprogramming on Reddit: How are API keys used in sites for authentication, and what prevents someone unauthorized from just copying them from the URL or body to make their own requests?
November 28, 2024 -

[EDIT] I'm concerned about generating my own API keys for authenticating users in my own project, not using an API if another service.

Hello there! Recently I've started reading on REST API and how to implement one, and currently I'm looking at the use of API keys for authentication. I'm confused on how the URL path should be constructed for different users, and whether the API key should be placed in the URL or within the HTTP header.

From my understanding, API keys are like your email/password when logging into a website, but they are usually encrypted in the database and used for verifying if a certain request like GET/POST can be called. From the guides I've read online, these API keys are stored as parameters in the URL, for example: http:/localhost:3000/users/?api_key=some_long_api_key. But with this approach, what's stopping someone from copying the API key who isn't authorized and using it in making requests?

The other option was to embed the API key in the body of the request, but I'm still wondering if this still suffers from the issue of someone who isn't authorized from making their own request body using it.

The other approach I'm thinking about is where before the request is made, the client retrieves the API key for the currently logged in user and then sends a request using that API key, ensuring that it is hidden from the url, but then again what's to stop someone from viewing the body of the request and getting the API key, unless encryption is required while sending it.

The above approach is what I'm planning to do, although I don't know if it the correct way to do it. For instance, my though process about doing this is as follows:

  1. A new user registers with an email and password,

  2. An API key is generated for the user,

  3. When a request is sent, like posting some form data, the API key is retrieved for the current user and encrypted, then placed in the body of the request,

  4. On the server, it first validates the API key and then continues with the request.

Also, for generating an API key, is generating a UUID good enough? Along with that, is it okay to send the user's email in the body of the request to identify which user is making the request? Is it possible that two user's can have the same API key, which would require sending their details to the server to know which valid user is making the request? I've never worked with API's before so I am curious to how this is solved from a security standpoint...

Thanks in advance and have an amazing day!

Top answer
1 of 5
12
you buy an api key from the service and you use it, that's it, you are not supposed to give it to someone else that is how it works. if you give it to me because you share it in this post (in text, screenshot, or you push it in your public git repo) i will use it and you will pay for it so you will not do that. https encrypts also the url, not only the page content: if you visit this: https://en.wikipedia.org/wiki/Sun an attacker that is intercepting data only see en.wikipedia.org because the requested page and parameters are encrypted
2 of 5
6
To authorize your own service in a browser, it is better to use sessions and cookies. The browser has extra security mechanisms for cookies. -Ideally API keys are sent in headers, not query strings. URLs show up in logs, browser history, etc and can leak the credential. The request should be sent over a HTTPS connection, which ensures only the client and the server can see the credentials. api keys should be hashed before saving them to the database, not encrypted. They should be sufficiently random that a sha function like sha512 is safe to use. UUIDs, even random ones, are not intended to be used for credentials. It’s better to generate ~32 random bytes, then encode them with an encoding like base64. Usually you don’t send a user id with the request. The API key is enough to look them up. The keys are random enough that the risk of collision is negligible, and you can add a unique constraint to the database to be sure. There are security benefits to having a public identifier as part of the key though (see split tokens ).