Skip to content

Commit 0ff377b

Browse files
Update giphy_trending.py
1 parent 99ceca4 commit 0ff377b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

consuming-apis-python/giphy_trending.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import requests
22

3-
# Replace the following with the API key generated.
4-
api_key = "API_KEY"
3+
# REPLACE the following with the API key you generated.
4+
API_KEY = "REPLACE_DEMO_API_KEY"
5+
56
endpoint = "https://api.giphy.com/v1/gifs/trending"
6-
params = {"api_key": api_key, "limit": 3, "rating": "g"}
77

8+
# In the query parameters you can define:
9+
# 1. The number of GIFs to return using the `limit` parameter.
10+
# 2. The accepted rating of the GIFs returned using the `rating` parameter: https://developers.giphy.com/docs/optional-settings#rating
11+
params = {"api_key": API_KEY, "limit": 3, "rating": "g"}
12+
13+
# The response will contain a list with all the GIFs that match your query.
14+
# For each of those, you want to get the `title`, `url` and the `trending_datetime` fields.
815
response = requests.get(endpoint, params=params).json()
916
for gif in response["data"]:
1017
title = gif["title"]

0 commit comments

Comments
 (0)