API

How to Use the CSVLint Webservice API

CSVLint has a Webservice API that allows you to POST a file and return a validation.

Currently you POST a file like so:

curl -L --data "urls[]=http://theodi.github.io/hot-drinks/hot-drinks.csv" http://csvlint.io/package.json

(urls[] can also be a comma seperated list of urls)

Or with a schema:

curl -L --data "urls[]=http://theodi.github.io/hot-drinks/hot-drinks.csv&schema=1&schema_url=http://example.com/some_schema.json" http://csvlint.io/package.json

And you get back some json with a URL to a package:

{
  "package": {
    "url":"http://csvlint.io/package/53a150336373764c17170700"
  }
}

You can then get the validation by making a request to the JSON version of the package like so:

curl http://csvlint.io/package/53a150336373764c17170700.json

Note Currently the package is created in the background, so may not be available immediately. This will change in the future.

This then returns the JSON version of the package:

{
  "version":"0.1",
  "licence":"http://opendatacommons.org/licenses/odbl/",
  "package":{
    "validations":[
      {
        "url":"http://csvlint.io/validation/53566ef96373767abf010000",
        "source":"http://theodi.github.io/hot-drinks/hot-drinks.csv",
        "state":"invalid"
      }
    ]
  }
}

You can then get the full validation by making a GET request to the actual validation URL:

curl http://csvlint.io/validation/53566ef96373767abf010000.json
{
  "version": "0.1",
  "licence": "http://opendatacommons.org/licenses/odbl/",
  "validation": {
    "url": "http://csvlint.io/validation/53566ef96373767abf010000",
    "source": "http://theodi.github.io/hot-drinks/hot-drinks.csv",
    "state": "invalid",
    "errors": [
      {
        "type": "undeclared_header",
        "category": "structure",
        "row": null,
        "col": null
      }
    ],
    "warnings": [
      {
        "type": "header_name",
        "category": "schema",
        "row": null,
        "col": 1
      },
      {
        "type": "header_name",
        "category": "schema",
        "row": null,
        "col": 2
      },
      {
        "type": "header_name",
        "category": "schema",
        "row": null,
        "col": 3
      },
      {
        "type": "header_name",
        "category": "schema",
        "row": null,
        "col": 4
      }
    ],
    "info": [
      {
        "type": "assumed_header",
        "category": "structure",
        "row": null,
        "col": null
      },
      {
        "type": "nonrfc_line_breaks",
        "category": "structure",
        "row": null,
        "col": null
      }
    ],
    "standardisedCSV": "http://csvlint.io/validation/53566ef96373767abf010000.csv",
    "badges": {
      "svg": "http://csvlint.io/validation/53566ef96373767abf010000.svg",
      "png": "http://csvlint.io/validation/53566ef96373767abf010000.png"
    }
  }
}

Gems

This application uses the csvlint.rb Ruby gem made by the Open Data Institute. For details on how to use the gem yourself, visit https://github.com/theodi/csvlint.rb.