Get a list of URLs of GIFs based on a given query..
(query: str, api_key: str = giphy_api_key)
| 14 | |
| 15 | |
| 16 | def get_gifs(query: str, api_key: str = giphy_api_key) -> list: |
| 17 | """ |
| 18 | Get a list of URLs of GIFs based on a given query.. |
| 19 | """ |
| 20 | formatted_query = "+".join(query.split()) |
| 21 | url = f"https://api.giphy.com/v1/gifs/search?q={formatted_query}&api_key={api_key}" |
| 22 | gifs = httpx.get(url, timeout=10).json()["data"] |
| 23 | return [gif["url"] for gif in gifs] |
| 24 | |
| 25 | |
| 26 | if __name__ == "__main__": |