Stock Fetcher
Stock Fetcher is a standalone, lightweight Python library for fetching copyright-free images and photos from various popular sources such as Pexels, Pixabay, Unsplash, and Flickr.
Built with a clean architecture and type hints, it makes retrieving high-quality stock images across multiple providers simple and consistent.
Features
- Unified Interface: Fetch images using a consistent API regardless of the backend source.
- Multiple Providers: Out-of-the-box support for Pexels, Pixabay, Unsplash, and Flickr.
- Type Hinting: Fully type-hinted for better IDE integration.
- Error Handling: Standardized
FetcherErrorwrapper for easy debugging and exception catching.
Installation
You can install the core package directly from the source directory:
pip install .
Optional Features (Extras)
Stock Fetcher supports CLI and MCP integrations as optional features. You can install them by adding extras:
-
CLI Support: To use the command-line interface, install with
cli:pip install '.[cli]'
👉 Read the CLI Manual for detailed usage and commands.
-
MCP Server: To expose this package as a tool for AI agents (like Claude), install with
mcp:pip install '.[mcp]'
👉 Read the MCP Manual for Claude configuration instructions.
-
Install All: To install both features at once:
pip install '.[all]'
Quick Start
Import the client for the platform you want to use. You must provide an API key for Pexels, Pixabay, and Unsplash. (Flickr uses a custom scrapper and does not require an API key in this implementation).
Using Pixabay
from stock_fetcher import PixabayClient, FetcherError
client = PixabayClient(api_key="YOUR_PIXABAY_API_KEY")
try:
images = client.search_images(query="nature", per_page=5)
for img in images:
print(f"[{img['source']}] Original URL: {img['url_original']}")
except FetcherError as e:
print(f"Error: {e}")
Using Unsplash
from stock_fetcher import UnsplashClient, FetcherError
client = UnsplashClient(api_key="YOUR_UNSPLASH_ACCESS_KEY")
try:
images = client.search_images(query="architecture", per_page=3)
for img in images:
print(f"[{img['source']}] ID: {img['id']} - URL: {img['url_original']}")
except FetcherError as e:
print(f"Error: {e}")
Using Pexels
from stock_fetcher import PexelsClient
client = PexelsClient(api_key="YOUR_PEXELS_API_KEY")
images = client.search_images(query="technology", per_page=3)
Using Flickr
from stock_fetcher import FlickrClient
client = FlickrClient() # No API key required for the scrapper
images = client.search_images(query="vintage cars", per_page=5)
Disclaimer & Licensing
[!WARNING] Copyright & Usage Notice While this library fetches images from platforms known for providing "royalty-free" or "copyright-free" content, you are solely responsible for ensuring that your specific use-case complies with the respective platform's licensing terms.
- Pexels / Pixabay / Unsplash: Generally allow free commercial and non-commercial use, but strictly prohibit selling unaltered copies, building competing services, or using identifiable people/trademarks in an offensive manner.
- Flickr: Images are governed by various Creative Commons licenses. This library attempts to filter for permissive licenses, but you must manually verify the exact license of the image before any commercial use.
The authors and maintainers of
stock-fetcherassume no liability for any copyright infringement, trademark disputes, or legal issues that may arise from using the fetched images. Always refer to the original image source link (url_page) to review the precise license details.
Error Handling
The library provides a custom FetcherError exception to handle API failures uniformly.
from stock_fetcher import PexelsClient, FetcherError
client = PexelsClient(api_key="INVALID_KEY")
try:
client.search_images("test")
except FetcherError as e:
print(f"A fetching error occurred: {e}")
Metadata
Release files for stock-fetcher 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| stock_fetcher-0.2.0.tar.gz | 13.3 kB | With provenance | Details for stock_fetcher-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stock_fetcher-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for stock_fetcher-0.2.0-py3-none-any.whl |
Total release size: 29.0 kB
Release files / stock_fetcher-0.2.0.tar.gz
| Download URL | stock_fetcher-0.2.0.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f60001854de5c80fb2bf50d5d28b1f8b62a63001f2499060a754f46d42727af8
|
|
BLAKE2b-256 checksum How to use checksums |
f18161c912175d41c90bbff0cae28ba6cc78e2572b0e43004597ae1930c3afc3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 19, 2026.
Transparency logRelease files / stock_fetcher-0.2.0-py3-none-any.whl
| Download URL | stock_fetcher-0.2.0-py3-none-any.whl |
|---|---|
| Size | 15.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1eb296b4dc51c506cd33d6162f53eea127f8baeda32b8320e181eb896906f40f
|
|
BLAKE2b-256 checksum How to use checksums |
22995391ad370b918d1acff882678fc583adbec888c6370f0b967c6d4c8b1937
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 19, 2026.
Transparency logSecurity for stock-fetcher 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for stock_fetcher-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 19, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.