mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2024-12-29 07:10:44 -05:00
21 lines
511 B
Python
21 lines
511 B
Python
|
import requests
|
||
|
|
||
|
|
||
|
class Pictures:
|
||
|
def __init__(self, token) -> None:
|
||
|
self.url = "https://api.pexels.com"
|
||
|
|
||
|
self.parameters = {"orientation": "square", "size": "small"}
|
||
|
self.headers = {"Authorization": f"{token}"}
|
||
|
|
||
|
def search(self, topic):
|
||
|
|
||
|
search_path = "/v1/search"
|
||
|
search_params = {**self.parameters, "query": topic}
|
||
|
|
||
|
r = requests.get(
|
||
|
url=self.url + search_path, params=search_params, headers=self.headers
|
||
|
)
|
||
|
|
||
|
return r.json()
|