i am using firebase for my project ,the documentation gives me the endpoint for signing in users as:
:signInWithPassword?key=[API_KEY]
i want to know what does the colon :
mean, for example the word key after the question mark shows its a parameter likewise what does the notion accounts:signInWithPassword
mean.The reason:I have an axios instance with config:
axios.create(
{
baseURL:"",
params:{
apiKey:"somekey"
}
})
now since the baseUrl shown above remains same for firebase signing in with email and password or signing up with email and password. I want to dynamically embed accounts:signInWithPassword
and accounts:signUp
for respective requests and i am not sure if specifying accounts:respectiveUsecase
in params object would work.
i am using firebase for my project ,the documentation gives me the endpoint for signing in users as:
https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=[API_KEY]
i want to know what does the colon :
mean, for example the word key after the question mark shows its a parameter likewise what does the notion accounts:signInWithPassword
mean.The reason:I have an axios instance with config:
axios.create(
{
baseURL:"https://identitytoolkit.googleapis.com/v1",
params:{
apiKey:"somekey"
}
})
now since the baseUrl shown above remains same for firebase signing in with email and password or signing up with email and password. I want to dynamically embed accounts:signInWithPassword
and accounts:signUp
for respective requests and i am not sure if specifying accounts:respectiveUsecase
in params object would work.
3 Answers
Reset to default 8A colon doesn't have any special meaning in an URL path. It's just a convention those APIs tend to use in their paths.
There are a handful of metacharacters that do:
- question marks (?) and hashes (#) delimit the query or search parts
%
is used for escaping characters (e.g.%0A
)+
is sometimes an encoding for a space instead of%20
.&
generally separates query parameters (e.g.foo=bar&baz
), though this is not a part of the standard. Some server software could expect e.g. semicolon-separated parameters.
As @deceze pointed out, colons do have a special meaning in the host part, e.g. https://user:pass@host/path:where:colons:do:not:matter
.
As others have said - a colon doesn't mean anything special in the URL.
However - I've just read "API Design Patterns" by JJ Geewax (ex-Google engineer who has worked on Firebase) - in it he describes colons being used to signify custom methods (so anything that doesn't fit in the standard POST/GET/PUT/DELETE methods that are seen in for many REST APIs), exactly as you have described with your signInWithPassword
method. So it seems to be the Google way of doing things.
It is a dynamic value (like a parameter where you in pass in a value directly)
:nounId: The colon (:) before the word indicates that we don't mean the literal string "nounId" as part of the endpoint, but rather that we are expecting some dynamic data to be inside there. From the above example of /ski/:skiId, one actual endpoint might be something like /ski/1234 (where 1234 is the unique ID number of one of the skis in our database.
source: https://coursework.vschool.io/rest-api-design/#:~:text=%3AnounId%20%3A%20The%20colon%20(%3A)%20before,data%20to%20be%20inside%20there.
accounts-signInWithPassword
oraccounts_signInWithPassword
and it'd work the same. – VLAZ Commented Apr 27, 2020 at 7:29