Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

If the query produces large amounts of data (>10,000 observations/rows), the best way to extract the data is using the the code snippet produced after selecting the API button (blue star). Here we see that a code generator appears with the data query……. dataset and observable properties and the user has the option to customise the programming language, variant and output format.

...

In this example , we have selected the programming language R, CSV output and httr variant. Now we can copy the code snippet by pressing the copy snippet button(blue star). In R studio, we can paste this snippet. It is important to note that you will need to enter your own individual API-key into the code.

Code Block
languager
library(httr)

## you will need to enter your own individaul API key ##
headers = c(
  'X-Api-Key' = 'your-api-key',
  'Content-Type' = 'application/json'
)

body = '{
  "query": {
    "dataset": [
      "http://linked.data.gov.au/dataset/tern-ecosystem-processes"
    ],
    "observed_property": [
      "http://linked.data.gov.au/def/tern-cv/56195246-ec5d-4050-a1c6-af786fbec715",
      "http://linked.data.gov.au/def/tern-cv/5701d307-bbea-415a-8857-fbf27d5b93ed",
      "http://linked.data.gov.au/def/tern-cv/c3d26c6f-91b7-4627-91e6-2147fa44ad03",
      "http://linked.data.gov.au/def/tern-cv/c3111898-8404-4306-9599-e7866a749de7"
    ]
  }
}';

res <- VERB("POST", url = "https://ecoplots.tern.org.au/api/v1.0/data/tern-ecosystem-processes?dformat=csv", body = body, add_headers(headers))

cat(content(res, 'text'))