shorten.rest
Module shorten.rest
ballerinax/shorten.rest Ballerina library
Overview
This is a generated connector for Shorten.REST API v1.0 OpenAPI specification.
The Shorten.REST API provides the capability to programmatically create short URLs for longer URL.
Prerequisites
Before using this connector in your Ballerina application, complete the following:
- Create a Shorten.REST account.
- Obtain tokens - Follow this guide.
Quickstart
To use the Shorten.REST connector in your Ballerina application, update the .bal file as follows:
Step 1: Import connector
First, import the ballerinax/shorten.rest module into the Ballerina project.
import ballerinax/shorten.rest;
Step 2: Create a new connector instance
You can now make the connection configuration using the Shorten.REST API keys config.
rest:ApiKeysConfig & readonly apiKeyConfig = ?; rest:Client baseClient = check new Client(apiKeyConfig);
Step 3: Invoke connector operation
Following is code demonstrates how to get all aliases using ballerinax/shorten.rest
connector.
public function main() returns error? { rest:GetAliasesModel entity = check baseClient->getAliases(); }
Clients
shorten.rest: Client
This is a generated connector for Shorten.REST v1.0 OpenAPI Specification. The Shorten.REST API allows you to programmatically create short URLs for longer URL. Each alias you create can be used to redirect the end user (person clicking on the link) to one or more destination URLs A default destination is always set and specific destinations can be set to redirect the end user to preferred destinations based on the user's geographical location (country) and device Operating System.
Constructor
Gets invoked to initialize the connector
.
The connector initialization requires setting the API credentials.
Create a Shorten.REST account and obtain tokens by following this guide.
init (ApiKeysConfig apiKeyConfig, ConnectionConfig config, string serviceUrl)
- apiKeyConfig ApiKeysConfig - API keys for authorization
- config ConnectionConfig {} - The configurations to be used when initializing the
connector
- serviceUrl string "https://api.shorten.rest" - URL of the target service
getAlias
function getAlias(string aliasName, string domainName) returns AliasModel|error
Get alias
Parameters
- aliasName string - alias value (without
/
at the beginning)
- domainName string (default "short.fyi") - domain which alias belongs to (string without
http/https
or/
)
Return Type
- AliasModel|error - Alias model or null
updateAlias
function updateAlias(string aliasName, CreateAliasModel payload, string domainName) returns Response|error
Update alias
Parameters
- aliasName string - alias (without
/
at the beginning)
- payload CreateAliasModel - alias properties you wish to be updated
- domainName string (default "short.fyi") - domain which alias belongs to (string without
http/https
or/
)
createAlias
function createAlias(CreateAliasModel payload, string domainName, string aliasName) returns CreateAliasResponseModel|error
Create alias
Parameters
- payload CreateAliasModel - alias properties
- domainName string (default "short.fyi") - domain which alias will belong to (string without
http/https
or/
)
- aliasName string (default "@rnd") - alias (without
/
at the beginning)
Return Type
- CreateAliasResponseModel|error - Response contains aliasName, domainName and full generated short link
deleteAlias
Delete alias
Parameters
- aliasName string - alias (without
/
at the beginning)
- domainName string (default "short.fyi") - domain which alias belongs to (string without
http/https
or/
)
getAliases
function getAliases(string domainName, string? continueFrom, int 'limit) returns GetAliasesModel|error
Get aliases by domain
Parameters
- domainName string (default "short.fyi") - The domain name to get the aliases for (string without
http/https
or/
)
- continueFrom string? (default ()) - An ID returned by a previous query to continue aliases retrieval (see lastId in response)
- 'limit int (default 1000) - Number of results to return per request
Return Type
- GetAliasesModel|error - returns Array of aliases with lastId
getClicks
function getClicks(string? continueFrom, int 'limit) returns GetClicksModel|error
Get clicks
Parameters
- continueFrom string? (default ()) - An ID returned by a previous query to continue clicks retrieval (see lastId in response)
- 'limit int (default 1000) - Number of results to return per request
Return Type
- GetClicksModel|error - returns Array of Click models, also returns lastId
Records
shorten.rest: AliasModel
Fields
- createdAt int? -
- destinations DestinationModel[]? -
- domainName string? -
- metatags MetaTagModel[]? -
- name string -
- snippets SnippetModel[]? -
- updatedAt int? -
shorten.rest: ApiKeysConfig
Provides API key configurations needed when communicating with a remote HTTP endpoint.
Fields
- xApiKey string - Represents API Key
x-api-key
shorten.rest: ClickModel
Fields
- alias string? -
- aliasId string? -
- browser string? -
- country string? -
- createdAt int? -
- destination string? -
- domain string? -
- os string? -
- referrer string? -
- userAgent string? -
shorten.rest: ClientHttp1Settings
Provides settings related to HTTP/1.x protocol.
Fields
- keepAlive KeepAlive(default http:KEEPALIVE_AUTO) - Specifies whether to reuse a connection for multiple requests
- chunking Chunking(default http:CHUNKING_AUTO) - The chunking behaviour of the request
- proxy ProxyConfig? - Proxy server related options
shorten.rest: ConnectionConfig
Provides a set of configurations for controlling the behaviours when communicating with a remote HTTP endpoint.
Fields
- httpVersion HttpVersion(default http:HTTP_2_0) - The HTTP version understood by the client
- http1Settings ClientHttp1Settings? - Configurations related to HTTP/1.x protocol
- http2Settings ClientHttp2Settings? - Configurations related to HTTP/2 protocol
- timeout decimal(default 60) - The maximum time to wait (in seconds) for a response before closing the connection
- forwarded string(default "disable") - The choice of setting
forwarded
/x-forwarded
header
- poolConfig PoolConfiguration? - Configurations associated with request pooling
- cache CacheConfig? - HTTP caching related configurations
- compression Compression(default http:COMPRESSION_AUTO) - Specifies the way of handling compression (
accept-encoding
) header
- circuitBreaker CircuitBreakerConfig? - Configurations associated with the behaviour of the Circuit Breaker
- retryConfig RetryConfig? - Configurations associated with retrying
- responseLimits ResponseLimitConfigs? - Configurations associated with inbound response size limits
- secureSocket ClientSecureSocket? - SSL/TLS-related options
- proxy ProxyConfig? - Proxy server related options
- validation boolean(default true) - Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
shorten.rest: CreateAliasModel
Fields
- destinations DestinationModel[]? -
- metatags MetaTagModel[]? -
- snippets SnippetModel[]? -
shorten.rest: CreateAliasResponseModel
Fields
- aliasName string? -
- domainName string? -
- shortUrl string? -
shorten.rest: DestinationModel
Fields
- country string? - ISO alpha-2 country code
- os string? - Please check the supported OS list
- url string -
shorten.rest: GetAliasesModel
Fields
- aliases string[]? -
- lastId string? -
shorten.rest: GetAliasModel
Fields
- createdAt int? -
- domainName string? -
- name string? -
- updatedAt int? -
shorten.rest: GetClicksModel
Fields
- clicks ClickModel[]? -
- lastId string? -
shorten.rest: MetaTagModel
Fields
- content string -
- name string -
shorten.rest: ProxyConfig
Proxy server configurations to be used with the HTTP client endpoint.
Fields
- host string(default "") - Host name of the proxy server
- port int(default 0) - Proxy server port
- userName string(default "") - Proxy server username
- password string(default "") - Proxy server password
shorten.rest: SnippetModel
Fields
- id string - Please check the supported snippets list
- parameters record {}? -
Import
import ballerinax/shorten.rest;
Metadata
Released date: over 1 year ago
Version: 1.5.1
License: Apache-2.0
Compatibility
Platform: any
Ballerina version: 2201.4.1
GraalVM compatible: Yes
Pull count
Total: 3
Current verison: 2
Weekly downloads
Keywords
Marketing/Url Shortener
Cost/Freemium
Contributors
Dependencies