Create Dynamic Links with the REST API
You can create short Dynamic Links with the Firebase Dynamic Links REST API. This API accepts either a long Dynamic Link or an object containing Dynamic Link parameters, and returns a URL like the following example:
Short Dynamic Links created with the API and client (Android/iOS) SDK do not show up in the Firebase console. Such Dynamic Links are intended for user-to-user sharing. For marketing use cases, continue to create your links directly through the Dynamic Links page of the Firebase console.
Before you begin
- Get your API key. You will need an API key to authenticate your requests to the API. To find your API key:
- Open the Settings page of the Firebase console. If you are prompted to choose a project, select your Firebase project from the menu.
- Take note of the value of the Web API Key field.
- In the Firebase console, open the Dynamic Links section.
- If you have not already accepted the terms of service and set a domain for your Dynamic Links, do so when prompted.If you already have a Dynamic Links domain, take note of it. You need to provide a Dynamic Links domain when you programmatically create Dynamic Links.
Creating a short Dynamic Link
Create a short link from a long link
You can use the Firebase Dynamic Links API to shorten a long Dynamic Link. To do so, make an HTTP POST request to the
shortLinks
endpoint, specifying the long Dynamic Link in the longDynamicLink
parameter. For example:Create a short link from parameters
You can also create a short Dynamic Link by specifying the Dynamic Link parameters directly. To do so, make an HTTP POST request to the
shortLinks
endpoint, specifying the Dynamic Link parameters in the dynamicLinkInfo
parameter. For example:Set the length of a short Dynamic Link
You can also set the
suffix
parameter to specify how the path component of the short Dynamic Link is generated.
By default, or if you set the parameter to
"UNGUESSABLE"
, the path component will be a 17-character string, such as in the following example:
Such strings are created by base62-encoding randomly generated 96-bit numbers. Use this setting to prevent your Dynamic Links URLs from being guessed and crawled, which can potentially expose sensitive information to unintended recipients.
If you set the parameter to
"SHORT"
, the path component will be a string that is only as long as needed to be unique, with a minimum length of 4 characters.
Use this method if sensitive information would not be exposed if a short Dynamic Link URL were guessed.
The following example shows how you can set the
suffix
parameter:Ensure deep link is valid
At minimum, the deep-link value provided must begin with http:// or https:// schemes. It must also match any URL patterns whitelist entered in the console. Else, the creation API will fail with HTTP error code 400.
Next steps
Now that you've created Dynamic Links, you need to set up your app to receive Dynamic Links and send users to the right place in your app after a user opens them.
Requests are limited to 5 requests/IP address/second, and 200,000 requests/day. If exceeded, then the response will return HTTP error code 429. To request for more quota, fill out this form.
Comments
Post a Comment