無法取得 Pexels API 金鑰?10 分鐘轉用 Pexafy,仍可搜尋 Pexels 相片
Can't get a Pexels API key? Switch to Pexafy in 10 minutes (Pexels photos included)
Pexels 暫停發放新 API 金鑰後,Pexafy 開發者提供遷移指南,示範如何在 10 分鐘內轉用 Pexafy,並繼續搜尋 Pexels 相片。Pexafy 可用單一請求搜尋多個相片庫,支援 100 多種語言的語意搜尋,並附攝影師署名資料。免費方案可建立 API 金鑰,並提供欄位轉換示例及託管 MCP 伺服器。
Since 30 September, the Pexels API page opens with one line: "New API key issuance is currently paused." No form, no waiting list, no date. If you were about to build on Pexels, onboard a teammate, or open-source a project that asks for a PEXELS_API_KEY, you are stuck.
Full disclosure: I build Pexafy, and this post is a migration guide to it. I'll show you the switch step by step, and I'll be straight about what it changes and what it doesn't.
What Pexels changed
- No new keys: "New API key issuance is currently paused." (pexels.com/api, and the help-center article How do I get an API key?)
- No higher limits either: "API rate limit increases are currently paused." Keys already issued stay at the default 200 requests an hour and 20,000 a month.
- Since when: the help-center texts were edited on 30 September 2026, between 19:04 and 19:15 UTC. Still up on 17 October, with no reason and no date for reopening.
Developers are already rewriting around it. In the first two weeks of October, 20 public GitHub issues and pull requests cite the pause as the reason for a change. Half of them moved to Pixabay, which means a different catalogue, plus Pixabay's own rules: download and re-host the images, cache API responses for 24 hours.
There is a shorter path.
Why Pexafy is the easiest place to land
1. You get a key today. Sign up with Google, GitHub or an email address, create a key in the dashboard, and the first call works. Free plan, no card, no use-case form to fill in, no review to wait for.
2. The Pexels photos are still there. Pexafy indexes millions of Pexels photos, next to Unsplash, Pixabay and other free-to-use libraries. One request searches all of them. If your product's look is built on Pexels, add source=Pexels and you only get Pexels photos: same library, same photographers.
3. You search by meaning, not by tags. Describe the scene in a full sentence, in any of 100+ languages. Here is the top result for "a glowing neon no vacancy sign at night", a Pexels photo:
{
"photo_id": "019e1cec-493e-75c9-93fd-b530c28ed7e8",
"source": "Pexels",
"photographer_full_name": "Prime Cinematics",
"source_image_url": "https://www.pexels.com/photo/no-vacancy-neon-light-sign-2057184",
"urls": { "regular": "https://images.pexels.com/photos/2057184/pexels-photo-2057184.jpeg?w=1280", "…": "…" },
"attribution": { "plain": "Photo by Prime Cinematics on Pexels (https://pexafy.com/legal/licenses/#pexels)", "html": "…" }
}
With keyword search, every extra word is one more tag the photo probably doesn't have. With Pexafy, the extra words make the match better.
4. Credit is built in. Every result carries the photographer, the link to the photo's page on its library, and a ready-made credit line in HTML and plain text. Crediting is one line of code.
5. Room to grow without asking. Pexels has paused limit increases. Pexafy's plans are published on the pricing page and you upgrade from the dashboard, no email to write.
6. Ready for AI agents. Search by image (send a photo, get look-alikes from every library), and a hosted MCP server so Claude, ChatGPT, Cursor, VS Code and other agents can search and credit photos by themselves. Setup per client: pexafy.com/mcp.
Switch in 10 minutes
Step 1: get a key
Create a free account and an API key. Put it in an environment variable, PEXAFY_API_KEY, on your server. Never in browser code.
Step 2: change one request
# Before: Pexels
curl -H "Authorization: $PEXELS_API_KEY" \
"https://api.pexels.com/v1/search?query=neon+sign&per_page=15"
# After: Pexafy (describe what you want to see; add &source=Pexels to keep Pexels only)
curl -H "X-Api-Key: $PEXAFY_API_KEY" \
"https://api.pexafy.com/api/v1/search/photos?q=a+glowing+neon+no+vacancy+sign+at+night&per_page=15"
Step 3: rename the fields you read
| Pexels | Pexafy | Note |
|---|---|---|
Authorization: <key> |
X-Api-Key: <key> |
Header name only |
query |
q |
Up to 500 characters; full sentences work best |
orientation, color
|
orientation, color_name or color_hex
|
Same orientation values |
locale |
— | Not needed: any language, one index |
page, next_page
|
cursor, pagination.next_cursor
|
Cursor pagination; per_page up to 100 |
photos[] |
data[] |
|
id |
photo_id |
A string, not an integer |
src.original · large2x · large · medium · small
|
urls.full · large · regular · small · thumb
|
Closest sizes, largest to smallest |
url |
source_image_url |
The photo's page on its library |
photographer, photographer_url
|
photographer_full_name, photographer_url
|
|
avg_color |
color_hex |
Plus a named color_name
|
alt |
alt_description |
|
| — |
source, license_type, attribution
|
New: where it comes from, its licence, a ready credit line |
Step 4: or keep your Pexels-shaped code untouched
If your front end already reads photos[].src.large, don't touch it. Put this adapter on your server: it calls Pexafy and returns the Pexels shape, plus the two fields Pexels never gave you.
// pexafy-as-pexels.mjs — call Pexafy, get Pexels-shaped JSON back (Node 18+).
// Your front end keeps reading photos[].src.large, photographer, url…
const ENDPOINT = "https://api.pexafy.com/api/v1/search/photos";
export async function searchPhotos(query, { perPage = 15, cursor, onlyPexels = false } = {}) {
const url = new URL(ENDPOINT);
url.searchParams.set("q", query);
url.searchParams.set("per_page", String(perPage));
if (cursor) url.searchParams.set("cursor", cursor);
if (onlyPexels) url.searchParams.set("source", "Pexels"); // same library, same photographers
const res = await fetch(url, { headers: { "X-Api-Key": process.env.PEXAFY_API_KEY } });
if (!res.ok) throw new Error(`Pexafy ${res.status}: ${await res.text()}`);
const { data, pagination } = await res.json();
return {
per_page: perPage,
next_cursor: pagination?.next_cursor ?? null, // replaces Pexels' next_page URL
photos: data.map((p) => ({
id: p.photo_id,
width: p.width,
height: p.height,
url: p.source_image_url,
photographer: p.photographer_full_name,
photographer_url: p.photographer_url,
avg_color: p.color_hex,
alt: p.alt_description,
src: {
original: p.urls.full,
large2x: p.urls.large,
large: p.urls.regular,
medium: p.urls.small,
small: p.urls.thumb,
tiny: p.urls.thumb,
},
source: p.source, // "Pexels", "Unsplash", "Pixabay"…
attribution: p.attribution, // { html, plain }: render it as-is
})),
};
}
Step 5: already have a Pexels key? Use Pexafy as overflow
Keep your key: you can't create another one, and you can't rotate it yourself. Let it answer first, and let Pexafy answer when Pexels says 429:
import os, requests
def search(query, per_page=15):
"""Pexels first while your key has quota; Pexafy when Pexels answers 429."""
r = requests.get(
"https://api.pexels.com/v1/search",
params={"query": query, "per_page": per_page},
headers={"Authorization": os.environ["PEXELS_API_KEY"]},
timeout=10,
)
if r.status_code != 429: # anything but "over your limit": keep Pexels' answer
r.raise_for_status()
return [(p["src"]["large"], f"Photo by {p['photographer']} on Pexels") for p in r.json()["photos"]]
r = requests.get(
"https://api.pexafy.com/api/v1/search/photos",
params={"q": query, "per_page": per_page},
headers={"X-Api-Key": os.environ["PEXAFY_API_KEY"]},
timeout=10,
)
r.raise_for_status()
return [(p["urls"]["regular"], p["attribution"]["plain"]) for p in r.json()["data"]]
Or flip it: Pexafy first (one call already covers Pexels and the other libraries), your Pexels key as the backup.
Both snippets were tested as printed (Node 20 and Python 3.12) against recorded responses, including the error paths.
What doesn't change
- Licences. Every photo keeps the licence of the library it comes from. Pexafy is a search engine and API over those libraries, not the rights holder.
- Credit. Show the credit line. It costs one line of code and it's how photographers get recognised.
- Independence. Pexafy isn't affiliated with Pexels. The photos you find through it link back to their original pages.
- Quotas. The free plan has a monthly quota and a per-minute rate limit; the pricing page lists every plan.
Try it
Get a free API key, run Step 2, and your first search answers before your coffee cools. The full reference (filters by orientation, colour, licence and source, search by image, MCP setup) is in the docs.
Were you hit by the Pexels pause? Tell me in the comments what you're migrating, and I'll help you map it.
Sources, read on 17 October 2026: Pexels API · How do I get an API key? · How do I get unlimited requests? · How do I change my API key? · Pixabay API docs · Pexafy API docs · GitHub search of public issues and pull requests citing the pause (1 to 16 October).
Cover photo by Shane Rounce on Unsplash, the first result Pexafy returns for "a frustrated developer with a hand in his hair, staring at his laptop in a dim café at night".
來源:DEV Community · dev.to