news-api-integration
Skill này làm gì
Skill này giải thích cách AI agent có thể gọi API tin tức để lấy tiêu đề và kết quả tìm kiếm. Nó dành cho nhà phát triển xây dựng nguồn tin hoặc công cụ hiển thị tin tức hiện tại.
Khi nào nên dùng
- ✓Khi bạn muốn hiển thị nguồn tiêu đề tin trong một ứng dụng hoặc bảng điều khiển.
- ✓Khi bạn cần tìm tin tức theo một chủ đề hoặc từ khóa.
- ✓Khi bạn muốn tin tức được lọc theo chuyên mục như công nghệ hoặc kinh doanh.
Liên kết skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/news-api-integration/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Thêm một nguồn tiêu đề công nghệ vào bảng điều khiển của tôi, dùng một API tin tức, và cho tôi tìm kiếm theo chủ đề.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent gọi API tin tức với một khóa và một chuyên mục hoặc từ khóa tìm kiếm, rồi đọc các bài báo được trả về. Skill mô tả GNews là lựa chọn được khuyên dùng vì gói miễn phí dễ dùng, còn NewsAPI là một lựa chọn khác.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
News API Integration
Multiple news APIs available. GNews is recommended for free tier usability.
Recommended: GNews
- Docs: https://gnews.io/docs/v4
- Base URL:
https://gnews.io/api/v4 - Auth: Query param
token=API_KEY - Free tier: 100 requests/day, 10 articles per request
- CORS: Yes
Top Headlines
GET /top-headlines?category=general&lang=en&max=10&token=API_KEY
Categories: general, world, nation, business, technology, entertainment, sports, science, health
Search
GET /search?q=artificial+intelligence&lang=en&max=10&token=API_KEY
Response Shape
{
"totalArticles": 1234,
"articles": [
{
"title": "Article Title",
"description": "Short description...",
"content": "Full article content (truncated)...",
"url": "https://example.com/article",
"image": "https://example.com/image.jpg",
"publishedAt": "2024-01-15T12:00:00Z",
"source": {
"name": "CNN",
"url": "https://cnn.com"
}
}
]
}
Alternative: NewsAPI.org
- Docs: https://newsapi.org/docs
- Free tier: 100 requests/day, for development only
- Note: Free plan does NOT support production use (requires paid plan for CORS from browser)
GET /v2/top-headlines?country=us&apiKey=API_KEY
GET /v2/everything?q=bitcoin&apiKey=API_KEY
Other Alternatives (from public-apis)
| API | Free Tier | Best For |
|---|---|---|
| GNews | 100 req/day | General news, good free tier |
| Currents API | 600 req/day | Real-time news, good rate |
| NewsData.io | 200 req/day | News + crypto news |
| The Guardian | Unlimited (rate limited) | UK/international news |
| New York Times | 500 req/day | US news, archives |
| Mediastack | 500 req/month | Multi-source aggregation |
| TheNews API | 100 req/day | Simple aggregation |
| MarketAux | 100 req/day | Financial news with sentiment |
| HackerNews | No limit | Tech/startup news (no key needed) |
Frontend Service Implementation
// src/services/news.ts
import { createCircuitBreaker } from '@/utils/circuit-breaker';
export interface NewsArticle {
title: string;
description: string;
url: string;
source: string;
publishedAt: string;
image?: string;
}
const newsBreaker = createCircuitBreaker<NewsArticle[]>({
name: 'News',
cacheTtlMs: 5 * 60_000, // 5 minutes
});
export async function fetchNews(category = 'general'): Promise<NewsArticle[]> {
return newsBreaker.execute(async () => {
const resp = await fetch(`/api/news?category=${category}`);
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
const data = await resp.json();
return data.articles || [];
}, []);
}
export async function searchNews(query: string): Promise<NewsArticle[]> {
const resp = await fetch(`/api/news?q=${encodeURIComponent(query)}`);
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
const data = await resp.json();
return data.articles || [];
}
HackerNews (No API Key Needed)
For tech news, HackerNews API is free and unlimited:
// Fetch top 30 stories
const topIds = await fetch('https://hacker-news.firebaseio.com/v0/topstories.json').then(r => r.json());
const stories = await Promise.all(
topIds.slice(0, 30).map((id: number) =>
fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`).then(r => r.json())
)
);
// Each story: { title, url, score, by, time, descendants }
Panel Rendering Pattern
private render(articles: NewsArticle[]): void {
const rows = articles.map(a => `
<div class="news-item">
<a href="${a.url}" target="_blank" rel="noopener" class="news-title">${escapeHtml(a.title)}</a>
<div class="news-meta">
<span class="news-source">${escapeHtml(a.source)}</span>
<span class="news-time">${formatTime(new Date(a.publishedAt))}</span>
</div>
</div>
`).join('');
this.setContent(`<div class="news-list">${rows}</div>`);
}
Always escape user-controlled strings with escapeHtml() to prevent XSS.
Câu hỏi thường gặp
API tin tức nào được khuyên dùng?
Skill khuyên dùng GNews vì gói miễn phí dễ sử dụng và ghi chú nó hỗ trợ CORS trên trình duyệt.
NewsAPI có miễn phí cho môi trường sản phẩm không?
Không, skill nói gói miễn phí của nó chỉ dành cho phát triển và không hỗ trợ dùng sản phẩm từ trình duyệt.
Có những chuyên mục nào?
Skill liệt kê các chuyên mục như chung, kinh doanh, công nghệ, thể thao, khoa học và sức khỏe.
Chi tiết
Mô tả gốc của tác giả
Integrate with news APIs (GNews, NewsAPI, etc.) for aggregated news feeds. Covers headline fetching, search, and category filtering.
repo: HKUDS/AgentPilot
Độ phổ biến
- Sao GitHub
- 7.8k
- Vị trí xếp hạng
- #13061
- Giấy phép
- MIT
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
agentpilot
7.8kGiúp agent của bạn cải thiện dự án từng bước bằng cách chuẩn bị tác vụ và chạy vòng lặp AgentPilot, gồm đề xuất, kiểm thử và chấm điểm thay đổi.
openspace
7.8kGiúp agent của bạn thiết lập OpenSpace, công cụ lưu và lấy lại skill của agent, rồi kết nối nó với ứng dụng AI của bạn qua MCP.
rsi-arena
7.8kGiúp agent của bạn thiết lập và chạy các bài kiểm thử benchmark AI chuẩn, như AIME và Terminal-Bench, để so sánh các phương pháp cải tiến khác nhau.
experiment-guide
7.8kGiúp agent của bạn lên kế hoạch các thí nghiệm nhỏ, đọc kết quả và ghi lại phát hiện khi tìm cách cải thiện một chương trình.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.