forked from pybites/challenges
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into community
- Loading branch information
Showing
1 changed file
with
19 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,34 @@ | ||
import hashlib # needed for API auth | ||
import json | ||
import json # use dumps and loads | ||
import os | ||
from time import sleep # between API pagination calls | ||
|
||
import requests | ||
import requests # call Marvel API | ||
|
||
# get from marvel developer account: | ||
public_key = os.environ['PUBLIC_KEY'] | ||
private_key = os.environ['PRIVATE_KEY'] | ||
PUBLIC_KEY = os.environ['PUBLIC_KEY'] | ||
PRIVATE_KEY = os.environ['PRIVATE_KEY'] | ||
|
||
ENDPOINTS = 'characters comics creators events series stories'.split() | ||
# https://developer.marvel.com/documentation/authorization | ||
# "Authentication for Server-Side Applications" section | ||
ENDPOINT = ('https://gateway.marvel.com:443/v1/public/{endpoint}?ts=1&' | ||
'apikey={public_key}&hash={hash_}') | ||
|
||
# https://developer.marvel.com/docs | ||
MARVEL_OBJECTS = 'characters comics creators events series stories'.split() | ||
|
||
# recommended prep work | ||
|
||
def get_data_from_marvel_api_endpoint(endpoint): | ||
"""Helper function to get data from the Marvel API: | ||
def get_api_endpoint(): | ||
"""Helper function to form a valid API endpoint (use ENDPOINT)""" | ||
pass | ||
|
||
https://gateway.marvel.com:443/v1/public/{endpoint} | ||
|
||
See: https://developer.marvel.com/documentation/authorization | ||
"Authentication for Server-Side Applications" section | ||
-> you will need to hash ts, public and private key, use hashlib | ||
Endpoints: https://developer.marvel.com/docs | ||
Return the response json object. | ||
""" | ||
ts = 1 | ||
def cache_marvel_data(): | ||
"""Helper function to cache Marvel API JSON data to file""" | ||
pass | ||
|
||
|
||
if __name__ == '__main__': | ||
your_endpoint = '' # one of ENDPOINTS | ||
get_data_from_marvel_api_endpoint(your_endpoint) | ||
# 1. cache API data | ||
# 2. load JSON file(s) and build awesome graphs | ||
pass |