Title: api_key param is absent and ParseError reference is missing · Issue #6 · glassnode/glassnode-api-python-client · GitHub
Open Graph Title: api_key param is absent and ParseError reference is missing · Issue #6 · glassnode/glassnode-api-python-client
X Title: api_key param is absent and ParseError reference is missing · Issue #6 · glassnode/glassnode-api-python-client
Description: Your python client lib has problems. First up the api_key param in your example doesn't work: `from glassnode import GlassnodeClient gn = GlassnodeClient(api_key='YOUR-KEY')` Obviously that's insecure but I wanted to give it a first run ...
Open Graph Description: Your python client lib has problems. First up the api_key param in your example doesn't work: `from glassnode import GlassnodeClient gn = GlassnodeClient(api_key='YOUR-KEY')` Obviously that's insec...
X Description: Your python client lib has problems. First up the api_key param in your example doesn't work: `from glassnode import GlassnodeClient gn = GlassnodeClient(api_key='YOUR-KEY')` Obviously ...
Opengraph URL: https://github.com/glassnode/glassnode-api-python-client/issues/6
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"api_key param is absent and ParseError reference is missing","articleBody":"Your python client lib has problems. First up the api_key param in your example doesn't work:\r\n\r\n`from glassnode import GlassnodeClient\r\n\r\ngn = GlassnodeClient(api_key='YOUR-KEY')`\r\n\r\nObviously that's insecure but I wanted to give it a first run and got this:\r\n\r\nTypeError: __init__() got an unexpected keyword argument 'api_key'\r\n\r\nLooking at the source I can see why. Anyway, I removed the param as I had set an env variable in PyCharm as well as in OS X:\r\n\r\n```\r\nimport os\r\nfrom glassnode import GlassnodeClient\r\n\r\nGLASSNODE_API_KEY = os.getenv('GLASSNODE_API_KEY')\r\nprint(GLASSNODE_API_KEY)\r\n\r\ngn = GlassnodeClient()\r\n\r\nresponse = gn.get(\r\n 'https://api.glassnode.com/v1/metrics/indicators/net_realized_profit_loss?a=BTC\u0026s=1479573422\u0026u=1614470400',\r\n a='BTC',\r\n s='2020-01-01',\r\n i='24h'\r\n)\r\n\r\nprint(response)\r\n\r\n```\r\n\r\nAfter running it like that I get another error:\r\n\r\n```\r\n401 Client Error: Unauthorized for url: https://api.glassnode.com/v1/metrics/indicators/net_realized_profit_loss?a=BTC\u0026s=1479573422\u0026u=1614470400\u0026a=BTC\u0026i=24h\u0026c=native\u0026s=1577833200\u0026api_key=\r\n\u003chtml\u003e\r\n\u003chead\u003e\u003ctitle\u003e401 Authorization Required\u003c/title\u003e\u003c/head\u003e\r\n\u003cbody\u003e\r\n\u003ccenter\u003e\u003ch1\u003e401 Authorization Required\u003c/h1\u003e\u003c/center\u003e\r\n\u003chr\u003e\u003ccenter\u003enginx/1.15.9\u003c/center\u003e\r\n\u003c/body\u003e\r\n\u003c/html\u003e\r\n\r\nExpecting value: line 1 column 1 (char 0)\r\nNone\r\n```\r\n\r\nSo either it's not picking up the key or something else is going on.\r\n\r\nFinally there seem to be an unresolved ParseError reference in glassnode.py. It's clearly the iso8601 ParseError and I've fixed it by making it verbose by adding the module name ahead of ParseError. I've also removed superfluous imports:\r\n\r\n```\r\nimport json\r\nimport requests\r\nimport iso8601\r\nimport pandas as pd\r\n\r\nclass GlassnodeClient:\r\n\r\n def __init__(self):\r\n self._api_key = ''\r\n\r\n @property\r\n def api_key(self):\r\n return self._api_key\r\n\r\n def set_api_key(self, value):\r\n self._api_key = value\r\n\r\n def get(self, url, a='BTC', i='24h', c='native', s=None, u=None):\r\n p = dict()\r\n p['a'] = a\r\n p['i'] = i\r\n p['c'] = c\r\n\r\n if s is not None:\r\n try:\r\n p['s'] = iso8601.parse_date(s).strftime('%s')\r\n except iso8601.ParseError:\r\n p['s'] = s\r\n\r\n if u is not None:\r\n try:\r\n p['u'] = iso8601.parse_date(u).strftime('%s')\r\n except iso8601.ParseError:\r\n p['u'] = s\r\n\r\n p['api_key'] = self.api_key\r\n\r\n r = requests.get(url, params=p)\r\n\r\n try:\r\n r.raise_for_status()\r\n except Exception as e:\r\n print(e)\r\n print(r.text)\r\n\r\n try:\r\n df = pd.DataFrame(json.loads(r.text))\r\n df = df.set_index('t')\r\n df.index = pd.to_datetime(df.index, unit='s')\r\n df = df.sort_index()\r\n s = df.v\r\n s.name = '_'.join(url.split('/')[-2:])\r\n return s\r\n except Exception as e:\r\n print(e)\r\n```\r\n\r\nI run python 3.9 on OS X.\r\n\r\nAny pointers would be appreciated. ","author":{"url":"https://github.com/mmehrle","@type":"Person","name":"mmehrle"},"datePublished":"2021-02-28T13:43:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/6/glassnode-api-python-client/issues/6"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4ea0ce33-4086-ab1f-7c4c-40299cbec8e2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9516:9FE98:1D63A4C:2898F7B:6A4ECEFD |
| html-safe-nonce | fbb6abc62ed1e1f885925eacd32e6a6e396a2240f283910996501fd6f082b3b4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTE2OjlGRTk4OjFENjNBNEM6Mjg5OEY3Qjo2QTRFQ0VGRCIsInZpc2l0b3JfaWQiOiI3NDU4MDAzMDE1MjU5MDQ5NzI1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 70b9ea8f1ea430f0d77e164e6a8d62abe0c3288f1cda863f57a5a8c00b1c78ab |
| hovercard-subject-tag | issue:818209247 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/glassnode/glassnode-api-python-client/6/issue_layout |
| twitter:image | https://opengraph.githubassets.com/91f1a73fd02ea4722324cca5100f37df8b8d5d2c9961958075d63804e9264d7c/glassnode/glassnode-api-python-client/issues/6 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/91f1a73fd02ea4722324cca5100f37df8b8d5d2c9961958075d63804e9264d7c/glassnode/glassnode-api-python-client/issues/6 |
| og:image:alt | Your python client lib has problems. First up the api_key param in your example doesn't work: `from glassnode import GlassnodeClient gn = GlassnodeClient(api_key='YOUR-KEY')` Obviously that's insec... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mmehrle |
| hostname | github.com |
| expected-hostname | github.com |
| None | 41b6ab3ba6d20a71766ac245b5a4a94c6fc672a9cd4da7d44c1b33ab8bf6a21c |
| turbo-cache-control | no-preview |
| go-import | github.com/glassnode/glassnode-api-python-client git https://github.com/glassnode/glassnode-api-python-client.git |
| octolytics-dimension-user_id | 40865666 |
| octolytics-dimension-user_login | glassnode |
| octolytics-dimension-repository_id | 243736354 |
| octolytics-dimension-repository_nwo | glassnode/glassnode-api-python-client |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 243736354 |
| octolytics-dimension-repository_network_root_nwo | glassnode/glassnode-api-python-client |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e6a744804e8e70f97b4d5a18a94dcc63db22f97a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width