Example code in python-client/README.md not working
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 65/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- pandas, python
- Domain
- documentation
Research direction
Start with the example in python-client/README.md and review the configuration, timestamp explanation, and API calls against the working example in the issue. Update the README so the example is self-explanatory and runnable, then run it to verify that it downloads data successfully.
Written by the indexing model from the issue text.
Description
Please update the python example code in python-client/README.md - there are several issues with it (host wrong, discard_unknown_keys should be False or it will fail, it is not self-explaining what timestamps can be used, ...).
I was able to download data with this code:
import pandas as pd
from deutschland import smard
from pprint import pprint
from deutschland.smard.api import default_api
configuration = smard.Configuration(
host="http://www.smard.de/app/chart_data", # host/path given in example is wrong
discard_unknown_keys=True # suppress "deutschland.smard.exceptions.ApiTypeError: Invalid type for variable '1'.
# Required value type is float and passed type was NoneType at ['received_data']['series'][140][1]"
)
def run():
with smard.ApiClient(configuration) as api_client:
api_instance = default_api.DefaultApi(api_client)
smard_filter = 1223
smard_region = "DE"
smard_resolution = "quarterhour"
try:
# this will return all timestamps that can be used in smard_timestamp
api_response = api_instance.filter_region_index_resolution_json_get(
smard_filter, region=smard_region, resolution=smard_resolution)
timestamp_df = pd.Series(api_response["timestamps"])
last_timestamp_ms = timestamp_df.iloc[-1]
last_datetime = pd.to_datetime(last_timestamp_ms, unit="ms")
last_datetime = last_datetime.tz_localize('UTC')
print("Latest json data starts at unixtimestamp %u ms (%s)"
% (last_timestamp_ms, last_datetime.tz_convert('Europe/Berlin')))
smard_timestamp = int(last_timestamp_ms)
api_response = api_instance.filter_region_filter_copy_region_copy_resolution_timestamp_json_get(
smard_filter, smard_filter, smard_region, smard_timestamp,
region=smard_region, resolution=smard_resolution)
pprint(api_response)
except smard.ApiException as e:
print("SMART Api Exception filter_region_filter_copy_region_copy_resolution_timestamp_json_get: %s\n" % e)
if __name__ == "__main__":
run()
- Dominant language
- Python
- Stars
- 94
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bundesAPI/smard-api
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
2 times Polen in API Open
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
All issues in bundesAPI/smard-api
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100