structured-data / linter

Structured Data linter
The Unlicense
85 stars 17 forks source link

Ability to programmatically POST a HTML/JSON file for linting? #48

Open pdehaan opened 5 years ago

pdehaan commented 5 years ago

Re: "Programatic Access to the Linter" (http://linter.structured-data.org/about/),

The docs say:

To do this, construct an HTTP GET request using the Accept: application/json HTTP header with a url query parameter referencing the page to be processed. curl -H 'Accept: application/json' http://linter.structured-data.org/?url=http://linter.structured-data.org/

Is there a way to do a POST request with an HTML string to be processed? I have a bunch of .jsonld files locally that I need to try linting, but they aren't online. Having the ability to POST a request would let me wrap the .jsonld files in a <script>...</script> tag and validate them easily using Node.

gkellogg commented 5 years ago

I think you can do POST as well.

A better way would be to install the "linkeddata" ruby gem and use the "rdf" command line interface, such as "rdf lint http://example.org/example.jsonld", or a local file. The linter is implemented on top of the RDF Reasoner, which is exposed through the CLI.

pdehaan commented 5 years ago

Yeah, the problem was that I was trying to use this via Node.js, so having to install Ruby would be non-trivial in this case.

But I'll play around w/ POST and see if I can figure out how to send the payload. Thanks!

gkellogg commented 5 years ago

I would caution against overusing the service, as it’s hosted on a free Heroku dyno, and could become overwhelmed. You could consider self-hosting a copy of the service for more intense usage.