links

Link shortener and analytics endpoint

With the links endpoint your can shorten links to include in social posts.

The Ayrshare link shortener offers several valuable benefits social publishing.

  • Condense long and complex URLs for more visually appealing, concise, and memorable.

  • Analytics and tracking capabilities, allowing you to monitor link performance, engagement, and audience insights.

  • Save valuable character space, especially on platforms like Twitter where character limits are stringent.

  • Add a custom link domain with your own url.

POST https://app.ayrshare.com/api/links

Provide a URL and a shortened link will be returned. Analytics can then be gathered on the clicks, browser type, etc.

Submitting the same URL for shortening will always result in the same shortened link. To generate a unique shortened link for the same URL, you can add extra query parameters to it. For example, appending a unique identifier like https://ayrshare.com?uniqueId=123 will create a distinct shortened link.

You may also include UTM parameters, which will be embedded in the shortened URL link.

Headers

NameTypeDescription

Authorization*

string

Format: Authorization: Bearer API_KEY. See Overview for more information.

Request Body

NameTypeDescription

url*

string

URL to be shortened. Must be a valid URL starting with https://

utmId

string

Used to identify which Google Analytics ads campaign this referral references. Use utm_id to identify a specific ads campaign.

utmSource

string

Used to identify a search engine, newsletter name, or other source.

utmMedium

string

Used to identify a medium such as email or cost-per-click.

utmCampaign

string

Used for keyword analysis. Used to identify a specific product promotion or strategic campaign.

utmTerm

string

Used for paid search. Used to note the keywords for this ad.

utmContent

string

Used for A/B testing and content-targeted ads. Used to differentiate ads or links that point to the same URL.

{
    "created": "2023-07-17T15:20:51.118Z",
    "id": "yC0fTl",
    "originalUrl": "https://www.ayrshare.com/?utm_source=looking",
    "shortUrl": "https://ayrs.io/yC0fTl",
    "status": "success",
    "utmSource": "looking"
}

Request Examples

curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"url": "https://www.ayrshare.com", "utmSource": "google_ads"}' \
-X POST https://app.ayrshare.com/api/links

GET https://app.ayrshare.com/api/links/:id

Return analytics for all shortened links or a single link for a given link ID. For example:

https://app.ayrshare.com/api/links/yC0fTl returns analytics for ID yC0fTl

https://app.ayrshare.com/api/links returns all link analytics.

Path Parameters

NameTypeDescription

id

string

Provide the shortened link ID returned from the POST /links request as a path parameter. For example: https://app.ayrshare.com/api/links/yC0fTl

If no link ID is provided, all links are returned.

Query Parameters

NameTypeDescription

fromCreatedDate

string

Get history of links shortened after this date. Accepts a UTC date time. For example, use format "YYYY-MM-DDThh:mm:ssZ" and send as "2023-07-08T12:30:00Z".

toCreatedDate

string

Get history of links shortened before this date. Accepts a UTC date time. For example, use format "YYYY-MM-DDThh:mm:ssZ" and send as "2023-07-08T12:30:00Z".

fromClickDate

string

Get history of links clicked after this date. Accepts a UTC date time. For example, use format "YYYY-MM-DDThh:mm:ssZ" and send as "2023-07-08T12:30:00Z".

toClickDate

string

Get history links clicked after this date. Accepts a UTC date time. For example, use format "YYYY-MM-DDThh:mm:ssZ" and send as "2023-07-08T12:30:00Z".

Headers

NameTypeDescription

Authorization*

string

Format: Authorization: Bearer API_KEY. See Overview for more information.

{
    "status": "success",
    "analytics": {
        "browserCounts": {
            "chrome": 15
        },
        "created": "2023-06-29T00:57:12.220Z",
        "id": "yC0fTl",
        "originalUrl": "https://www.ayrshare.com/?utm_source=google_ads",
        "refererCounts": {},
        "shortUrl": "https://ayrs.io/yC0fTl",
        "socialClicks": {},
        "status": "success",
        "totalClicks": 15,
        "utmSource": "google_ads"
    }
}

Request Examples

curl \
-H "Authorization: Bearer API_Key" \
-H 'Content-Type: application/json' \
-X GET https://app.ayrshare.com/api/links/yC0fTl

A custom link domain allows you to personalize and brand the domain name used for link shortening and redirection. Instead of using a generic link shortener domain (e.g., bit.ly, ayr.app), a custom link domain allows you to use own domain name to create shortened links.

Please contact us to set up your custom domain.

Last updated