Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend 'metadatablocks' endpoint to include the 'multiple' field #8944

Closed
JR-1991 opened this issue Aug 30, 2022 · 2 comments · Fixed by #9213
Closed

Extend 'metadatablocks' endpoint to include the 'multiple' field #8944

JR-1991 opened this issue Aug 30, 2022 · 2 comments · Fixed by #9213
Labels
Feature: API Guide Hackathon: More APIs Add new or missing API endpoints Type: Suggestion an idea User Role: API User Makes use of APIs
Milestone

Comments

@JR-1991
Copy link
Contributor

JR-1991 commented Aug 30, 2022

Overview of the Feature Request

Extend the /metadatablocks/{identifier} endpoint to include the multiple field such that the schema can be used to programmatically upload data.

What kind of user is the feature intended for?

API Users

What inspired the request?

While presenting the EasyDataverse library at the Dataverse Community Meeting 2022 it was brought up in the discussion that the missing field could allow more users to upload datasets programmatically.

What existing behavior do you want changed?

The current REST-API implementation offers the possibility to fetch all metadatablock configurations by using the /metadatablocks/{identifier} endpoint. It provides relevant information of a metadatablock but lacks the multiple statement in a field, which on the flip is necessary to upload data via PyDataverse/HTTP. At the moment, the TSV file has to be inspected to find the corresponding values, but since metadatablock TSVs usually aren't hosted publicly this is only possible for those with access (except for the default TSVs)

An extension of the endpoint would allow users to infer the correct schema to upload datasets programmatically. Furthermore, this would allow EasyDataverse to generate Python interfaces at runtime without the need of hosting a generated API such as the one we are hosting at our university. This would allow the following functionality as an example:

from easyDataverse import Dataset

# Adds metadata configs as objects to which data can be added
dataset = Dataset.from_installation("https://www.mydataverse.com")
dataset.citation.add_author(...)
@poikilotherm
Copy link
Contributor

This is related to #8822 and IQSS/dataverse-pm#26

@pdurbin
Copy link
Member

pdurbin commented Sep 14, 2022

Yes, sure. Good idea @JR-1991. I assume you only want to add to the JSON output, not change anything. Are you thinking about making a pull request?

We've been talking a lot internally about APIs and what the community needs. This is an API I sort of forgot even existed. 😄

Here's a handy link to the docs: https://guides.dataverse.org/en/5.11.1/api/native-api.html#show-info-about-all-metadata-blocks

The API seems extremely useful. Here is some example output:

$ curl -s https://demo.dataverse.org/api/metadatablocks | jq '.data[0]'
{
  "id": 2,
  "displayName": "Geospatial Metadata",
  "name": "geospatial"
}
$ curl -s https://demo.dataverse.org/api/metadatablocks/geospatial | jq | head -20
{
  "status": "OK",
  "data": {
    "id": 2,
    "name": "geospatial",
    "displayName": "Geospatial Metadata",
    "fields": {
      "geographicCoverage": {
        "name": "geographicCoverage",
        "displayName": "Geographic Coverage",
        "title": "Geographic Coverage",
        "type": "NONE",
        "watermark": "",
        "description": "Information on the geographic coverage of the data. Includes the total geographic scope of the data.",
        "childFields": {
          "country": {
            "name": "country",
            "displayName": "Geographic Coverage Country / Nation",
            "title": "Country / Nation",
            "type": "TEXT",

@pdurbin pdurbin added Type: Suggestion an idea Feature: API Guide User Role: API User Makes use of APIs Hackathon: More APIs Add new or missing API endpoints labels Oct 9, 2022
pdurbin added a commit that referenced this issue Dec 2, 2022
With toArray().toString() we were getting something like this:
[Ljava.lang.Object;@76d0a290
pdurbin added a commit that referenced this issue Dec 8, 2022
pdurbin added a commit that referenced this issue Dec 8, 2022
kcondon added a commit that referenced this issue Dec 9, 2022
#8944 - Extend 'metadatablocks/{block_id}' endpoint JSON output
@pdurbin pdurbin added this to the 5.13 milestone Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: API Guide Hackathon: More APIs Add new or missing API endpoints Type: Suggestion an idea User Role: API User Makes use of APIs
Projects
None yet
3 participants