AGENT SKILL

stock-photo-api

Integrates the Unsplash, Pexels, and Pixabay APIs in code - auth, search endpoints, rate limits, attribution, hotlinking versus caching rules, and the compliance obligations that get apps deactivated when skipped. Use when someone says "integrate the Unsplash API", "pull images from Pexels in my app", "build an image picker on a stock photo API", "how do I trigger the Unsplash download endpoint", or is wiring stock imagery into a CMS, blog pipeline, or placeholder service. Do NOT use to choose a source by hand or write a search brief - use stock-photo-finder instead; do NOT use to decide whether a license permits a use or a release is needed - use image-license-rights instead; do NOT use to art-direct results - use visual-asset-curation instead.

License 许可
MIT
所属仓库
SkillMedev/skills
最近更新
2026-10-14
Stars
★ 25
Forks
3

01 前言 Front Matter

name
stock-photo-api
metadata
{ "title": "Stock Photo APIs" }
description
Integrates the Unsplash, Pexels, and Pixabay APIs in code - auth, search endpoints, rate limits, attribution, hotlinking versus caching rules, and the compliance obligations that get apps deactivated when skipped. Use when someone says "integrate the Unsplash API", "pull images from Pexels in my app", "build an image picker on a stock photo API", "how do I trigger the Unsplash download endpoint", or is wiring stock imagery into a CMS, blog pipeline, or placeholder service. Do NOT use to choose a source by hand or write a search brief - use stock-photo-finder instead; do NOT use to decide whether a license permits a use or a release is needed - use image-license-rights instead; do NOT use to art-direct results - use visual-asset-curation instead.

03 SKILL.md 正文

Stock Photo APIs

Wire stock imagery into a product through the three main free APIs - Unsplash, Pexels, Pixabay - without tripping the compliance rules that get API keys revoked. The fetch is trivial; the contractual obligations (Unsplash's download-endpoint trigger, Pixabay's mandatory caching, attribution everywhere) are the actual work, and skipping them is the #1 reason apps get deactivated.

Operating procedure

Step 1: Gather inputs

  • Is the need dynamic, repeated, or in-product? For a one-off hero image, download it by hand - an API key is overkill.
  • Which provider(s), or should the integration abstract over all three? (Choosing a source for a specific image is stock-photo-finder's job.)
  • Expected request volume, to check against the rate-limit table.
  • Where images will render (client hotlink vs server cache) - this decides between Unsplash's hotlink rule and Pixabay's cache rule.
  • Whether anything commercial ships - a human owns that license call via image-license-rights.

Step 2: Pick against the provider quick reference

Provider Auth Search endpoint Default rate limit The gotcha most people miss
Unsplash Authorization: Client-ID ACCESS_KEY GET /search/photos Demo 50 req/hr; Production 5000 req/hr after app review MUST trigger the per-photo download endpoint on use, attribute photographer + Unsplash with UTM links, and hotlink the returned urls (do not rehost)
Pexels Authorization: API_KEY GET /v1/search 200 req/hr, 20,000 req/mo default Show Pexels + photographer attribution; do not build a Pexels clone; respect the X-Ratelimit-* response headers
Pixabay ?key=API_KEY query param GET /api/ ~100 req/min Must cache/download images to your own server per their terms rather than permanently hotlinking; cache API responses ~24h

These are the documented defaults - confirm current limits and terms in each provider's live docs before shipping, since providers revise them.

Step 3: Implement the compliant flow (Unsplash worked example)

Unsplash's guidelines are strict and enforced. The three non-negotiables: hotlink, trigger-download, attribute.

const ACCESS_KEY = process.env.UNSPLASH_ACCESS_KEY!; // server-side only
const H = { Authorization: `Client-ID ${ACCESS_KEY}` };

// 1. Search. Hotlink the urls Unsplash returns; do not rehost the file.
async function searchPhotos(query: string) {
  const res = await fetch(
    `https://api.unsplash.com/search/photos?query=${encodeURIComponent(query)}&per_page=12&orientation=landscape`,
    { headers: H },
  );
  if (!res.ok) throw new Error(`Unsplash ${res.status}`);
  const { results } = await res.json();
  return results; // each has urls.regular, links.download_location, user{name, links.html}
}

// 2. REQUIRED: when a photo is actually used/downloaded, ping its
//    download_location. This is how photographers get credited usage.
//    Skipping it is the top reason Unsplash deactivates apps.
async function triggerDownload(downloadLocation: string) {
  await fetch(downloadLocation, { headers: H });
}

// 3. REQUIRED: attribute with UTM params to the photographer and Unsplash.
function attribution(photo: { user: { name: string; links: { html: string } } }) {
  const u = `${photo.user.links.html}?utm_source=your_app&utm_medium=referral`;
  return `Photo by <a href="${u}">${photo.user.name}</a> on ` +
         `<a href="https://unsplash.com/?utm_source=your_app&utm_medium=referral">Unsplash</a>`;
}

Step 4: Run the compliance checklist

  • Keys are secret and server-side. Never ship an access/secret key in client JS - proxy through a backend or serverless function.
  • Unsplash: hotlink urls, fire download_location on use, attribute with UTM links. Demo apps stay capped at 50 req/hr until production approval.
  • Pexels: render the required Pexels + photographer attribution; do not replicate Pexels as a product.
  • Pixabay: download/cache images to your server; cache API responses ~24h; do not permanently hotlink.
  • Rate limits: read the response headers (X-Ratelimit-Remaining and friends), back off on 429, and cache search results so one query is not re-fetched on every render - pair with rate-limit-handler for the backoff design.
  • License still applies. The API grants no rights it does not have: identifiable people/brands and editorial-only assets remain image-license-rights territory. Surface that to whoever publishes the result.

Step 5: Build for robustness

  • Wrap calls with timeouts, retry-with-backoff on 429/5xx, and a graceful empty state for zero results.
  • Persist provider, photo ID, photographer name, profile URL, and attribution HTML alongside any stored image - needed to render credit and answer later license questions.
  • Normalize the providers behind one internal interface (searchImages(query): Promise<Image[]>) so callers never depend on a provider's response shape, and a provider swap is one adapter.

Deliverable

Produce a working integration containing: the server-side proxy with secret key handling, the provider adapter(s) behind a normalized interface, the Unsplash download-trigger call sited at the moment of use, attribution rendering, response caching per provider rule, and stored metadata (provider, ID, photographer, attribution HTML) for every persisted image.

Do NOT

  • Do not ship API keys in client-side code.
  • Do not skip Unsplash's download_location trigger or its UTM attribution - the enforcement is real.
  • Do not rehost Unsplash images (hotlink their urls) and do not permanently hotlink Pixabay images (cache them) - the two rules are opposites; applying the wrong one violates the terms.
  • Do not hammer search on every page render - cache results and honor rate-limit headers.
  • Do not treat API access as a license opinion; anything commercial with identifiable people or brands goes through image-license-rights.
  • Do not hand-pick images or write search briefs here - that is stock-photo-finder.

Quality bar

  • Each provider's specific compliance rule is implemented, not just the fetch: download trigger + attribution + hotlinking for Unsplash, attribution for Pexels, server caching for Pixabay.
  • No key appears in client-delivered code.
  • A 429 produces backoff, not a retry storm; zero results produce a designed empty state.
  • Every persisted image carries enough metadata to render credit and answer a license question later.

Escalation

License permission and model/property-release questions go to image-license-rights (and to counsel for anything contractual). Source selection and search strategy go to stock-photo-finder; visual selection among results to visual-asset-curation.

04 同仓库更多 Skills

SkillMedev
SkillMedev/skills

有氧运动计划

zone-2-cardio-plan

当有人要求制定稳态有氧训练计划、进行有氧基础训练或达到第二区间、安排轻松或耐力型的每周有氧训练、按心率区间训练,或提高静息心率、最大摄氧量或耐力时,可以使用此方案。该方案构建了一个包含训练计划结构、训练方式选择和进度安排的心率区间有氧训练模块。本方案仅提供一般健身指导,不构成医疗建议。请勿用于设计力量或举重训练计划(请使用力量训练计划)、高强度间歇训练 (HIIT) 或循环训练(请使用体能训练和 HIIT 计划),或灵活性/柔韧性训练(请使用灵活性训练计划)。

★ 25
SkillMedev
SkillMedev/skills

youtube-script-writer

Writes retention-engineered long-form YouTube scripts on a hook/body/payoff architecture - a first-30-seconds hook that survives the retention cliff, a beat-sheet body with mini-hooks and bridges, timed pattern interrupts, and a payoff that over-delivers - with B-roll and editing cues marked inline. Use when someone says "script my next video", "my retention graph dies at the start", "tighten this draft", or "outline a video on X". Do NOT use for the 3-second opener of TikTok, Reels, or Shorts - use video-hook-writer instead; do NOT use for spoken voiceover synced to on-screen tutorial actions - use narration-script instead; do NOT use for a sales demo built on a buyer's discovery notes - use demo-script instead; do NOT use to design the thumbnail and title - use thumbnail-concept instead.

★ 25
SkillMedev
SkillMedev/skills

win-back-campaign

Designs segmented win-back email sequences for dormant users - dormancy tiers, a three-beat sequence with a single proportional incentive, and a suppression rule - and measures success by re-activation, not opens. Use when someone says "our users went quiet", "design a win-back campaign", "how do I re-engage lapsed customers", "should we email people who haven't logged in for months", or lifecycle messaging has stopped landing with a lapsed segment. Do NOT use for recovering an unfinished checkout - use abandoned-cart-sequence instead. Do NOT use for diagnosing and fixing why active customers cancel - use churn-reduction instead. Do NOT use for building always-on onboarding or nurture flows - use email-drip-builder instead.

★ 25
SkillMedev
SkillMedev/skills

wikipedia-style

Writes neutral, verifiable, encyclopedic prose following Wikipedia's core content policies and manual of style - NPOV, inline citations, notability-backed claims, and a strict ban on promotional language. Use when someone asks "write this like a Wikipedia article", "draft a Wikipedia page for this company or person", "make this neutral and encyclopedic", or "why does my article draft keep getting rejected". Do NOT use for persuasive or opinion writing - use op-ed-writer instead; for thesis-driven academic papers, use academic-essay; for verifying claims in existing text, use fact-checker.

★ 25
SkillMedev
SkillMedev/skills

whitepapers

Structures and writes authoritative B2B whitepapers - a standalone executive summary, a data-sized problem statement, methodology, evidence-driven findings, recommendations, and a soft call to action - flagging every claim that needs a real citation. Use when a marketer asks "write a whitepaper on this topic", "turn our research into a lead-gen asset", "make this credible enough for executives", or a draft reads like a product pitch instead of analysis. Do NOT use for customer-story-driven proof - use case-study-builder instead; for policy audiences, use policy-brief.

★ 25
SkillMedev
SkillMedev/skills

white-space-analysis

Finds unmet market gaps by ranking jobs-to-be-done on importance versus satisfaction, overlaying them against current solutions and workarounds, and validating that each gap is real, winnable, and worth winning. Use when someone asks "where are the gaps in this market", "what's underserved here", "where should we play next", or is hunting for product, feature, or market-entry opportunities. Do NOT use for profiling competitors and building battle cards - use competitive-intelligence instead; for putting a dollar figure on an identified opportunity - use market-sizing instead; for extracting jobs-to-be-done from raw customer interviews - use jtbd-extractor instead.

★ 25