VtEcostudies / VAL_Data_Explorers

Other
1 stars 1 forks source link

Listing publishers that contribute data #6

Open MortenHofft opened 2 years ago

MortenHofft commented 2 years ago

I notice you currently link to https://www.gbif.org/publisher/search?q=vermont

We do not really have a good way to display all the publishers that contribute data.

Currently you would have to do that yourself I'm afraid:

Example API call to https://graphql.gbif-staging.org/graphql (POST with body {query[string], variables[JSON]}

query:

query table($predicate: Predicate, $size: Int = 100){
  occurrenceSearch(predicate: $predicate, size: 0, from: 0) {
    cardinality {
      publishingOrg
    }
    facet {
      publishingOrg(size: $size) {
        count
        publisher {
          key
          title
        }
      }
    }
  }
}

variables:

{
  "predicate": {
    "type": "and",
    "predicates": [
      {
        "type": "or",
        "predicates": [
          {
            "type": "and",
            "predicates": [
              {
                "key": "country",
                "type": "equals",
                "value": "US"
              },
              {
                "type": "in",
                "key": "stateProvince",
                "values": [
                  "vermont",
                  "vermont (state)"
                ]
              },
              {
                "type": "equals",
                "key": "hasCoordinate",
                "value": false
              }
            ]
          },
          {
            "type": "equals",
            "key": "gadmGid",
            "value": "USA.46_1"
          }
        ]
      },
      {
        "type": "and",
        "predicates": []
      }
    ]
  },
  "size": 200
}
jloomisVCE commented 2 years ago

Thanks for this. I'd been wondering if there's a way to run a live GBIF API query that uses a predicate (which I think otherwise must be done with CURL, hence offline/downloaded).

I've not seen this approach before. I'm interested to try it out.

MortenHofft commented 2 years ago

This is using our experimental graphql API, but we also just added search by predicate to the APIv1 https://github.com/gbif/portal16/issues/1778 but haven't documented it yet. Notice that graphql differs slightly in predicates. The casing for keys are different. That is my mistake when implementing it the graphql version 😢