1. Timo Sulg
  2. franziska

Wiki

Clone wiki

franziska / curl_examples

cURL examples

As you know, official documentation lacks of real examples. It was total headache to get statements querying and filtering correct, therefor i created some curl examples. Of course, you can use those example in your unit-tests to compare results:

#!/bin/bash
# Query unittests with comparing previously prepared cURL commands

# official documentation:
# http://www.franz.com/agraph/support/documentation/current/http-protocol.html#get-catalogs

#PUT/POST /repositories/[name]/statements :

#add examples to db
curl --verbose --basic --user root:baas471 --header "Content-Type: text/plain"\
	 --url http://192.168.100.5:10035/repositories/test/statements \
	 --data '<http://example.org#metusala> <http://example.org#age> "960".\n
	 		<http://example.org#triin> <http://example.org#age> "20".\n
	 		<http://example.org#kati> <http://example.org#age> "960".\n
	 		<http://example.org#kerli> <http://example.org#age> "18".\n
	 		<http://example.org#franz> <http://example.org#age> "20".'

#CURL commands for GET /repositories/[name]/statements 

# Additional parameters for statements querying:
# subj -  Match a specific subject. When given, should be a term in N-triples format. 
# 		Can be given multiple times to mean 'the subject must be one of these resources.
# 		example: '<http://example.org#aljona>' 
# subjEnd - Can only be given if exactly one subj parameter is given. 
#           Matches a range of subjects. 
# pred - Match a specific predicate. Can be passed multiple times, like subj, to match a set. 
# predEnd - Perform a range query on the predicate.
# obj - Match a specific object. Pass multiple values to match a set.
# objEnd - Range query on objects.
# context - Can be given multiple times. Restricts the query to the given list of named graphs. 
# contextEnd -Range query on contexts / graph names.
# limit - An integer indicating the maximum amount of results to return.
# offset -An integer. Tell the server to skip a number of results before it starts returning. 
# infer - Used to turn on reasoning for this query. Valid values are false, rdfs++, and hasvalue. 
#	Default is false — no reasoning. 

#fetch statement by subject
curl --verbose --basic --user root:baas471 --get --data-urlencode subj='<http://example.org#bob>'\
	 --url http://192.168.100.5:10035/repositories/test/statements

#fetch statement by predicate
curl --verbose --basic --user root:baas471 --get --data-urlencode pred='<http://example.org#age>'\
	  --url http://192.168.100.5:10035/repositories/test/statements

#fetch statements by object period
curl --verbose --basic --user root:baas471 --get --data-urlencode obj='"22"'\
  --data-urlencode objEnd="\"33\"" --data limit=5\
  --url http://192.168.100.5:10035/repositories/test/statements


#remove all bobs

# Additional parameters:
# subj - Match a specific subject. When given, should be a term in N-triples format. 
# pred - Match a specific predicate.
# obj - Match a specific object.
# context - Match a specific graph name.

curl --verbose --basic --user root:baas471\
	 --get --request DELETE\
	 --data-urlencode subj='<http://example.org#bob>'\
	 --url http://192.168.100.5:10035/repositories/test/statements

official documentation: http:www.franz.com/agraph/support/documentation/current/http-protocol.html#get-catalogs

Updated