ggindinson / aiopypexels

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.


Languages

Language:Python 100.0%