开发工具中心 API

发布: (2025年12月15日 GMT+8 00:46)
5 min read
原文: Dev.to

Source: Dev.to

我构建的内容

提交给 Xano AI 驱动后端挑战赛:可投产的公共 API

标题: DevTools 资源中心 API
可用: True

DevTools API 列表

  • Xano Hub API
  • Xano Assisted Production API

软件后端架构

Architecture Diagram 1

后端采用分层、模块化设计,适用于 MVP。API 端点提供 REST 接口,受身份验证、速率限制和参数校验保护。核心业务逻辑被抽象为搜索、推荐、评分等服务。数据访问层负责对 PostgreSQL 的查询、缓存和事务处理。事件处理和后台任务实现了可扩展的异步集成。

Architecture Diagram 2

Architecture Diagram 3

Architecture Diagram 4

缓存策略概览

Caching Strategy

数据库模式

tools

ColumnTypeConstraints / Description
idSERIAL主键
nameVARCHAR(255)唯一、非空
slugVARCHAR(255)唯一、URL 安全
category_idINTEGERFK → categories.id
descriptionTEXT工具描述
taglineVARCHAR(500)简短营销语句
website_urlVARCHAR(500)官方网站
logo_urlVARCHAR(500)Logo 图片 URL
founded_dateDATE公司成立日期
company_nameVARCHAR(255)开发该工具的公司
is_activeBOOLEAN默认: true
query_countINTEGER默认: 0(趋势分数)
last_queried_atTIMESTAMP最近一次 API 查询时间
created_atTIMESTAMP默认: now()
updated_atTIMESTAMP默认: now()

索引

  • category_id
  • slug
  • is_active
  • (query_count, last_queried_at)

categories

ColumnTypeConstraints / Description
idSERIAL主键
nameVARCHAR(255)唯一、非空
slugVARCHAR(255)唯一
parent_idINTEGER自引用 FK → categories.id
descriptionTEXT类别描述
iconVARCHAR(100)图标标识符
display_orderINTEGER默认: 0
created_atTIMESTAMP创建时间戳

索引

  • parent_id
  • slug

pricing_tiers

ColumnTypeConstraints / Description
idSERIAL主键
tool_idINTEGERFK → tools.id (CASCADE)
tier_nameVARCHAR(100)Free、Starter、Pro
monthly_priceDECIMAL(10,2)可为空
annual_priceDECIMAL(10,2)可为空
currencyVARCHAR(3)默认: USD
billing_cycleENUMmonthlyannualone-time
features_jsonJSONB灵活的功能列表
limits_jsonJSONBAPI 限制、用户数、存储等
is_currentBOOLEAN默认: true
effective_fromTIMESTAMP定价开始时间
effective_toTIMESTAMP可为空
created_atTIMESTAMP创建时间戳

索引

  • (tool_id, is_current)
  • (effective_from, effective_to)

alternatives

ColumnTypeConstraints / Description
idSERIAL主键
tool_idINTEGERFK → tools.id
alternative_idINTEGERFK → tools.id
similarity_scoreDECIMAL(5,2)范围: 0–100
match_basisENUMfeaturespricingcategory
comparison_notesTEXT对比细节
upvotesINTEGER默认: 0
created_atTIMESTAMP创建时间戳
updated_atTIMESTAMP更新时间戳

约束

  • UNIQUE(tool_id, alternative_id)
  • tool_id <> alternative_id

索引

  • tool_id
  • similarity_score DESC

reviews_aggregate

ColumnTypeConstraints / Description
idSERIAL主键
tool_idINTEGERFK → tools.id
sourceVARCHAR(50)g2capterraproducthunt
avg_ratingDECIMAL(3,2)范围: 0–5
total_reviewsINTEGER评论数量
rating_breakdownJSONB例如 {5:120,4:45,...}
source_urlVARCHAR(500)评论页面 URL
last_scraped_atTIMESTAMP抓取时间
created_atTIMESTAMP创建时间戳

索引

  • (tool_id, source)
  • avg_rating DESC

features

ColumnTypeConstraints / Description
idSERIAL主键
tool_idINTEGERFK → tools.id
feature_nameVARCHAR(255)功能名称
feature_categoryVARCHAR(100)AuthAPIDatabase
is_availableBOOLEAN默认: true
tier_availabilityVARCHAR(50)freeproall
descriptionTEXT功能详情
created_atTIMESTAMP创建时间戳

索引

  • tool_id
  • feature_category
  • is_available

changelog

ColumnTypeConstraints / Description
idSERIAL主键
tool_idINTEGERFK → tools.id
change_typeENUMpricingfeatureupdate
change_summaryVARCHAR(500)简短摘要
change_detailsTEXT详细变更
old_valueJSONB旧值
new_valueJSONB新值
changed_atTIMESTAMP变更发生时间
created_atTIMESTAMP创建时间戳

索引

  • (tool_id, changed_at DESC)
  • change_type

integrations

ColumnTypeConstraints / Description
idSERIAL主键
tool_idINTEGERFK → tools.id
integrates_withINTEGERFK → tools.id
integration_typeENUMnativeapiwebhookzapier
ease_of_setupENUMeasymediumcomplex
documentation_urlVARCHAR(500)文档链接
is_officialBOOLEAN默认: false
created_atTIMESTAMP创建时间戳

索引

  • tool_id
  • integrates_with

API 文档

Tools API

1️⃣ 获取全部工具

端点

GET /tools/

查询参数

参数类型描述
categorystring (optional)按类别过滤
price_minnumber (optional)最低价格
price_maxnumber (optional)最高价格
featuresarray of strings (optional)必需的功能
sortstring (default: “name”)排序字段
pagenumber (default: 1)页码
sizenumber (default: 10)每页条目数

响应示例

{
  "items": [
    {
      "id": 1,
      "name": "VS Code",
      "slug": "vs-code",
      "category_id": 3,
      "description": "Free source‑code editor",
      "website_url": "https://code.visualstudio.com/",
      "logo_url": "https://example.com/logo.png",
      "is_active": true,
      "query_count": 124,
      "last_queried_at": "2025-11-01T12:34:56Z"
    }
    // …more tools
  ],
  "page": 1,
  "size": 10,
  "total_items": 342,
  "total_pages": 35
}

2️⃣ 获取工具详情

端点

GET /tools/{id}/

路径参数

  • id – 工具的整数 ID。

响应示例

{
  "id": 1,
  "name": "VS Code",
  "slug": "vs-code",
  "category": {
    "id": 3,
    "name": "IDE"
  },
  "description": "Free source‑code editor",
  "website_url": "https://code.visualstudio.com/",
  "logo_url": "https://example.com/logo.png",
  "features": [
    { "name": "IntelliSense", "available": true },
    { "name": "Debugging", "available": true }
  ],
  "pricing_tiers": [
    { "tier_name": "Free", "monthly_price": null, "annual_price": null }
  ],
  "reviews": {
    "avg_rating": 4.7,
    "total_reviews": 215
  }
}

3️⃣ 搜索工具

端点

GET /tools/search/

查询参数

参数类型描述
qstring搜索词(名称、标语等)
pagenumber页码(默认 1)
sizenumber每页条目数(默认 10)

响应 – 与 获取全部工具 的结构相同,只是已按搜索词过滤。

Categories API

端点

GET /categories/

返回工具类别列表及其层级结构。

Pricing Tiers API

端点

GET /tools/{id}/pricing/

提供指定工具的当前及历史定价信息。

Alternatives API

端点

GET /tools/{id}/alternatives/

返回基于相似度得分排序的替代工具列表。

Reviews Aggregate API

端点

GET /tools/{id}/reviews/

聚合来自外部来源(G2、Capterra、Product Hunt)的评分。

Features API

端点

GET /tools/{id}/features/

列出工具的所有功能,按类别和套餐可用性分组。

Changelog API

端点

GET /tools/{id}/changelog/

提供变更的时间顺序列表(定价、功能、更新等)。

Integrations API

端点

GET /tools/{id}/integrations/

展示该工具的原生及第三方集成情况。

Back to Blog

相关文章

阅读更多 »