When using this library you still need to abide to Pexels Guidelines, which are explained on Pexels API page
PyPexels is available on PyPI and thus can be installed with
pip on most platforms.
$ pip install pypexels
This library depends on Requests to make - well - requests to the Pexels API. This additional package should be automatically installed at installation time, or you can simply install it by:
$ pip install requests
This example shows how the interaction with the paging functionality of the Pexels API is greatly abstracted and simplified. The code below will iterate through all popular images, and print attributes for each photo in there.
from pypexels import PyPexels api_key = 'YOUR_API_KEY' # instantiate PyPexels object py_pexels = PyPexels(api_key=api_key) popular_photos = py_pexels.popular(per_page=30) while popular_photos.has_next: for photo in popular_photos.entries: print(photo.id, photo.photographer, photo.url) # no need to specify per_page: will take from original object popular_photos = popular_photos.get_next_page()
Documentation is published on ReadTheDocs.
PyPexels v1.0.0b1 (beta, v1)
First release with wrappers around the two Pexels API for search and popular.
Note that using this library you still need to abide to Pexels Guidelines, which are explained on Pexels API page
PyPexels is released under the MIT License.