Skip to content

An asynchronous wrapper for Pexels API based on aiohttp, which additionally allows to download photos in any of avaliable resolutions.

Notifications You must be signed in to change notification settings

ggindinson/aiopypexels

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

An asynchronous wrapper for Pexels API based on aiohttp, which additionally allows to download photos in any of avaliable resolutions.

Installation

Install aiopypexels with pip

  pip install aiopypexels

Examples

Searching photos by query

from aiopypexels import AioPexels
from aiopypexels.types import PhotoSearchResponse

api = AioPexels(API_KEY)

async def get_photos_by_query(query: str) -> PhotoSearchResponse:
    response = await api.get_photos_by_query(query)
    print(response.total_results)  # 498

Getting photo by ID

from aiopypexels import AioPexels
from aiopypexels.types import Photo

api = AioPexels(API_KEY)

async def get_photo_by_id(id: int) -> Photo:
    photo = await api.get_photo_by_id(id)

Downloading photo by ID

from aiopypexels import AioPexels

api = AioPexels(API_KEY)

async def download_photo_by_id(query: str) -> PhotoSearchResponse:
    response = await api.download_photo_by_id(photo_id=9999, destination = './photos/test.jpeg', quality='original')

Links

Latest Version

Feedback

I would be very pleased for a star :-)

About

An asynchronous wrapper for Pexels API based on aiohttp, which additionally allows to download photos in any of avaliable resolutions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages