{"id":21953925,"url":"https://github.com/hydroshare/hs_restclient","last_synced_at":"2025-04-23T10:18:35.626Z","repository":{"id":31489172,"uuid":"35053341","full_name":"hydroshare/hs_restclient","owner":"hydroshare","description":"Python client for the https://www.hydroshare.org REST API","archived":false,"fork":false,"pushed_at":"2020-05-18T20:44:33.000Z","size":387,"stargazers_count":6,"open_issues_count":43,"forks_count":7,"subscribers_count":36,"default_branch":"develop","last_synced_at":"2025-04-23T10:18:30.278Z","etag":null,"topics":["api-client","client","hydrology","hydroshare","python","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hydroshare.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-04T18:58:28.000Z","updated_at":"2023-04-14T19:29:00.000Z","dependencies_parsed_at":"2022-09-09T09:31:25.314Z","dependency_job_id":null,"html_url":"https://github.com/hydroshare/hs_restclient","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hydroshare%2Fhs_restclient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hydroshare%2Fhs_restclient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hydroshare%2Fhs_restclient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hydroshare%2Fhs_restclient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hydroshare","download_url":"https://codeload.github.com/hydroshare/hs_restclient/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250412573,"owners_count":21426286,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","client","hydrology","hydroshare","python","rest-api"],"created_at":"2024-11-29T07:14:20.574Z","updated_at":"2025-04-23T10:18:35.600Z","avatar_url":"https://github.com/hydroshare.png","language":"Python","readme":"Python-based client library for HydroShare REST API\n===================================================\n\nQuestions? support@cuahsi.org\n\nTo run tests\n------------\n    \nTo run unit tests::\n\n    cd tests\n    python test_hs_restclient.py\n    \nTo use\n------\n\nTo get a listing of public resources::\n\n    from hs_restclient import HydroShare\n    hs = HydroShare()\n    for resource in hs.resources():\n        print(resource)\n\nTo authenticate using HTTP Basic authentication, and then get a list of resources you have access to::\n\n    from hs_restclient import HydroShare, HydroShareAuthBasic\n    auth = HydroShareAuthBasic(username='myusername', password='mypassword')\n    hs = HydroShare(auth=auth)\n    for resource in hs.resources():\n        print(resource)\n\nTo authenticate using OAuth2 authentication (using a user and password supplied by the user), and then get a list of\nresources you have access to::\n\n    from oauthlib.oauth2 import TokenExpiredError\n    from hs_restclient import HydroShare, HydroShareAuthOAuth2\n\n    # Get a client ID and client secret by registering a new application at:\n    # https://www.hydroshare.org/o/applications/\n    # Choose client type \"Confidential\" and authorization grant type \"Resource owner password-based\"\n    # Keep these secret!\n    client_id = 'MYCLIENTID'\n    client_secret = 'MYCLIENTSECRET'\n\n    auth = HydroShareAuthOAuth2(client_id, client_secret,\n                                username='myusername', password='mypassword')\n    hs = HydroShare(auth=auth)\n\n    try:\n        for resource in hs.resources():\n            print(resource)\n    except TokenExpiredError as e:\n        hs = HydroShare(auth=auth)\n        for resource in hs.resources():\n            print(resource)\n\nNote that currently the client does not handle token renewal, hence the need to catch TokenExpiredError.\n\nTo authenticate using OAuth2 authentication (using an existing token), and then get a list of resources you have\naccess to::\n\n    from oauthlib.oauth2 import TokenExpiredError\n    from hs_restclient import HydroShare, HydroShareAuthOAuth2\n\n    # Get a client ID and client secret by registering a new application at:\n    # https://www.hydroshare.org/o/applications/\n    # Choose client type \"Confidential\" and authorization grant type \"Resource owner password-based\"\n    # Keep these secret!\n    client_id = 'MYCLIENTID'\n    client_secret = 'MYCLIENTSECRET'\n\n    # A token dictionary obtained separately from HydroShare of the form:\n    #   {\n    #       \"access_token\": \"\u003cyour_access_token\u003e\",\n    #       \"token_type\": \"Bearer\",\n    #       \"expires_in\": 36000,\n    #       \"refresh_token\": \"\u003cyour_refresh_token\u003e\",\n    #       \"scope\": \"read write groups\"\n    #   }\n    # get_token() is a stand in for how you get a new token on your system.\n    token = get_token()\n\n    auth = HydroShareAuthOAuth2(client_id, client_secret,\n                                token=token)\n    try:\n        hs = HydroShare(auth=auth)\n        for resource in hs.resources():\n            print(resource)\n    except:\n        # get_token() is a stand in for how you get a new token on your system.\n        token = get_token()\n        hs = HydroShare(auth=auth)\n        for resource in hs.resources():\n            print(resource)\n\nNote that currently the client does not handle token renewal, hence the need to catch TokenExpiredError.\n\nTo connect to a development HydroShare server that uses a self-sign security certificate::\n\n    from hs_restclient import HydroShare\n    hs = HydroShare(hostname='mydev.mydomain.net', verify=False)\n    for resource in hs.resources():\n        print(resource)\n\nTo connect to a development HydroShare server that is not running HTTPS::\n\n    from hs_restclient import HydroShare\n    hs = HydroShare(hostname='mydev.mydomain.net', port=8000, use_https=False)\n    for resource in hs.resources():\n        print(resource)\n\nNote that authenticated connections **must** use HTTPS.\n\nFor more usage options see the documentation.\n\nDocumentation\n-------------\n\nComplete installation and usage documentation is available at http://hs-restclient.readthedocs.org/en/latest/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhydroshare%2Fhs_restclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhydroshare%2Fhs_restclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhydroshare%2Fhs_restclient/lists"}