Skip to content
Fox photography representing the Public APIs section

Public APIs

Free Image APIs

Where to get photographs and placeholder images programmatically - and the attribution requirements that most tutorials quietly skip.

  • 5 providers
  • Licensing explained
  • Placeholder options

The APIs covered on this page

Image licensing is the part that bites later. Free to use is not the same as free of obligations - check attribution and redistribution rules on each provider's own terms page before shipping.

Unsplash API

Documentation

High quality photography with a documented developer API.

Authentication
Free developer key (Client-ID) required
Pricing
Free demo tier with a low hourly limit; production access requires approval
Endpoint
GET /search/photos

Example request

curl -H "Authorization: Client-ID YOUR_ACCESS_KEY" \
  "https://api.unsplash.com/search/photos?query=fox&per_page=1"

Example response

{
  "total": 4213,
  "results": [
    {
      "id": "abc123",
      "urls": { "regular": "https://images.unsplash.com/photo-...?w=1080" },
      "user": { "name": "Photographer Name", "links": { "html": "https://unsplash.com/@handle" } }
    }
  ]
}

Good for

  • Editorial imagery for content sites
  • Search-driven image pickers
  • Design mockups and prototypes

Limitations

  • Demo tier is rate limited to a small number of requests per hour
  • Attribution to the photographer and Unsplash is required
  • Hotlinking rules and download tracking apply

Pexels API

Documentation

Photos and stock video with a straightforward key-based API.

Authentication
Free API key required in the Authorization header
Pricing
Free tier with hourly and monthly request limits
Endpoint
GET /search

Example request

curl -H "Authorization: YOUR_API_KEY" \
  "https://api.pexels.com/v1/search?query=office&per_page=1"

Example response

{
  "total_results": 8000,
  "photos": [
    { "id": 1181244, "photographer": "Photographer Name", "src": { "large": "https://images.pexels.com/photos/..." } }
  ]
}

Good for

  • Content sites needing varied imagery
  • Video backgrounds
  • Prototype galleries

Limitations

  • Key required for every request
  • Attribution requested by the license
  • Rate limits on the free tier

Lorem Picsum

Documentation

Random real photographs by URL, sized on demand - no key at all.

Authentication
None
Pricing
Free
Endpoint
GET /{width}/{height}

Example request

curl -L "https://picsum.photos/600/400" --output sample.jpg

Example response

HTTP/2 302
location: https://fastly.picsum.photos/id/237/600/400.jpg

Good for

  • Filling a grid layout during development
  • Testing image loading and aspect ratios
  • Demos and screenshots

Limitations

  • You cannot choose the subject
  • Not intended for production traffic
  • Redirects, so follow them in your HTTP client

Pixabay API

Documentation

Photos, illustrations and vectors under a permissive content license.

Authentication
Free API key required
Pricing
Free tier with rate limits
Endpoint
GET /

Example request

curl "https://pixabay.com/api/?key=YOUR_KEY&q=mountain&image_type=photo&per_page=3"

Example response

{
  "total": 10432,
  "hits": [
    { "id": 195893, "webformatURL": "https://pixabay.com/get/....jpg", "user": "Contributor" }
  ]
}

Good for

  • Illustrations and vectors as well as photos
  • Broad subject coverage
  • Blog and article imagery

Limitations

  • Caching of results is required by their terms
  • Hotlinking restrictions apply
  • Quality is more variable than curated libraries

Placehold.co

Documentation

Generated placeholder rectangles with custom size, colours and text.

Authentication
None
Pricing
Free
Endpoint
GET /{size}/{bg}/{fg}

Example request

curl "https://placehold.co/600x400/4A1521/FFC875?text=Fox+Is+Happy" --output placeholder.png

Example response

A 600x400 PNG with the requested colours and label.

Good for

  • Wireframes and layout tests
  • Documentation screenshots
  • Empty states during development

Limitations

  • Not photographs - generated graphics only
  • External dependency in your markup
  • Replace before launch

Working with image APIs without a licensing problem

Images are the one category where the technical integration is easy and the legal detail is not. Getting a photo onto a page takes ten minutes; understanding whether you are allowed to use it that way takes slightly longer and matters considerably more.

Free to use is not the same as no obligations

Most free photo libraries publish a custom license rather than a standard one. They typically allow commercial use and modification, and typically prohibit selling unaltered copies, using images in a way that implies endorsement, or building a competing stock library. Several also require attribution as a condition of API access even when the license itself only requests it. Read the API terms and the content license - they are often two separate documents saying different things.

Attribution done properly

Where attribution is required, it usually means a visible credit naming the photographer and linking back to their profile and to the platform. A credit buried in a site-wide footer rarely satisfies this. Plan for it in the design: a small caption under the image, or a line in the page footer that names each photo used on that page. It is a two-line component and it removes an entire category of risk.

Performance is the other half of the job

  • Request the size you will display. Most of these APIs accept width parameters - fetching a 4000px original for a 400px thumbnail wastes most of your page weight.
  • Use modern formats. WebP and AVIF are dramatically smaller than JPEG at equivalent quality, and most providers can serve them.
  • Set explicit dimensions. Images without a reserved space cause layout shift, which is both irritating and a ranking signal.
  • Lazy-load anything below the fold, and load your main image eagerly so it is not delayed.
  • Write real alt text. Describe what the image shows and why it is there, not "image" or a keyword list.

Hotlinking, caching and the rules around them

Providers differ sharply here. Some require you to hotlink their CDN so they can count views and pay contributors. Others require you to cache images on your own infrastructure and explicitly forbid hotlinking. Doing the opposite of what a provider asks is the most common way developers end up with their API key revoked, and it is entirely avoidable by reading one page of documentation.

If you cache, respect any expiry requirements and keep a link back to the source record so you can refresh or remove an image if it is withdrawn.

Placeholders belong in development only

Generated placeholder services are excellent for building layouts, and every one of them becomes a third-party dependency the moment your site goes live. If the service has an outage, your production page shows broken images. Replace placeholders with real assets before launch, and search your codebase for the placeholder domain as part of your release checklist.

Resizing and format parameters

Most photo CDNs accept transformation parameters in the URL: width, height, crop mode, quality and output format. That is where the real performance win lives, because a single parameter can turn a two megabyte original into a sixty kilobyte thumbnail without any processing on your side. Read the provider's parameter documentation before writing your own image pipeline - you rarely need one. Just be careful to generate a fixed set of sizes rather than a new URL for every viewport width, or you will miss the CDN cache on almost every request.

Related resources

For the general checklist on evaluating any provider, see Public APIs for Developers. If you are assembling a project that needs both pictures and records, Free JSON APIs covers the data side, and the Frontend Developer Roadmap includes the image performance work that separates a fast site from a slow one.

Frequently asked questions

Do I have to credit photographers when using a free image API?

Often yes. Several providers require attribution as a condition of API access even where the content license only requests it. Check both the API terms and the license before you publish.

Can I use placeholder image services in production?

You should not. They are development tools with no uptime commitment, so an outage leaves broken images on your live site. Replace them with real assets before launch.

Keep going

Related resources

Hand-picked pages that pair well with this one.

Public APIs

Free JSON APIs

Sample and real JSON endpoints for prototypes, tutorials, portfolio projects and interface testing.

Open

Public APIs

Public APIs for Developers

Where to find public APIs, how to judge one before you build on it, and five reliable starting points.

Open

Roadmaps

Frontend Developer Roadmap

A realistic path from first HTML page to employable frontend developer, in the order that actually works.

Open