pu
python-unsplash
pypi i python-unsplash
pu

python-unsplash

Python wrapper for the Unsplash API.

by Yakup Adaklı

1.1.0 (see all)License:MIT
pypi i python-unsplash
Readme

python-unsplash

A library that provides a Python interface to the Unsplash API.

Installation

The easiest way to install the latest version is by using pip/easy_install to pull it from PyPI:

pip install python-unsplash

You may also use Git to clone the repository from Github and install it manually:

git clone https://github.com/yakupadakli/python-unsplash.git
cd python-unsplash
python setup.py install

Python 2.7, 3.4, 3.5 and 3.6, is supported for now.

Usage

Code is required for authenticated actions

from unsplash.api import Api
from unsplash.auth import Auth

client_id = ""
client_secret = ""
redirect_uri = ""
code = ""

auth = Auth(client_id, client_secret, redirect_uri, code=code)
api = Api(auth)

User

User me
Require authentication.

Get the user’s profile.

api.user.me()
User update
Require authentication.

Update the current user’s profile

paramDescription
usernameUsernameoptional
first_nameFirst name.optional
last_nameLast name.optional
emailEmail.optional
urlPortfolio/personal URL.optional
bioAbout/bio.optional
instagram_usernameFirstoptional
first_nameFirstoptional
first_nameInstagram username.optional
kwargs = {"first_name": "Yakup"}

api.user.update(**kwargs)
User get

Retrieve public details on a given user.

paramDescription
usernameUsernamerequired
wProfile image width in pixels.optional
hProfile image height in pixels.optional
api.user.get("yakupa")
User portfolio

Retrieve a single user’s portfolio link.

paramDescription
usernameUsernamerequired
api.user.portfolio("yakupa")
User photos

Get a list of photos uploaded by a user.

paramDescription
usernameUsernamerequired
pagePage number to retrieve. (default: 1)optional
per_pageNumber of items per page. (default: 10)optional
order_byHow to sort the photos. Optional. (Valid values: latest, oldest, popular; default: latest)optional
statsShow the stats for each user’s photo. (default: false)optional
resolutionThe frequency of the stats. (default: “days”)optional
quantityThe amount of for each stat. (default: 30)optional
api.user.portfolio("yakupa")
User likes

Get a list of photos liked by a user.

paramDescription
usernameUsernamerequired
pagePage number to retrieve. (default: 1)optional
per_pageNumber of items per page. (default: 10)optional
order_byHow to sort the photos. Optional. (Valid values: latest, oldest, popular; default: latest)optional
api.user.likes("yakupa")
User collections

Get a list of collections created by the user.

paramDescription
usernameUsernamerequired
pagePage number to retrieve. (default: 1)optional
per_pageNumber of items per page. (default: 10)optional
api.user.collections("yakupa")

Photo

Photo all

Get a single page from the list of all photos.

paramDescription
pagePage number to retrieve. (default: 1)optional
per_pageNumber of items per page. (default: 10)optional
order_byHow to sort the photos. Optional. (Valid values: latest, oldest, popular; default: latest)optional
api.photo.all()
Photo curated

Get a single page from the list of the curated photos.

paramDescription
pagePage number to retrieve. (default: 1)optional
per_pageNumber of items per page. (default: 10)optional
order_byHow to sort the photos. Optional. (Valid values: latest, oldest, popular; default: latest)optional
api.photo.curated()
Photo get

Get a single page from the list of the curated photos.

paramDescription
idThe photo’s ID.required
wImage width in pixels.optional
hImage height in pixels.optional
rect4 comma-separated integers representing x, y, width, height of the cropped rectangle.optional
api.photo.get("Dwu85P9SOIk")
Photo random

Retrieve a single random photo, given optional filters.

Note: You can’t use the collections and query parameters in the same request

Note: When supplying a count parameter - and only then - the response will be an array of photos, even if the value of count is 1.

paramDescription
collectionsPublic collection ID(‘s) to filter selection. If multiple, comma-separatedoptional
featuredLimit selection to featured photos.optional
usernameLimit selection to a single user.optional
queryLimit selection to photos matching a search term.optional
wImage width in pixels.optional
hImage height in pixels.optional
orientationFilter search results by photo orientation. Valid values are landscape, portrait, and squarish.optional
countThe number of photos to return. (Default: 1; max: 30)optional
api.photo.random()
Photo stats

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

paramDescription
idThe public id of the photo.required
resolutionThe frequency of the stats.optional
quantityThe amount of for each stat.optional
api.photo.stats("LF8gK8-HGSg")
Photo like

Like a photo on behalf of the logged-in user. This requires the write_likes scope.

Note: This action is idempotent; sending the POST request to a single photo multiple times has no additional effect.

paramDescription
idThe photo’s ID.required
api.photo.like("LF8gK8-HGSg")
Photo unlike

Remove a user’s like of a photo.

Note: This action is idempotent; sending the DELETE request to a single photo multiple times has no additional effect.

paramDescription
idThe photo’s ID.required
api.photo.unlike("LF8gK8-HGSg")
Search photos

Get a single page of photo results for a query.

paramDescription
querySearch terms.required
pagePage number to retrieve.optional
per_pageNumber of items per page.optional
collectionsCollection ID(‘s) to narrow search. If multiple, comma-separated.optional
api.search.photos("office")
Search collections

Get a single page of collection results for a query.

paramDescription
querySearch terms.required
pagePage number to retrieve.optional
per_pageNumber of items per page.optional
api.search.collections("office")
Search users

Get a single page of user results for a query.

paramDescription
querySearch terms.required
pagePage number to retrieve.optional
per_pageNumber of items per page.optional
api.search.users("yakupa")

Collections

Collections all

Get a single page from the list of all collections.

paramDescription
pagePage number to retrieve.optional
per_pageNumber of items per page.optional
api.collection.all()

Get a single page from the list of featured collections.

paramDescription
pagePage number to retrieve.optional
per_pageNumber of items per page.optional
api.collection.featured()
Collections curated

Get a single page from the list of curated collections.

paramDescription
pagePage number to retrieve.optional
per_pageNumber of items per page.optional
api.collection.curated()
Collections get

Retrieve a single collection. To view a user’s private collections, the read_collections scope is required.

paramDescription
idThe collections’s ID.required
api.collection.get("547584")
Collections get curated

Retrieve a single curated collection. To view a user’s private collections, the read_collections scope is required.

paramDescription
idThe curated collections’s ID.required
api.collection.get_curated("547584")
Collections photos

Retrieve a collection’s photos.

paramDescription
idThe collections’s ID.required
pagePage number to retrieve.optional
per_pageNumber of items per page.optional
api.collection.photos("547584")
Collections curated photos

Retrieve a curated collection’s photos.

paramDescription
idThe curated collections’s ID.required
pagePage number to retrieve.optional
per_pageNumber of items per page.optional
api.collection.curated_photos("547584")

Retrieve a list of collections related to this one.

paramDescription
idThe collection’s ID.required
api.collection.related("547584")
Collections create

Create a new collection. This requires the write_collections scope.

paramDescription
titleThe title of the collection.required
descriptionThe collection’s description.optional
privateWhether to make this collection private.optional
api.collection.create("New Test Collection")
Collections update

Update an existing collection belonging to the logged-in user. This requires the write_collections scope.

paramDescription
idThe collection’s ID.required
titleThe title of the collection.optional
descriptionThe collection’s description.optional
privateWhether to make this collection private.optional
api.collection.update("547584")
Collections delete

Delete a collection belonging to the logged-in user. This requires the write_collections scope.

paramDescription
idThe collection’s ID.required
api.collection.delete("547584")
Collections add photo

Add a photo to one of the logged-in user’s collections. Requires the write_collections scope.

paramDescription
collection_idThe collection’s ID.required
photo_idThe photo’s ID.required
api.collection.add_photo("547584", "KSap1iDftvQ")
Collections remove photo

Remove a photo from one of the logged-in user’s collections. Requires the write_collections scope.

paramDescription
collection_idThe collection’s ID.required
photo_idThe photo’s ID.required
api.collection.remove_photo("547584", "KSap1iDftvQ")

Stats

Stats total

Get a list of counts for all of Unsplash.

api.stat.total()
Stats total

Get the overall Unsplash stats for the past 30 days.

api.stat.month()

GitHub Stars

111

LAST COMMIT

2yrs ago

MAINTAINERS

1

CONTRIBUTORS

4

OPEN ISSUES

3

OPEN PRs

1
VersionTagPublished
1.1.0
2yrs ago
1.0.1
4yrs ago
1.0.0a2
5yrs ago
1.0.0a1
6yrs ago
No alternatives found
No tutorials found
Add a tutorial