Skip to content

Conversation

@JR-1991
Copy link
Member

@JR-1991 JR-1991 commented Apr 9, 2025

This PR introduces endpoints to interact with the Dataverse Hub server, which manages installation records and provides access to global metrics. It includes the implementation of request and response models using Pydantic, which has been added as a new dependency. These models ensure payload and response validation and offer a convenient interface for navigating response data.

Example

from pyDataverse.hub import HubApi

hub = HubApi()

installations = hub.get_installation_metrics_monthly(
    from_date="2020-01",
    to_date="2025-01",
)

for installation in installations:
    print(installation.name)
    print(installation.country)

Metric Filtering

The PR also adds the FilterMetrics class to simplify passing filter parameters to the metrics endpoint. This approach improves readability and scalability by avoiding a bloated method signature and making it easier to extend filtering options in the future.

hub = HubApi()
filter_by = FilterMetrics(launch_year=2025)
response = hub.get_installation_metrics(filter_by=filter_by)

TLDR

JR-1991 added 3 commits April 9, 2025 18:49
- Includes PyDantic models for validation
- filters can be passed as an object, which will be added as params
@JR-1991 JR-1991 added the pkg:api api related activities label Apr 9, 2025
@JR-1991 JR-1991 added this to the 0.3.5 milestone Apr 9, 2025
@JR-1991 JR-1991 requested a review from pdurbin April 9, 2025 17:22
@JR-1991 JR-1991 self-assigned this Apr 9, 2025
@JR-1991 JR-1991 linked an issue Apr 9, 2025 that may be closed by this pull request
@JR-1991 JR-1991 moved this to Ready for Review in PyDataverse Working Group Apr 9, 2025
@JR-1991
Copy link
Member Author

JR-1991 commented Apr 9, 2025

By the way: This PR already adapts the PyDantic-based implementation I was envisioning at py.gdcc.io

@JR-1991 JR-1991 closed this Apr 16, 2025
@github-project-automation github-project-automation bot moved this from Ready for Review to Done in PyDataverse Working Group Apr 16, 2025
@pdurbin
Copy link
Member

pdurbin commented Apr 16, 2025

As discussed today, we're thinking a separate package would be best. dataverse-hub on PyPI or something.

@JR-1991 JR-1991 deleted the 218-client-bindings-based-on-httpshubdataverseorgopenapi branch August 14, 2025 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:api api related activities

Projects

Development

Successfully merging this pull request may close these issues.

client bindings based on https://hub.dataverse.org/openapi

3 participants