pexels-media by troykelly/claude-skills
npx skills add https://github.com/troykelly/claude-skills --skill pexels-media从 Pexels 获取高质量、免版税的图片和视频,用于设计工作、占位符或内容创作。
此技能需要设置 PEXELS_API_KEY 环境变量。
# 检查 API 密钥是否可用
echo $PEXELS_API_KEY
如果未设置,请从 Pexels API 获取免费的 API 密钥。
https://api.pexels.com/v1/https://api.pexels.com/videos/所有请求都需要 Authorization 请求头:
curl -H "Authorization: $PEXELS_API_KEY" "https://api.pexels.com/v1/search?query=nature"
curl -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/search?query=QUERY&orientation=ORIENTATION&size=SIZE&color=COLOR&locale=LOCALE&page=PAGE&per_page=PER_PAGE"
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
参数:
| 参数 | 必需 | 值 |
|---|---|---|
query | 是 | 搜索词 |
orientation | 否 | landscape, portrait, square |
size | 否 | large (24MP), medium (12MP), small (4MP) |
color | 否 | red, orange, yellow, green, turquoise, blue, violet, pink, brown, black, gray, , 或十六进制代码(例如 ) |
locale | 否 | en-US, pt-BR, es-ES, de-DE, fr-FR, ja-JP, zh-CN, ko-KR 等 |
page | 否 | 页码(默认:1) |
per_page | 否 | 每页结果数(默认:15,最大:80) |
由 Pexels 团队策划的热门照片(每小时更新):
curl -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/curated?page=1&per_page=15"
curl -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/photos/PHOTO_ID"
curl -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/videos/search?query=QUERY&orientation=ORIENTATION&size=SIZE&min_width=MIN_WIDTH&min_height=MIN_HEIGHT&min_duration=MIN_DURATION&max_duration=MAX_DURATION&page=PAGE&per_page=PER_PAGE"
附加视频参数:
| 参数 | 描述 |
|---|---|
min_width | 最小宽度(像素) |
min_height | 最小高度(像素) |
min_duration | 最短时长(秒) |
max_duration | 最长时长(秒) |
curl -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/videos/popular?min_width=1920&min_duration=10&max_duration=60&page=1&per_page=15"
curl -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/videos/videos/VIDEO_ID"
curl -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/collections/featured?page=1&per_page=15"
curl -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/collections/COLLECTION_ID?type=TYPE&page=1&per_page=15"
类型参数: photos、videos,或省略表示两者都包含。
下载照片时,API 响应中提供以下尺寸:
| 键 | 描述 |
|---|---|
original | 摄影师上传的原始尺寸 |
large2x | 宽度 940px,高度加倍 |
large | 宽度 940px |
medium | 高度 350px |
small | 高度 130px |
portrait | 宽度 800px,高度 1200px |
landscape | 宽度 1200px,高度 627px |
tiny | 宽度 280px,高度 200px |
视频在响应中包含多种质量的文件:
| 质量 | 典型分辨率 |
|---|---|
hd | 1280x720 |
sd | 640x360 |
hls | 自适应流 |
| 多种 | 全高清、4K(如果可用) |
关键要求: 对于每一个下载的文件,您必须创建一个辅助元数据文件。
对于下载的文件 mountain-sunset.jpg,创建 mountain-sunset.jpg.meta.json。
{
"source": "pexels",
"type": "photo",
"id": 12345,
"url": "https://www.pexels.com/photo/12345/",
"download_url": "https://images.pexels.com/photos/12345/pexels-photo-12345.jpeg",
"downloaded_size": "large",
"width": 1920,
"height": 1080,
"photographer": "John Doe",
"photographer_url": "https://www.pexels.com/@johndoe",
"photographer_id": 67890,
"avg_color": "#7E5835",
"alt": "Brown mountain during sunset",
"license": "Pexels License - Free for personal and commercial use",
"attribution": "Photo by John Doe on Pexels",
"attribution_html": "<a href=\"https://www.pexels.com/photo/12345/\">Photo</a> by <a href=\"https://www.pexels.com/@johndoe\">John Doe</a> on <a href=\"https://www.pexels.com\">Pexels</a>",
"downloaded_at": "2025-12-02T14:30:00Z",
"api_response": {
// 此照片的完整原始 API 响应
}
}
{
"source": "pexels",
"type": "video",
"id": 12345,
"url": "https://www.pexels.com/video/12345/",
"download_url": "https://videos.pexels.com/video-files/12345/...",
"downloaded_quality": "hd",
"width": 1920,
"height": 1080,
"duration": 30,
"user": {
"id": 67890,
"name": "John Doe",
"url": "https://www.pexels.com/@johndoe"
},
"video_files": [
{
"id": 1,
"quality": "hd",
"file_type": "video/mp4",
"width": 1920,
"height": 1080,
"link": "https://..."
}
],
"video_pictures": [
{
"id": 1,
"picture": "https://...",
"nr": 0
}
],
"license": "Pexels License - Free for personal and commercial use",
"attribution": "Video by John Doe on Pexels",
"downloaded_at": "2025-12-02T14:30:00Z",
"api_response": {
// 此视频的完整原始 API 响应
}
}
# 搜索照片
RESPONSE=$(curl -s -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/search?query=office+workspace&orientation=landscape&per_page=5")
# 解析并显示结果
echo "$RESPONSE" | jq '.photos[] | {id, photographer, alt, url: .src.large}'
# 获取照片详情
PHOTO_ID=12345
PHOTO_DATA=$(curl -s -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/photos/$PHOTO_ID")
# 提取下载 URL(选择尺寸)
DOWNLOAD_URL=$(echo "$PHOTO_DATA" | jq -r '.src.large')
FILENAME="pexels-$PHOTO_ID-large.jpg"
# 下载图片
curl -L -o "$FILENAME" "$DOWNLOAD_URL"
# 创建辅助元数据文件(强制要求)
echo "$PHOTO_DATA" | jq '{
source: "pexels",
type: "photo",
id: .id,
url: .url,
download_url: .src.large,
downloaded_size: "large",
width: .width,
height: .height,
photographer: .photographer,
photographer_url: .photographer_url,
photographer_id: .photographer_id,
avg_color: .avg_color,
alt: .alt,
license: "Pexels License - Free for personal and commercial use",
attribution: ("Photo by " + .photographer + " on Pexels"),
downloaded_at: (now | todate),
api_response: .
}' > "$FILENAME.meta.json"
X-Ratelimit-LimitX-Ratelimit-RemainingX-Ratelimit-Reset虽然 Pexels 许可证在法律上不要求署名,但鼓励署名:
attribution_html# 获取 5 张抽象/极简图片作为占位符
curl -s -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/search?query=minimal+abstract&orientation=square&size=small&per_page=5"
# 查找简短、宽阔的风景视频
curl -s -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/videos/search?query=nature+aerial&orientation=landscape&min_width=1920&min_duration=5&max_duration=15"
# 搜索干净、中性的背景
curl -s -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/search?query=white+background+texture&color=white&size=large"
使用此技能时:
PEXELS_API_KEY 已设置每周安装数
90
代码仓库
GitHub 星标数
6
首次出现
Jan 24, 2026
安全审计
安装于
gemini-cli82
codex82
opencode82
github-copilot80
cursor78
kimi-cli77
Source high-quality, royalty-free images and videos from Pexels for design work, placeholders, or content creation.
This skill requires the PEXELS_API_KEY environment variable to be set.
# Check if API key is available
echo $PEXELS_API_KEY
If not set, obtain a free API key from Pexels API.
https://api.pexels.com/v1/https://api.pexels.com/videos/All requests require the Authorization header:
curl -H "Authorization: $PEXELS_API_KEY" "https://api.pexels.com/v1/search?query=nature"
curl -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/search?query=QUERY&orientation=ORIENTATION&size=SIZE&color=COLOR&locale=LOCALE&page=PAGE&per_page=PER_PAGE"
Parameters:
| Parameter | Required | Values |
|---|---|---|
query | Yes | Search term |
orientation | No | landscape, portrait, square |
size | No | large (24MP), medium (12MP), (4MP) |
Trending photos curated by the Pexels team (updated hourly):
curl -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/curated?page=1&per_page=15"
curl -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/photos/PHOTO_ID"
curl -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/videos/search?query=QUERY&orientation=ORIENTATION&size=SIZE&min_width=MIN_WIDTH&min_height=MIN_HEIGHT&min_duration=MIN_DURATION&max_duration=MAX_DURATION&page=PAGE&per_page=PER_PAGE"
Additional Video Parameters:
| Parameter | Description |
|---|---|
min_width | Minimum width in pixels |
min_height | Minimum height in pixels |
min_duration | Minimum duration in seconds |
max_duration | Maximum duration in seconds |
curl -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/videos/popular?min_width=1920&min_duration=10&max_duration=60&page=1&per_page=15"
curl -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/videos/videos/VIDEO_ID"
curl -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/collections/featured?page=1&per_page=15"
curl -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/collections/COLLECTION_ID?type=TYPE&page=1&per_page=15"
Type parameter: photos, videos, or omit for both.
When downloading photos, these sizes are available in the API response:
| Key | Description |
|---|---|
original | Original size uploaded by photographer |
large2x | Width 940px, height doubled |
large | Width 940px |
medium | Height 350px |
small | Height 130px |
portrait | Width 800px, height 1200px |
Videos include multiple quality files in the response:
| Quality | Typical Resolution |
|---|---|
hd | 1280x720 |
sd | 640x360 |
hls | Adaptive streaming |
| Various | Full HD, 4K when available |
CRITICAL REQUIREMENT: For EVERY downloaded file, you MUST create a sidecar metadata file.
For a downloaded file mountain-sunset.jpg, create mountain-sunset.jpg.meta.json.
{
"source": "pexels",
"type": "photo",
"id": 12345,
"url": "https://www.pexels.com/photo/12345/",
"download_url": "https://images.pexels.com/photos/12345/pexels-photo-12345.jpeg",
"downloaded_size": "large",
"width": 1920,
"height": 1080,
"photographer": "John Doe",
"photographer_url": "https://www.pexels.com/@johndoe",
"photographer_id": 67890,
"avg_color": "#7E5835",
"alt": "Brown mountain during sunset",
"license": "Pexels License - Free for personal and commercial use",
"attribution": "Photo by John Doe on Pexels",
"attribution_html": "<a href=\"https://www.pexels.com/photo/12345/\">Photo</a> by <a href=\"https://www.pexels.com/@johndoe\">John Doe</a> on <a href=\"https://www.pexels.com\">Pexels</a>",
"downloaded_at": "2025-12-02T14:30:00Z",
"api_response": {
// Full original API response for this photo
}
}
{
"source": "pexels",
"type": "video",
"id": 12345,
"url": "https://www.pexels.com/video/12345/",
"download_url": "https://videos.pexels.com/video-files/12345/...",
"downloaded_quality": "hd",
"width": 1920,
"height": 1080,
"duration": 30,
"user": {
"id": 67890,
"name": "John Doe",
"url": "https://www.pexels.com/@johndoe"
},
"video_files": [
{
"id": 1,
"quality": "hd",
"file_type": "video/mp4",
"width": 1920,
"height": 1080,
"link": "https://..."
}
],
"video_pictures": [
{
"id": 1,
"picture": "https://...",
"nr": 0
}
],
"license": "Pexels License - Free for personal and commercial use",
"attribution": "Video by John Doe on Pexels",
"downloaded_at": "2025-12-02T14:30:00Z",
"api_response": {
// Full original API response for this video
}
}
# Search for photos
RESPONSE=$(curl -s -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/search?query=office+workspace&orientation=landscape&per_page=5")
# Parse and display results
echo "$RESPONSE" | jq '.photos[] | {id, photographer, alt, url: .src.large}'
# Get photo details
PHOTO_ID=12345
PHOTO_DATA=$(curl -s -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/photos/$PHOTO_ID")
# Extract download URL (choose size)
DOWNLOAD_URL=$(echo "$PHOTO_DATA" | jq -r '.src.large')
FILENAME="pexels-$PHOTO_ID-large.jpg"
# Download the image
curl -L -o "$FILENAME" "$DOWNLOAD_URL"
# Create sidecar metadata (MANDATORY)
echo "$PHOTO_DATA" | jq '{
source: "pexels",
type: "photo",
id: .id,
url: .url,
download_url: .src.large,
downloaded_size: "large",
width: .width,
height: .height,
photographer: .photographer,
photographer_url: .photographer_url,
photographer_id: .photographer_id,
avg_color: .avg_color,
alt: .alt,
license: "Pexels License - Free for personal and commercial use",
attribution: ("Photo by " + .photographer + " on Pexels"),
downloaded_at: (now | todate),
api_response: .
}' > "$FILENAME.meta.json"
X-Ratelimit-LimitX-Ratelimit-RemainingX-Ratelimit-ResetWhile not legally required by the Pexels license, attribution is encouraged:
attribution_html from the sidecar file# Get 5 abstract/minimal images for placeholders
curl -s -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/search?query=minimal+abstract&orientation=square&size=small&per_page=5"
# Find short, wide landscape videos
curl -s -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/videos/search?query=nature+aerial&orientation=landscape&min_width=1920&min_duration=5&max_duration=15"
# Search for clean, neutral backgrounds
curl -s -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/search?query=white+background+texture&color=white&size=large"
When using this skill:
PEXELS_API_KEY is setWeekly Installs
90
Repository
GitHub Stars
6
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
gemini-cli82
codex82
opencode82
github-copilot80
cursor78
kimi-cli77
lark-cli 共享规则:飞书资源操作指南与权限配置详解
35,100 周安装
white#ffffffsmallcolor | No | red, orange, yellow, green, turquoise, blue, violet, pink, brown, black, gray, white, or hex code (e.g., #ffffff) |
locale | No | en-US, pt-BR, es-ES, de-DE, fr-FR, ja-JP, zh-CN, ko-KR, etc. |
page | No | Page number (default: 1) |
per_page | No | Results per page (default: 15, max: 80) |
landscape| Width 1200px, height 627px |
tiny | Width 280px, height 200px |