mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2024-12-27 22:50:42 -05:00
20 lines
511 B
Python
20 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()
|