What is an API key?

162,980

Solution 1

What "exactly" an API key is used for depends very much on who issues it, and what services it's being used for. By and large, however, an API key is the name given to some form of secret token which is submitted alongside web service (or similar) requests in order to identify the origin of the request. The key may be included in some digest of the request content to further verify the origin and to prevent tampering with the values.

Typically, if you can identify the source of a request positively, it acts as a form of authentication, which can lead to access control. For example, you can restrict access to certain API actions based on who's performing the request. For companies which make money from selling such services, it's also a way of tracking who's using the thing for billing purposes. Further still, by blocking a key, you can partially prevent abuse in the case of too-high request volumes.

In general, if you have both a public and a private API key, then it suggests that the keys are themselves a traditional public/private key pair used in some form of asymmetric cryptography, or related, digital signing. These are more secure techniques for positively identifying the source of a request, and additionally, for protecting the request's content from snooping (in addition to tampering).

Solution 2

Very generally speaking:

An API key simply identifies you.

If there is a public/private distinction, then the public key is one that you can distribute to others, to allow them to get some subset of information about you from the api. The private key is for your use only, and provides access to all of your data.

Solution 3

It looks like that many people use API keys as a security solution. The bottom line is: Never treat API keys as secret it is not. On https or not, whoever can read the request can see the API key and can make whatever call they want. An API Key should be just as a 'user' identifier as its not a complete security solution even when used with ssl.

The better description is in Eugene Osovetsky link to: When working with most APIs, why do they require two types of authentication, namely a key and a secret? Or check http://nordicapis.com/why-api-keys-are-not-enough/

Solution 4

An API key is a unique value that is assigned to a user of this service when he's accepted as a user of the service.

The service maintains all the issued keys and checks them at each request.

By looking at the supplied key at the request, a service checks whether it is a valid key to decide on whether to grant access to a user or not.

Solution 5

API keys are just one way of authenticating users of web services.

Share:
162,980

Related videos on Youtube

OrangeRind
Author by

OrangeRind

What about me? Nothing really. Regular guy. Bit of brain. Lots of interests.

Updated on July 08, 2022

Comments

  • OrangeRind
    OrangeRind over 1 year

    I see this word in almost every cross service application these days.

    What exactly is an API key and what are its uses?

    Also, what is the difference between public and private API keys.

  • OrangeRind
    OrangeRind about 14 years
    so what about the public and private one?
  • OrangeRind
    OrangeRind about 14 years
    most of the time they look like hashes. is my observation correct?
  • Admin
    Admin about 14 years
    Public and private keys come from the domain of encryption and have something to do with asymmetric encryption. I've never heard these terms used in the sense of API keys.
  • Matthew Scharley
    Matthew Scharley about 14 years
    The can be generated however you want, as long as they are unique. A hash of some data seems like a reasonable way to generate one, yes.
  • timdev
    timdev about 14 years
    Yes, they look like hashes. After all, you don't want them to be easy to guess.
  • Rob
    Rob about 14 years
    More or less - most bog standard API keys are generated by hashing some pseudorandom value and performing some standard plain-text encoding on the result, e.g. base16, base64 etc.
  • timdev
    timdev about 14 years
    Well put! However, in my somewhat limited experience, the public/private distinction has nothing to do with public key crypto. The "public" keys I've seen are typically "access lite" -- in other words, a key you can distribute to grant third parties access to non-sensitive data, without giving away the keys to the kingdom.
  • OrangeRind
    OrangeRind about 14 years
    @Rob +1 for the detailed answer @tim +1 for the aferthought!
  • Rob
    Rob about 14 years
    @tim - agreed. I think the more common approach I've seen is to have a private digest key.
  • Dev-iL
    Dev-iL over 6 years
    As you can see, this is an old question, and may likely be considered "too broad" (or perhaps "off-topic") according to modern Stack Overflow standards. Such questions tend to attract opinionated answers, which are usually downvoted and/or deleted. Staying away from such questions is usually the best course of action. You can take a look at the help center for more information.