Skip to content

This Python script uses Flask to provide a RESTful API which applies the data verification ruleset contained within the NBN Record Cleaner application to JSON data returned by calls to the NBN Atlas API

License

Notifications You must be signed in to change notification settings

prolixteriat/nbn-record-cleaner-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nbn-record-cleaner-api

Overview

This Python script uses Flask to provide a RESTful API which applies the data verification ruleset contained within the NBN Record Cleaner application to JSON data returned by calls to the NBN Atlas API.

Example Usage

The following call to the NBN Atlas API will return 150 records:

  • https://records-ws.nbnatlas.org/occurrences/search.json?q=*:*&fq=year:2022&lat=51.5074&lon=0.1278&radius=25.0&pageSize=150

Piping the results from such a call to the Flask API will cause the returned results to be assessed against the Record Cleaner verification ruleset. Any records which either fail or cause a warning to be raised will be returned with associated details.

Assuming that the Flask app is running on 127.0.0.1:5000: A call to the endpoint:

  • http://127.0.0.1:5000/validate?url=https://records-ws.nbnatlas.org/occurrences/search.json?q=*:*&fq=year:2022&lat=51.5074&lon=0.1278&radius=25.0&pageSize=150

Produces the output:

[
  {
    "count_all": 3,
    "count_fail": 1,
    "count_warn": 0,
    "result": [
      {
        "message": "Coordinate is outside known range for Chalcolestes viridis",
        "ruleset": "region",
        "status": "fail"
      }
    ],
    "status": "fail",
    "url": "https://records-ws.nbnatlas.org/occurrence/f0ae7868-d28a-42ca-840d-222e67ed3c4a"
  },
  {
    "count_all": 4,
    "count_fail": 1,
    "count_warn": 2,
    "result": [
      {
        "message": "Records for this ladybird species requires additional verification. This is a rare ladybird species",
        "ruleset": "additional",
        "status": "warning"
      },
      {
        "message": "Species needs confirmation from national expert or UK Ladybird Survey.",
        "ruleset": "difficulty",
        "status": "warning"
      },
      {
        "message": "Coordinate outside know range for Rhyzobius lophanthae",
        "ruleset": "region",
        "status": "fail"
      }
    ],
    "status": "fail",
    "url": "https://records-ws.nbnatlas.org/occurrence/68024714-0e5b-4473-8cab-2be076e36497"
  }
]

About

This Python script uses Flask to provide a RESTful API which applies the data verification ruleset contained within the NBN Record Cleaner application to JSON data returned by calls to the NBN Atlas API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages