Skip to content

Commit

Permalink
fix: use api parameters for individual site APIs
Browse files Browse the repository at this point in the history
As a result, they get 10K daily limit instead of 300 requests.

#1
  • Loading branch information
karlicoss committed Mar 13, 2021
1 parent f956f79 commit b0fc207
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/stexport/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,12 @@ def fetch_backoff(api, *args, **kwargs):

class Exporter:
def __init__(self, **kwargs) -> None:
self.api = _get_api(**kwargs)
self.api_params = kwargs
self.api = _get_api(**self.api_params)
self.user_id = kwargs['user_id']

def get_site_api(self, site: str):
api = _get_api()
api = _get_api(**self.api_params)
sites = get_all_sites(api)
api._name = sites[site]
api._api_key = site
Expand All @@ -159,11 +160,12 @@ def export_site(self, site: str) -> Json:
for ep in ENDPOINTS:
logger.info('exporting %s: %s', site, ep)
# TODO ugh. still not sure about using weird patterns as dictionary keys...
data[ep] = fetch_backoff(
r = fetch_backoff(
api,
endpoint=ep.format(ids=self.user_id, id=self.user_id),
filter=FILTER,
)['items']
)
data[ep] = r['items']
return data


Expand Down

0 comments on commit b0fc207

Please sign in to comment.