A Python library for fetching copyright-free images from various sources like Pexels, Pixabay, Unsplash, and Flickr.
Project description
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}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stock_fetcher-0.2.0.tar.gz.
File metadata
- Download URL: stock_fetcher-0.2.0.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f60001854de5c80fb2bf50d5d28b1f8b62a63001f2499060a754f46d42727af8
|
|
| MD5 |
5db848b160a1b9070fd000b1ed304468
|
|
| BLAKE2b-256 |
f18161c912175d41c90bbff0cae28ba6cc78e2572b0e43004597ae1930c3afc3
|
Provenance
The following attestation bundles were made for stock_fetcher-0.2.0.tar.gz:
Publisher:
cd.yml on AtaCanYmc/stock-fetcher
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stock_fetcher-0.2.0.tar.gz -
Subject digest:
f60001854de5c80fb2bf50d5d28b1f8b62a63001f2499060a754f46d42727af8 - Sigstore transparency entry: 1874448428
- Sigstore integration time:
-
Permalink:
AtaCanYmc/stock-fetcher@09b9f6a989de1c2430303cd96672b5f66fd5eea8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/AtaCanYmc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@09b9f6a989de1c2430303cd96672b5f66fd5eea8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file stock_fetcher-0.2.0-py3-none-any.whl.
File metadata
- Download URL: stock_fetcher-0.2.0-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1eb296b4dc51c506cd33d6162f53eea127f8baeda32b8320e181eb896906f40f
|
|
| MD5 |
263b079f3b9b6855f098f8457f24b00f
|
|
| BLAKE2b-256 |
22995391ad370b918d1acff882678fc583adbec888c6370f0b967c6d4c8b1937
|
Provenance
The following attestation bundles were made for stock_fetcher-0.2.0-py3-none-any.whl:
Publisher:
cd.yml on AtaCanYmc/stock-fetcher
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stock_fetcher-0.2.0-py3-none-any.whl -
Subject digest:
1eb296b4dc51c506cd33d6162f53eea127f8baeda32b8320e181eb896906f40f - Sigstore transparency entry: 1874448471
- Sigstore integration time:
-
Permalink:
AtaCanYmc/stock-fetcher@09b9f6a989de1c2430303cd96672b5f66fd5eea8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/AtaCanYmc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@09b9f6a989de1c2430303cd96672b5f66fd5eea8 -
Trigger Event:
release
-
Statement type: