OA0
OA0 是一个探索 AI 的社区
现在注册
已注册用户请  登录
OA0  ›  技能包  ›  go2gg:使用Go2.gg进行短链接、统计与二维码生成

go2gg:使用Go2.gg进行短链接、统计与二维码生成

 
  chrome ·  2026-02-02 02:47:38 · 138 次点击  · 0 条评论  

名称: go2gg
描述: 使用 Go2.gg API 进行短链接生成、链接分析、二维码创建、Webhook 设置和 Link-in-Bio 页面管理。适用于用户需要创建短链接、跟踪点击、生成二维码、设置 Link-in-Bio 页面或管理品牌化 URL 的场景。免费套餐包含短链接、二维码和分析功能。需要设置 GO2GG_API_KEY 环境变量。二维码生成无需认证且免费。


Go2.gg — 边缘原生短链接服务

提供短链接、分析、二维码、Webhook 和图库(Link-in-Bio)功能。基于 Cloudflare 边缘网络构建,全球重定向延迟低于 10 毫秒。

设置

从以下地址获取 API 密钥:https://go2.gg/dashboard/api-keys (免费,无需信用卡)

export GO2GG_API_KEY="go2_your_key_here"

API 基础地址: https://api.go2.gg/api/v1
认证方式: Authorization: Bearer $GO2GG_API_KEY
文档: https://go2.gg/docs/api/links


短链接

创建、管理和跟踪短链接,支持自定义别名、标签、过期时间、密码以及地理/设备定向。

创建链接

curl -X POST "https://api.go2.gg/api/v1/links" \
  -H "Authorization: Bearer $GO2GG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "destinationUrl": "https://example.com/landing-page",
    "slug": "my-link",
    "title": "My Campaign Link",
    "tags": ["marketing", "q1-2025"]
  }'

重要提示: 目标 URL 字段名为 destinationUrl(不是 url)。别名(slug)为可选,若省略则自动生成。

响应示例

{
  "success": true,
  "data": {
    "id": "lnk_abc123",
    "shortUrl": "https://go2.gg/my-link",
    "destinationUrl": "https://example.com/landing-page",
    "slug": "my-link",
    "domain": "go2.gg",
    "title": "My Campaign Link",
    "tags": ["marketing", "q1-2025"],
    "clickCount": 0,
    "createdAt": "2025-01-01T10:30:00Z"
  }
}

列出链接

# 列出所有链接(分页)
curl "https://api.go2.gg/api/v1/links?perPage=20&sort=clicks" \
  -H "Authorization: Bearer $GO2GG_API_KEY"

# 搜索链接
curl "https://api.go2.gg/api/v1/links?search=marketing&tag=q1-2025" \
  -H "Authorization: Bearer $GO2GG_API_KEY"

查询参数: page, perPage (最大 100), search, domain, tag, archived, sort (created/clicks/updated)

更新链接

curl -X PATCH "https://api.go2.gg/api/v1/links/lnk_abc123" \
  -H "Authorization: Bearer $GO2GG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"destinationUrl": "https://example.com/updated-page", "tags": ["updated"]}'

删除链接

curl -X DELETE "https://api.go2.gg/api/v1/links/lnk_abc123" \
  -H "Authorization: Bearer $GO2GG_API_KEY"
# 返回 204 No Content

链接分析

curl "https://api.go2.gg/api/v1/links/lnk_abc123/stats" \
  -H "Authorization: Bearer $GO2GG_API_KEY"

返回数据:totalClicks, byCountry, byDevice, byBrowser, byReferrer, overTime

高级链接选项

# 密码保护链接
curl -X POST "https://api.go2.gg/api/v1/links" \
  -H "Authorization: Bearer $GO2GG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"destinationUrl": "https://example.com/secret", "slug": "exclusive", "password": "secure123"}'

# 带过期时间和点击限制的链接
curl -X POST "https://api.go2.gg/api/v1/links" \
  -H "Authorization: Bearer $GO2GG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"destinationUrl": "https://example.com/flash", "expiresAt": "2025-12-31T23:59:59Z", "clickLimit": 1000}'

# 地理定向链接(不同国家跳转至不同 URL)
curl -X POST "https://api.go2.gg/api/v1/links" \
  -H "Authorization: Bearer $GO2GG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "destinationUrl": "https://example.com/default",
    "geoTargets": {"US": "https://example.com/us", "GB": "https://example.com/uk", "IN": "https://example.com/in"}
  }'

# 设备定向链接 + 应用深度链接
curl -X POST "https://api.go2.gg/api/v1/links" \
  -H "Authorization: Bearer $GO2GG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "destinationUrl": "https://example.com/default",
    "deviceTargets": {"mobile": "https://m.example.com"},
    "iosUrl": "https://apps.apple.com/app/myapp",
    "androidUrl": "https://play.google.com/store/apps/details?id=com.myapp"
  }'

# 带 UTM 参数的链接
curl -X POST "https://api.go2.gg/api/v1/links" \
  -H "Authorization: Bearer $GO2GG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "destinationUrl": "https://example.com/product",
    "slug": "summer-sale",
    "utmSource": "email",
    "utmMedium": "newsletter",
    "utmCampaign": "summer-sale"
  }'

创建链接参数说明

字段 类型 是否必需 描述
destinationUrl 字符串 是 重定向的目标 URL
slug 字符串 否 自定义别名(省略则自动生成)
domain 字符串 否 自定义域名(默认:go2.gg)
title 字符串 否 链接标题
description 字符串 否 链接描述
tags 字符串数组 否 用于筛选的标签
password 字符串 否 密码保护
expiresAt 字符串 否 ISO 8601 格式的过期日期
clickLimit 数字 否 允许的最大点击次数
geoTargets 对象 否 国家代码到 URL 的映射
deviceTargets 对象 否 设备类型到 URL 的映射
iosUrl 字符串 否 iOS 应用深度链接
androidUrl 字符串 否 Android 应用深度链接
utmSource/Medium/Campaign/Term/Content 字符串 否 UTM 参数

二维码

生成可自定义的二维码。二维码生成功能免费且无需认证。

生成二维码(无需认证)

# 生成 SVG 格式二维码(免费,无需 API 密钥)
curl -X POST "https://api.go2.gg/api/v1/qr/generate" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://go2.gg/my-link",
    "size": 512,
    "foregroundColor": "#1a365d",
    "backgroundColor": "#FFFFFF",
    "cornerRadius": 10,
    "errorCorrection": "H",
    "format": "svg"
  }' -o qr-code.svg

# PNG 格式
curl -X POST "https://api.go2.gg/api/v1/qr/generate" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com", "format": "png", "size": 1024}' -o qr-code.png

二维码参数

字段 类型 默认值 描述
url 字符串 必需 要编码的 URL
size 数字 256 像素尺寸(64-2048)
foregroundColor 字符串 #000000 模块的十六进制颜色
backgroundColor 字符串 #FFFFFF 背景的十六进制颜色
cornerRadius 数字 0 模块圆角半径(0-50)
errorCorrection 字符串 M L (7%), M (15%), Q (25%), H (30%)
format 字符串 svg svg 或 png

保存与跟踪二维码(需要认证)

# 保存二维码配置以便跟踪
curl -X POST "https://api.go2.gg/api/v1/qr" \
  -H "Authorization: Bearer $GO2GG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Business Card QR", "url": "https://go2.gg/contact", "linkId": "lnk_abc123"}'

# 列出已保存的二维码
curl "https://api.go2.gg/api/v1/qr" -H "Authorization: Bearer $GO2GG_API_KEY"

# 下载已保存的二维码
curl "https://api.go2.gg/api/v1/qr/qr_abc123/download?format=svg" \
  -H "Authorization: Bearer $GO2GG_API_KEY" -o qr.svg

# 删除二维码
curl -X DELETE "https://api.go2.gg/api/v1/qr/qr_abc123" -H "Authorization: Bearer $GO2GG_API_KEY"

Webhooks

接收链接点击、创建和更新的实时通知。

# 创建 Webhook
curl -X POST "https://api.go2.gg/api/v1/webhooks" \
  -H "Authorization: Bearer $GO2GG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Click Tracker", "url": "https://your-server.com/webhook", "events": ["click", "link.created"]}'

# 列出 Webhook
curl "https://api.go2.gg/api/v1/webhooks" -H "Authorization: Bearer $GO2GG_API_KEY"

# 测试 Webhook
curl -X POST "https://api.go2.gg/api/v1/webhooks/wh_abc123/test" \
  -H "Authorization: Bearer $GO2GG_API_KEY"

# 删除 Webhook
curl -X DELETE "https://api.go2.gg/api/v1/webhooks/wh_abc123" \
  -H "Authorization: Bearer $GO2GG_API_KEY"

事件类型: click, link.created, link.updated, link.deleted, domain.verified, qr.scanned, * (全部)

Webhook 负载包含用于验证的 X-Webhook-Signature (HMAC SHA256)。重试策略:5秒 → 30秒 → 2分钟 → 10分钟。


图库 (Link-in-Bio)

以编程方式创建 Link-in-Bio 页面。

# 创建图库
curl -X POST "https://api.go2.gg/api/v1/galleries" \
  -H "Authorization: Bearer $GO2GG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"slug": "myprofile", "title": "My Name", "bio": "Creator & developer", "theme": "gradient"}'

# 添加链接项
curl -X POST "https://api.go2.gg/api/v1/galleries/gal_abc123/items" \
  -H "Authorization: Bearer $GO2GG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"type": "link", "title": "My Website", "url": "https://example.com"}'

# 添加 YouTube 嵌入
curl -X POST "https://api.go2.gg/api/v1/galleries/gal_abc123/items" \
  -H "Authorization: Bearer $GO2GG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"type": "embed", "title": "Latest Video", "embedType": "youtube", "embedData": {"videoId": "dQw4w9WgXcQ"}}'

# 发布图库(使其在 go2.gg/bio/myprofile 生效)
curl -X POST "https://api.go2.gg/api/v1/galleries/gal_abc123/publish" \
  -H "Authorization: Bearer $GO2GG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"isPublished": true}'

# 重新排序项目
curl -X PATCH "https://api.go2.gg/api/v1/galleries/gal_abc123/items/reorder" \
  -H "Authorization: Bearer $GO2GG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"itemIds": ["item_3", "item_1", "item_2"]}'

# 列出图库
curl "https://api.go2.gg/api/v1/galleries" -H "Authorization: Bearer $GO2GG_API_KEY"

主题: default, minimal, gradient, dark, neon, custom (需配合 customCss)
项目类型: link, header, divider, embed (youtube), image


Python 示例

import requests

API_KEY = "go2_your_key_here"  # 或 os.environ["GO2GG_API_KEY"]
BASE = "https://api.go2.gg/api/v1"
headers = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}

# 创建短链接
resp = requests.post(f"{BASE}/links", headers=headers, json={
    "destinationUrl": "https://example.com/product",
    "slug": "my-product",
    "title": "Product Link",
    "tags": ["product"]
})
link = resp.json()["data"]
print(f"短链接: {link['shortUrl']}")

# 获取分析数据
stats = requests.get(f"{BASE}/links/{link['id']}/stats", headers=headers).json()["data"]
print(f"点击量: {stats['totalClicks']}")

# 生成二维码(无需认证)
qr = requests.post(f"{BASE}/qr/generate", json={"url": link["shortUrl"], "size": 512, "format": "png"})
with open("qr.png", "wb") as f:
    f.write(qr.content)

API 端点概览

服务 端点 方法 认证
链接 创建 /api/v1/links POST 是
链接列表 /api/v1/links GET 是
链接获取 /api/v1/links/:id GET 是
链接更新 /api/v1/links/:id PATCH 是
链接删除 /api/v1/links/:id DELETE 是
链接统计 /api/v1/links/:id/stats GET 是
二维码 生成 /api/v1/qr/generate POST 否
二维码保存 /api/v1/qr POST 是
二维码列表 /api/v1/qr GET 是
二维码下载 /api/v1/qr/:id/download GET 是
Webhooks /api/v1/webhooks CRUD 是
Webhook 测试 /api/v1/webhooks/:id/test POST 是
图库 /api/v1/galleries CRUD 是
图库项目 /api/v1/galleries/:id/items CRUD 是
图库发布 /api/v1/galleries/:id/publish POST 是

速率限制

套餐 请求数/分钟
免费版 60
专业版 300
商业版 1000

错误代码

代码 描述
SLUG_RESERVED 别名已被保留
SLUG_EXISTS 该域名下别名已存在
INVALID_URL 目标 URL 无效
LIMIT_REACHED 达到套餐链接数量上限
DOMAIN_NOT_VERIFIED 自定义域名未验证
138 次点击  ∙  0 人收藏  
登录后收藏  
0 条回复
关于 ·  帮助 ·  PING ·  隐私 ·  条款   
OA0 - Omni AI 0 一个探索 AI 的社区
沪ICP备2024103595号-2
耗时 21 ms
Developed with Cursor