From 2e27fc31b4758824877d7a27a0f7b21ae2be0b54 Mon Sep 17 00:00:00 2001 From: melange396 Date: Thu, 5 Oct 2023 18:10:07 -0400 Subject: [PATCH 1/2] use python package-specific "user agent" string --- Python-packages/covidcast-py/covidcast/covidcast.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Python-packages/covidcast-py/covidcast/covidcast.py b/Python-packages/covidcast-py/covidcast/covidcast.py index 1701f453..5c348adf 100644 --- a/Python-packages/covidcast-py/covidcast/covidcast.py +++ b/Python-packages/covidcast-py/covidcast/covidcast.py @@ -7,12 +7,22 @@ import pandas as pd import numpy as np from delphi_epidata import Epidata +from delphi_epidata.delphi_epidata import _HEADERS +from pkg_resources import get_distribution, DistributionNotFound from epiweeks import Week from .errors import NoDataWarning + # Point API requests to the default endpoint -Epidata.BASE_URL = "https://api.covidcast.cmu.edu/epidata" +Epidata.BASE_URL = "https://api.covidcast.cmu.edu/epidata/api.php" +# Prepend to Epidata client's user agent to specify this package and version +try: + _ver = get_distribution("covidcast").version +except DistributionNotFound: + _ver = "0.0.0" +_HEADERS['user-agent'] = f"covidcast/{_ver} " + _HEADERS['user-agent'] + VALID_GEO_TYPES = {"county", "hrr", "msa", "dma", "state", "hhs", "nation"} From 772cb0ed3e4af9e655bfa3cbb205988d8d9cb3f9 Mon Sep 17 00:00:00 2001 From: melange396 Date: Mon, 9 Oct 2023 17:05:43 -0400 Subject: [PATCH 2/2] Update Python-packages/covidcast-py/covidcast/covidcast.py --- Python-packages/covidcast-py/covidcast/covidcast.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python-packages/covidcast-py/covidcast/covidcast.py b/Python-packages/covidcast-py/covidcast/covidcast.py index 5c348adf..c523c83f 100644 --- a/Python-packages/covidcast-py/covidcast/covidcast.py +++ b/Python-packages/covidcast-py/covidcast/covidcast.py @@ -15,7 +15,7 @@ # Point API requests to the default endpoint -Epidata.BASE_URL = "https://api.covidcast.cmu.edu/epidata/api.php" +Epidata.BASE_URL = "https://api.covidcast.cmu.edu/epidata" # Prepend to Epidata client's user agent to specify this package and version try: _ver = get_distribution("covidcast").version