1. 快速接入
1.1 获取 API Key
访问 定价页面,选择适合的套餐:
- 免费试用 — 直接填写信息即可生成 API Key,每日 100 次调用
- 入门版/专业版 — 提交订单 → 转账 → 后台确认后自动发放 API Key
- 企业版 — 联系客服获取专属方案
建议先从免费版开始测试,确认接口满足需求后再升级付费套餐
1.2 鉴权方式
有两种传参方式(推荐使用请求头方式):
-H "X-API-Key: fme_your_key_here"
?api_key=fme_your_key_here
请妥善保管你的 API Key,不要在前端代码中明文暴露。如果 Key 泄漏,请联系我们吊销并重新生成。
1.3 免费额度
免费套餐每日 100 次调用额度,UTC 零点重置。超出返回 HTTP 429,请在 定价页面 升级套餐。
2. 代码示例
以下示例演示各语言调用方式。所有示例使用同一个场景:上传图片进行人脸情绪分析。
import requests
API_KEY = "fme_your_key_here"
URL = "https://followsrc.wang/api/v2/analyze/image"
with open("photo.jpg", "rb") as f:
resp = requests.post(
URL,
headers={"X-API-Key": API_KEY},
files={"image": f}
)
data = resp.json()
print(f"状态码: {data['code']}")
print(f"检测到 {data['data']['total_faces']} 张人脸")
for face in data['data']['faces']:
emotion = face['emotion']
print(f" 情绪: {emotion['label']} (置信度: {emotion['confidence']:.2%})")
print(f" 位置: x={face['bbox']['x']}, y={face['bbox']['y']}, "
f"w={face['bbox']['w']}, h={face['bbox']['h']}")
curl -X POST https://followsrc.wang/api/v2/analyze/image \
-H "X-API-Key: fme_your_key_here" \
-F "image=@photo.jpg" \
| python3 -m json.tool
const API_KEY = "fme_your_key_here";
async function analyzeImage(imagePath) {
const formData = new FormData();
formData.append("image", fs.createReadStream(imagePath));
const resp = await fetch("https://followsrc.wang/api/v2/analyze/image", {
method: "POST",
headers: { "X-API-Key": API_KEY },
body: formData
});
const data = await resp.json();
console.log(`检测到 ${data.data.total_faces} 张人脸`);
data.data.faces.forEach((face, i) => {
console.log(`人脸 #${i + 1}: ${face.emotion.label} ` +
`(${(face.emotion.confidence * 100).toFixed(1)}%)`);
});
}
import okhttp3.*;
import org.json.JSONObject;
public class EmotionAnalyzer {
private static final String API_KEY = "fme_your_key_here";
private static final String URL = "https://followsrc.wang/api/v2/analyze/image";
public static void main(String[] args) throws Exception {
OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(60, TimeUnit.SECONDS)
.build();
RequestBody fileBody = RequestBody.create(
MediaType.parse("image/jpeg"),
new java.io.File("photo.jpg")
);
MultipartBody body = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("image", "photo.jpg", fileBody)
.build();
Request request = new Request.Builder()
.url(URL)
.header("X-API-Key", API_KEY)
.post(body)
.build();
try (Response resp = client.newCall(request).execute()) {
JSONObject json = new JSONObject(resp.body().string());
System.out.println("状态码: " + json.getInt("code"));
JSONObject data = json.getJSONObject("data");
System.out.println("检测到 " + data.getInt("total_faces") + " 张人脸");
}
}
}
3. 更多 API 调用示例
3.1 视频分析
import requests
resp = requests.post(
"https://followsrc.wang/api/v2/analyze/video",
headers={"X-API-Key": "fme_your_key_here"},
files={"video": open("interview.mp4", "rb")}
)
data = resp.json()
print(f"总帧数: {data['data']['total_frames']}")
print(f"主要情绪: {data['data']['summary']['dominant_emotion']}")
print(f"情绪变化: {data['data']['summary']['emotion_transitions']}")
3.2 实时帧分析(WebSocket)
发送单帧 JPEG 字节数据,适合摄像头实时流场景:
curl -X POST https://followsrc.wang/api/v2/analyze/frame \
-H "X-API-Key: fme_your_key_here" \
-H "Content-Type: image/jpeg" \
--data-binary @frame.jpg
import cv2
import requests
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
_, jpeg = cv2.imencode('.jpg', frame, [cv2.IMWRITE_JPEG_QUALITY, 85])
resp = requests.post(
"https://followsrc.wang/api/v2/analyze/frame",
headers={
"X-API-Key": "fme_your_key_here",
"Content-Type": "image/jpeg"
},
data=jpeg.tobytes()
)
result = resp.json()
print(f"当前情绪: {result['data']['faces'][0]['emotion']['label']}")
3.3 人脸注册与识别
resp = requests.post(
"https://followsrc.wang/api/v2/faces/register",
headers={"X-API-Key": "fme_your_key_here"},
files={"image": open("zhangsan.jpg", "rb")},
data={"name": "张三"}
)
print(resp.json())
resp = requests.post(
"https://followsrc.wang/api/v2/faces/recognize",
headers={"X-API-Key": "fme_your_key_here"},
files={"image": open("unknown.jpg", "rb")}
)
data = resp.json()
print(f"识别结果: {data['data']['name']} (相似度: {data['data']['similarity']:.2%})")
3.4 用量查询
resp = requests.get(
"https://followsrc.wang/api/v2/usage",
headers={"X-API-Key": "fme_your_key_here"}
)
data = resp.json()
print(f"今日总量: {data['data']['key_info']['daily_count']}")
print(f"每日限额: {data['data']['key_info']['daily_limit']}")
print(f"各端点明细:")
for ep in data['data']['by_endpoint']:
print(f" {ep['endpoint']}: {ep['count']} 次")