|
1 | 1 | import hashlib # needed for API auth |
2 | | -import json |
| 2 | +import json # use dumps and loads |
3 | 3 | import os |
4 | 4 | from time import sleep # between API pagination calls |
5 | 5 |
|
6 | | -import requests |
| 6 | +import requests # call Marvel API |
7 | 7 |
|
8 | 8 | # 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'] |
11 | 11 |
|
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_}') |
13 | 16 |
|
| 17 | +# https://developer.marvel.com/docs |
| 18 | +MARVEL_OBJECTS = 'characters comics creators events series stories'.split() |
14 | 19 |
|
15 | | -# recommended prep work |
16 | 20 |
|
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 |
19 | 24 |
|
20 | | - https://gateway.marvel.com:443/v1/public/{endpoint} |
21 | 25 |
|
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 |
31 | 29 |
|
32 | 30 |
|
33 | 31 | 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