7 from .params
import params
8 from .query
import query
as queryCore
9 from .image
import image
as imageCore
10 from .video
import video
as videoCore
18 def __init__(self, apiKey, host='https://pixabay.com/api/
'): 42 def query(self, query='', lang='en', orientation='all', perPage=50, order="popular", safeSearch=False, minWidth=0, minHeight=0, editorsChoice=False, category='all', colors='all', image_type='all'):
48 orientation = orientation,
51 safeSearch = safeSearch,
53 minHeight = minHeight,
54 editorsChoice = editorsChoice,
57 image_type = image_type
60 return queryCore(param)
67 uri =
"{host}?key={api}&id={id}".format(
75 if (r.status_code != 200):
76 raise ValueError(
'Pixabay return status code != 200 for uri', uri,
'Invalid parameters?')
78 return imageCore(r.json()[
'hits'][0])
85 uri =
"{host}videos/?key={api}&id={id}".format(
93 if (r.status_code != 200):
94 raise ValueError(
'Pixabay return status code != 200 for uri', uri,
'Invalid parameters?')
96 return videoCore(r.json()[
'hits'][0])
99 def queryVideo(self, query='', lang='en', orientation='all', perPage=50, order="popular", safeSearch=False, minWidth=0, minHeight=0, editorsChoice=False, category='all', colors='all'):
101 host = self.
host+
'videos/',
105 orientation = orientation,
108 safeSearch = safeSearch,
110 minHeight = minHeight,
111 editorsChoice = editorsChoice,
116 return queryCore(param)
def query(self, query='', lang='en', orientation='all', perPage=50, order="popular", safeSearch=False, minWidth=0, minHeight=0, editorsChoice=False, category='all', colors='all', image_type='all')
Make search qvery on API.
def image(self, iid)
Get image by ID.
def __init__(self, apiKey, host='https://pixabay.com/api/')
Init function.