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.
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.