首页/AI 智能体外部交互/extension-http-outcalls
E

extension-http-outcalls

by @caffeinelabsv
4.6(120)

此技能为后端 Canister 提供 HTTP GET 和 POST 请求能力,使其能够与外部 API 和服务进行集成。它简化了后端与第三方系统的通信,无需手动编写复杂的网络请求逻辑,从而加速开发并扩展了 Canister 的功能边界。

http-requestsapi-integrationbackend-developmentexternal-servicesGitHub
安装方式
npx skills add https://github.com/caffeinelabs/skills --skill extension-http-outcalls
compare_arrows

Before / After 效果对比

1 组
使用前

在没有这个技能之前,用户需要手动编写复杂的网络请求代码和数据处理逻辑,以实现后端 Canister 与外部服务的通信。这不仅耗时,而且容易出错,增加了开发和维护的负担。

使用后

该 Skill 提供了预构建的 HTTP 请求模块,用户只需简单调用即可实现与外部 API 的集成。此技能显著减少了开发时间,降低了错误率,并提升了后端服务的集成能力。

SKILL.md

HTTP Outcalls

HTTP outcalls extension for Caffeine AI.

Overview

This skill adds the ability to make HTTP GET and POST requests from the backend canister. Useful for integrating with external APIs and services.

Backend

For HTTP outcalls that must be performed in the backend:

There is the prefabricated module mo:caffeineai-http-outcalls/outcall.mo that that cannot be modified. It provides fundamental functionality for making HTTP GET or PUT requests in the backend.

module {
  public type TransformationInput = {
    context : Blob;
    response : IC.HttpRequestResult;
  };
  public type TransformationOutput = IC.HttpRequestResult;
  public type Transform = query TransformationInput -> async TransformationOutput;
  public type Header = {
    name: Text;
    value: Text;
  };

  // Helper function for the transform callback used by the IC on HTTP outcalls.
  public func transform(input : TransformationInput) : TransformationOutput;

  // HTTP GET request with a transform callback function.
  public func httpGetRequest(url : Text, extraHeaders: [Header], transform : Transform) : async Text;

  // HTTP POST request, specifying a transform callback.
  public func httpPostRequest(url : Text, extraHeaders: [Header], body : Text, transform : Transform) : async Text;
};

Usage for GET:

import OutCall "mo:caffeineai-http-outcalls/outcall";

actor {
  public query func transform(input: OutCall.TransformationInput) : async OutCall.TransformationOutput {
    OutCall.transform(input);
  };

  func makeGetOutcall(url: Text) : async Text {
    await OutCall.httpGetRequest(url, [], transform);
  };
};

Hint: JSON parsing is not directly supported in Motoko. Better tunnel JSON to frontend for parsing.

POST usage is analogous.

用户评价 (0)

发表评价

效果
易用性
文档
兼容性

暂无评价

统计数据

安装量27.5K
评分4.6 / 5.0
版本
更新日期2026年10月23日
对比案例1 组

用户评分

4.6(120)
5
37%
4
43%
3
13%
2
5%
1
2%

为此 Skill 评分

0.0

兼容平台

🤖claude-code

时间线

创建2026年6月25日
最后更新2026年10月23日
🎁 Agent 知识卡片
调研问卷