Skip to main content

A python library that can download from Unsplash and also manage user account

Project description

Unsplash Library

With this library you can download/upload/delete ... images with just one api key ✨

Installation

For installation, run the following command ⬇️

pip install unsplash_lib

Having issue with pip?

How can i get a unsplash api key?

Usage

For importing ⬇️

from unsplash_lib import Photos, Collection, Search

Photos explanation

First step: make an instance

Photos_instance = Photos('Your api key 🔑')

1 - random_photo

Download photos by search results. All parameters are Optional.

param Description
count: The number of photos to return. (Default: 1; max: 30)
query: Search terms.
topics: Public topic ID('s) to filter selection. If multiple, comma-separated
collections: Collection ID('s) to narrow search. Optional. If multiple, comma-separated.
content_filter: Limit results by content safety. (Optional; default: low). Valid values are low and high.
orientation: The orientation of the images to download.
DownloadImg: A boolean value indicating whether to download the images.
FileName: The name of the file to save the images to.
UPath: The path to the directory to save the images to.
_pass_errors : If there an error during the process. It won't break the program. It will just skip the process

2 - photos_statistics

Retrieve total number of downloads, views and likes of a single photo, as well as the historical breakdown of these stats in a specific timeframe (default is 30 days)

param Description
id: The public id of the photo. Required.
resolution: The frequency of the stats. (Optional; default: “days”)
quantity: The amount of for each stat. (Optional; default: 30)

Search Explanation

Search_photo

First step: make an instance

Photos_instance = Search('Your api key 🔑')

1 - search_photo

Download photos by search results.

param Description
query: Search terms.
page: The page number of the results to download. (Optional; default: 1)
per_page: The number of images to download per page. (Optional; default: 10)
order_by: The order in which to sort the results. (Optional; default: relevant). Valid values are latest and relevant.
collections: Collection ID('s) to narrow search. Optional. If multiple, comma-separated.
content_filter: Limit results by content safety. (Optional; default: low). Valid values are low and high.
color: Filter results by color. Optional. Valid values are: black_and_white, black, white, yellow, orange, red, purple, magenta, green, teal, and blue.
orientation: The orientation of the images to download.
DownloadImg: A boolean value indicating whether to download the images.
FileName: The name of the file to save the images to.
UPath: The path to the directory to save the images to.
_pass_errors : If there an error during the process. It won't break the program. It will just skip the process

2 - search_users

Search for a user and getting back the results as list that contain a dictionary. If the operation was successful, returns a list with dictionary inside that contain search info. Raise the error message if the operation was unsuccessful.

param Description
query : Search terms.
page : The page number of the results to download. (Optional; default: 1)
per_page : The number of images to download per page. (Optional; default: 10)
_pass_errors : If there an error during the process. It won't break the program. It will just skip the process

Collection Explanation

First step: make an instance

Photos_instance = Collection('Your api key 🔑')

1 - download_collection

Download a collection's photos.

param Description
ID : The collection's ID. Required.
page : Page number to retrieve. (Optional; default: 1)
per_page : Number of items per page. (Optional; default: 10)
orientation : Filter by photo orientation. Optional. (Valid values: landscape, portrait, squarish)
DownloadImg: A boolean value indicating whether to download the images.
FileName: The name of the file to save the images to.
UPath: The path to the directory to save the images to.
_pass_errors : If there an error during the process. It won't break the program. It will just skip the process

2 - get_collections_id

You can search for collection and get the collection's id, Then you can use it in download_collection() func to download images.

param Description
query : Search terms.
page: The page number of the results to download. (Optional; default: 1)
per_page: The number of images to download per page. (Optional; default: 10)
_pass_errors : If there an error during the process. It won't break the program. It will just skip the process

3 - create_collection

Create a new collection. This requires the write_collections permission. Enable it on Redirect URI & Permissions on your profile.

return True if the operation was successful and return error message if operation was unsuccessful

param Description
client_id: Your Unsplash Access Key.
title: The title of the collection. (Required.)
description: The collection's description. (Optional.)
private: Whether to make this collection private. (Optional; default false).
_pass_errors: If there an error during the process. It won't break the program. It will just skip the process

4 - update_collection

Update an existing collection belonging to the logged-in user. This requires the write_collections permission. Enable it on Redirect URI & Permissions on your profile.

return True if the operation was successful and return error message if operation was unsuccessful

param Description
ID : The collection's ID. Required.
title: The title of the collection. (Optional.)
description: The collection's description. (Optional.)
private: Whether to make this collection private. (Optional; default false).
_pass_errors: If there an error during the process. It won't break the program. It will just skip the process

4 - delete_collection

Delete a collection belonging to the logged-in user. This requires the write_collections permission. Enable it on Redirect URI & Permissions on your profile.

return True if the operation was successful and return error message if operation was unsuccessful

param Description
ID : The collection's ID. Required.
_pass_errors: If there an error during the process. It won't break the program. It will just skip the process

5 - add_to_collection

Add a photo to one of the logged-in user's collections. Requires the write_collections permission. Enable it on Redirect URI & Permissions on your profile.

returns True if the operation was successful and returns an error message if operation was unsuccessful. Note: If the photo is already in the collection, this action has no effect.

param Description
client_id: Your Unsplash Access Key.
collection_id : The collection's ID. Required.
photo_id : The photo's ID that you want to add it. Required.
_pass_errors: If there an error during the process. It won't break the program. It will just skip the process

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unsplash_lib-0.0.3.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

unsplash_lib-0.0.3-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file unsplash_lib-0.0.3.tar.gz.

File metadata

  • Download URL: unsplash_lib-0.0.3.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for unsplash_lib-0.0.3.tar.gz
Algorithm Hash digest
SHA256 aa635e0583ec7537b2b6761aae00d097297477837ee2b07e9f88206ec6299c7b
MD5 b1f40d0597b787c28fbf0c275f5e0359
BLAKE2b-256 dcdbc4b5b6e52f1f37a3c53dd9873f3af033d567a4bb10857dea5e37ed0c95b5

See more details on using hashes here.

File details

Details for the file unsplash_lib-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for unsplash_lib-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e25dfb9124e87930aa0b84e9821e4f9e41eb8630b44817ecefb1a799a8f47a3b
MD5 66912a23f4a843d344de7d7871c15d3b
BLAKE2b-256 6d305d521525e8b6d3c83bd4de45b694e79fdd27af237caef63b9c3f1410601e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page