curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"url": "https://www.ayrshare.com", "utmSource": "google_ads"}' \
-X POST https://api.ayrshare.com/api/links
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/links", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
url: "https://www.ayrshare.com", // required
utmSource: "google_ads", // optional
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'url': 'https://www.ayrshare.com',
'utmSource': 'google_ads"}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.post('https://api.ayrshare.com/api/links',
json=payload,
headers=headers)
print(r.json())
require 'vendor/autoload.php';// Composer auto-loader using Guzzle. See .../guzzlephp.org/en/stable/overview.html
$client = new GuzzleHttp\Client();
$res = $client->request(
'POST',
'https://api.ayrshare.com/api/links',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'json' => [
'url' => 'https://www.ayrshare.com',
'utmSource' => 'google_ads', // optional
]
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
package main
import (
"bytes"
"encoding/json"
"log"
"net/http"
)
func main() {
message := map[string]interface{}{
"url": "https://www.ayrshare.com",
"utmSource": "google_ads",
}
bytesRepresentation, err := json.Marshal(message)
if err != nil {
log.Fatalln(err)
}
req, _ := http.NewRequest("POST", "https://api.ayrshare.com/api/links",
bytes.NewBuffer(bytesRepresentation))
req.Header.Add("Content-Type", "application/json; charset=UTF-8")
req.Header.Add("Authorization", "Bearer API_KEY")
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal("Error:", err)
}
res.Body.Close()
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace CreateShortLinkPOSTRequest_csharp
{
class CreateShortLink
{
private static readonly HttpClient client = new HttpClient();
static async Task Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://api.ayrshare.com/api/analytics/links";
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
string json = "{\"url\" : \"https://www.ayrshare.com\"," +
"\"utmSource\" :\"google_ads\"";
try
{
var content = new StringContent(json, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(url, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (HttpRequestException e)
{
Console.WriteLine($"Error: {e.Message}");
}
}
}
}
{
"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"
}
{
"action": "request",
"status": "error",
"code": 126,
"message": "Shorten URL failed. Please verify the URL is properly formatted and the correct UTM parameters are used."
}
Links
शॉर्ट लिंक बनाएँ
एक URL प्रदान करें और एक शॉर्टन किया गया लिंक लौटाया जाएगा।
POST
/
links
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"url": "https://www.ayrshare.com", "utmSource": "google_ads"}' \
-X POST https://api.ayrshare.com/api/links
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/links", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
url: "https://www.ayrshare.com", // required
utmSource: "google_ads", // optional
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'url': 'https://www.ayrshare.com',
'utmSource': 'google_ads"}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.post('https://api.ayrshare.com/api/links',
json=payload,
headers=headers)
print(r.json())
require 'vendor/autoload.php';// Composer auto-loader using Guzzle. See .../guzzlephp.org/en/stable/overview.html
$client = new GuzzleHttp\Client();
$res = $client->request(
'POST',
'https://api.ayrshare.com/api/links',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'json' => [
'url' => 'https://www.ayrshare.com',
'utmSource' => 'google_ads', // optional
]
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
package main
import (
"bytes"
"encoding/json"
"log"
"net/http"
)
func main() {
message := map[string]interface{}{
"url": "https://www.ayrshare.com",
"utmSource": "google_ads",
}
bytesRepresentation, err := json.Marshal(message)
if err != nil {
log.Fatalln(err)
}
req, _ := http.NewRequest("POST", "https://api.ayrshare.com/api/links",
bytes.NewBuffer(bytesRepresentation))
req.Header.Add("Content-Type", "application/json; charset=UTF-8")
req.Header.Add("Authorization", "Bearer API_KEY")
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal("Error:", err)
}
res.Body.Close()
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace CreateShortLinkPOSTRequest_csharp
{
class CreateShortLink
{
private static readonly HttpClient client = new HttpClient();
static async Task Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://api.ayrshare.com/api/analytics/links";
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
string json = "{\"url\" : \"https://www.ayrshare.com\"," +
"\"utmSource\" :\"google_ads\"";
try
{
var content = new StringContent(json, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(url, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (HttpRequestException e)
{
Console.WriteLine($"Error: {e.Message}");
}
}
}
}
{
"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"
}
{
"action": "request",
"status": "error",
"code": 126,
"message": "Shorten URL failed. Please verify the URL is properly formatted and the correct UTM parameters are used."
}
एक URL प्रदान करें और एक शॉर्टन किया गया लिंक लौटाया जाएगा। फिर क्लिक, ब्राउज़र प्रकार आदि पर एनालिटिक्स एकत्रित किए जा सकते हैं।
शॉर्टनिंग के लिए समान URL सबमिट करने पर हमेशा वही शॉर्टन किया गया लिंक मिलेगा। समान URL के लिए एक अद्वितीय शॉर्टन किया गया लिंक उत्पन्न करने के लिए, आप इसमें अतिरिक्त क्वेरी पैरामीटर जोड़ सकते हैं। उदाहरण के लिए, https://ayrshare.com?uniqueId=123 जैसे अद्वितीय पहचानकर्ता को जोड़ने पर एक अलग शॉर्टन किया गया लिंक बनेगा।
आप UTM पैरामीटर भी शामिल कर सकते हैं, जिन्हें शॉर्टन किए गए URL लिंक में एम्बेड किया जाएगा।
हेडर पैरामीटर
बॉडी पैरामीटर
शॉर्टन करने के लिए URL। https:// से शुरू होने वाला एक वैध URL होना चाहिए
यह पहचानने के लिए उपयोग किया जाता है कि यह रेफ़रल किस Google Analytics विज्ञापन अभियान का संदर्भ देता है।
खोज इंजन, न्यूज़लेटर नाम या अन्य स्रोत की पहचान करने के लिए उपयोग किया जाता है।
ईमेल या cost-per-click जैसे माध्यम की पहचान करने के लिए उपयोग किया जाता है।
कीवर्ड विश्लेषण के लिए उपयोग किया जाता है। किसी विशिष्ट उत्पाद प्रचार या रणनीतिक अभियान की पहचान करने के लिए उपयोग किया जाता है।
पेड सर्च के लिए उपयोग किया जाता है। इस विज्ञापन के लिए कीवर्ड्स नोट करने के लिए उपयोग किया जाता है।
A/B परीक्षण और सामग्री-लक्षित विज्ञापनों के लिए उपयोग किया जाता है। समान URL पर इंगित करने वाले विज्ञापनों या लिंक को अलग करने के लिए उपयोग किया जाता है।
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"url": "https://www.ayrshare.com", "utmSource": "google_ads"}' \
-X POST https://api.ayrshare.com/api/links
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/links", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
url: "https://www.ayrshare.com", // required
utmSource: "google_ads", // optional
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'url': 'https://www.ayrshare.com',
'utmSource': 'google_ads"}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.post('https://api.ayrshare.com/api/links',
json=payload,
headers=headers)
print(r.json())
require 'vendor/autoload.php';// Composer auto-loader using Guzzle. See .../guzzlephp.org/en/stable/overview.html
$client = new GuzzleHttp\Client();
$res = $client->request(
'POST',
'https://api.ayrshare.com/api/links',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'json' => [
'url' => 'https://www.ayrshare.com',
'utmSource' => 'google_ads', // optional
]
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
package main
import (
"bytes"
"encoding/json"
"log"
"net/http"
)
func main() {
message := map[string]interface{}{
"url": "https://www.ayrshare.com",
"utmSource": "google_ads",
}
bytesRepresentation, err := json.Marshal(message)
if err != nil {
log.Fatalln(err)
}
req, _ := http.NewRequest("POST", "https://api.ayrshare.com/api/links",
bytes.NewBuffer(bytesRepresentation))
req.Header.Add("Content-Type", "application/json; charset=UTF-8")
req.Header.Add("Authorization", "Bearer API_KEY")
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal("Error:", err)
}
res.Body.Close()
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace CreateShortLinkPOSTRequest_csharp
{
class CreateShortLink
{
private static readonly HttpClient client = new HttpClient();
static async Task Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://api.ayrshare.com/api/analytics/links";
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
string json = "{\"url\" : \"https://www.ayrshare.com\"," +
"\"utmSource\" :\"google_ads\"";
try
{
var content = new StringContent(json, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(url, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (HttpRequestException e)
{
Console.WriteLine($"Error: {e.Message}");
}
}
}
}
{
"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"
}
{
"action": "request",
"status": "error",
"code": 126,
"message": "Shorten URL failed. Please verify the URL is properly formatted and the correct UTM parameters are used."
}
⌘I
