Chinese Joke Api

# Chinese Joke API Skill

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "Chinese Joke Api" with this command: npx skills add djttt/chinese-joke-api

Chinese Joke API Skill

概述

这个 skill 使用第三方中文笑话 API 获取有趣的中式幽默。

API 源

1. 一言 API (Hitokoto)

特点: 包含各种类型的中文短句,包括笑话

基础 URL: https://v1.hitokoto.cn

用法:

curl "https://v1.hitokoto.cn?c=j"

参数:

  • c=j - 搞笑类别
  • c=a - 动画
  • c=b - 漫画
  • c=c - 原创

2. 简短笑话 API

特点: 专门的笑话 API,返回中文短笑话

基础 URL: https://api.jokeapi.cn

用法:

curl "https://api.jokeapi.cn/joke/Any?safe-mode"

快速开始

使用 Bash

# 获取一言搞笑
curl -s "https://v1.hitokoto.cn?c=j" | python3 -m json.tool

# 获取简短笑话
curl -s "https://api.jokeapi.cn/joke/Any?safe-mode" | python3 -m json.tool

使用 Python

import requests

# 一言搞笑
resp = requests.get("https://v1.hitokoto.cn?c=j")
data = resp.json()
print(f"{data['hitokoto']} - {data['from']}")

# 简短笑话
resp = requests.get("https://api.jokeapi.cn/joke/Any?safe-mode")
data = resp.json()
if data['type'] == 'single':
    print(data['joke'])
else:
    print(data['setup'])
    print(data['delivery'])

示例代码

Bash 脚本

#!/bin/bash
# 获取一言搞笑
curl -s "https://v1.hitokoto.cn?c=j" | python3 -c "
import sys, json
d = json.load(sys.stdin)
print(f'「{d['hitokoto']}」')
print(f'—— {d.get('from_') or d.get('from')}')
"

Python 脚本

#!/usr/bin/env python3
import requests
import json

def get_chinese_joke():
    """获取中文笑话"""
    try:
        # 尝试一言 API
        resp = requests.get("https://v1.hitokoto.cn?c=j", timeout=5)
        data = resp.json()
        print(f"「{data['hitokoto']}」")
        print(f"—— {data.get('from_', data.get('from'))}")
        return True
    except Exception as e:
        print(f"获取失败:{e}")
        return False

if __name__ == "__main__":
    get_chinese_joke()

注意事项

⚠️ 这些 API 都是第三方服务,可用性可能不稳定:

  • 一言 API:偶尔响应慢
  • 简短笑话 API:可能有时限流

建议:

  • 添加错误处理
  • 设置超时
  • 考虑备用 API

相关链接

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

aicade-create-service

Use when registering, updating, querying, or disabling aicade service-management APIs under /services, especially when preparing service metadata, billing, r...

Registry SourceRecently Updated
General

Huo15 Openclaw Enhance

火一五·克劳德·龙虾增强插件 v6.0.0 — npm 包改名 @huo15/openclaw-enhance → @huo15/huo15-openclaw-enhance(与 huo15-* 命名规范对齐 + 让 ClawHub 重新创建干净的 plugin entry,绕开老 slug 1.3.0-5.1....

Registry SourceRecently Updated
General

Xiaohongshu Creator Marketplace (Pugongying) Creator Core Metrics API

Call GET /api/xiaohongshu-pgy/api/pgy/kol/data/core_data/v1 for Xiaohongshu Creator Marketplace (Pugongying) Creator Core Metrics through JustOneAPI with use...

Registry SourceRecently Updated
General

Xiaohongshu Creator Marketplace (Pugongying) Creator Search API

Call GET /api/xiaohongshu-pgy/api/solar/cooperator/blogger/v2/v1 for Xiaohongshu Creator Marketplace (Pugongying) Creator Search through JustOneAPI.

Registry SourceRecently Updated