Skip to content

Commit d10af3f

Browse files
committed
updte template
1 parent 76831f4 commit d10af3f

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

64/marvel.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
import hashlib # needed for API auth
2-
import json
2+
import json # use dumps and loads
33
import os
44
from time import sleep # between API pagination calls
55

6-
import requests
6+
import requests # call Marvel API
77

88
# get from marvel developer account:
9-
public_key = os.environ['PUBLIC_KEY']
10-
private_key = os.environ['PRIVATE_KEY']
9+
PUBLIC_KEY = os.environ['PUBLIC_KEY']
10+
PRIVATE_KEY = os.environ['PRIVATE_KEY']
1111

12-
ENDPOINTS = 'characters comics creators events series stories'.split()
12+
# https://developer.marvel.com/documentation/authorization
13+
# "Authentication for Server-Side Applications" section
14+
ENDPOINT = ('https://gateway.marvel.com:443/v1/public/{endpoint}?ts=1&'
15+
'apikey={public_key}&hash={hash_}')
1316

17+
# https://developer.marvel.com/docs
18+
MARVEL_OBJECTS = 'characters comics creators events series stories'.split()
1419

15-
# recommended prep work
1620

17-
def get_data_from_marvel_api_endpoint(endpoint):
18-
"""Helper function to get data from the Marvel API:
21+
def get_api_endpoint():
22+
"""Helper function to form a valid API endpoint (use ENDPOINT)"""
23+
pass
1924

20-
https://gateway.marvel.com:443/v1/public/{endpoint}
2125

22-
See: https://developer.marvel.com/documentation/authorization
23-
"Authentication for Server-Side Applications" section
24-
-> you will need to hash ts, public and private key, use hashlib
25-
26-
Endpoints: https://developer.marvel.com/docs
27-
28-
Return the response json object.
29-
"""
30-
ts = 1
26+
def cache_marvel_data():
27+
"""Helper function to cache Marvel API JSON data to file"""
28+
pass
3129

3230

3331
if __name__ == '__main__':
34-
your_endpoint = '' # one of ENDPOINTS
35-
get_data_from_marvel_api_endpoint(your_endpoint)
32+
# 1. cache API data
33+
# 2. load JSON file(s) and build awesome graphs
34+
pass

0 commit comments

Comments
 (0)