Skip to content

Instantly share code, notes, and snippets.

@baskaufs
Created May 30, 2015 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baskaufs/55d5377422a641c5447c to your computer and use it in GitHub Desktop.
Save baskaufs/55d5377422a641c5447c to your computer and use it in GitHub Desktop.
cURL syntax to query the TDWG sandbox SPARQL endpoint
curl --data-urlencode "query@test.sparql" http://tdwg-rdf.phylodiversity.net/store2/sparql
@baskaufs
Copy link
Author

Notes:

  1. This assumes that cURL is installed and in the PATH for your computer.
  2. The command is given from the DOS command line from the directory that contains the file test.sparql .
  3. The file test.sparql contains a valid SPARQL query.
  4. --data passes the data contained in the file as a the query string so that you don't have to try to encode it in the URL.
  5. -urlencode allows you to have spaces in the SPARQL query and not have to escape them with "+". It escapes other "bad" characters.
  6. The results are displayed directly in the DOS window. They can be piped into a file using ">", e.g.
    curl --data-urlencode "query@test.sparql" http://tdwg-rdf.phylodiversity.net/store2/sparql > results.xml

@baskaufs
Copy link
Author

The triples are loaded into the "store3" endpoint, which returns JSON. So the same command can be given replacing "store2" with "store3" and the result will be in JSON. This endpoint seems a lot slower and more prone to breaking with complex queries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment