Querying the CSDMS model repository
Querying the CSDMS Model Repository
Semantic MediaWiki (SMW)
is the knowledge management system used on the CSDMS website.
SMW has an API with several actions,
allowing users to add, edit, and query information.
Here, we'll focus on the ask
action,
and the Ask API,
to query metadata from the CSDMS model metadata repository.
The base URL for any call to the SMW API on the CSDMS website is http://csdms.colorado.edu/mediawiki/api.php.
Query syntax
The ask
action supports one parameter, query
,
which takes an urlencoded string.
The query is written in the SMW query language.
A query consists of a series of conditions,
which describe the search.
Conditions are built from properties and values.
For example, the condition
[[Programming language::C]]
would query for all models with the Programming language
property
that have a value of C
.
Note that the colons ::
in the condition
are literal in the query language,
and cannot be urlencoded.
Spaces, however, should be encoded with %20
or +
,
while brackets []
may optionally be encoded.
Try this condition in a query:
http://csdms.colorado.edu/mediawiki/api.php?action=ask&query=[[Programming+language::C]]&format=json
The results of a query are returned as JSON
with a specified
format.
A query result can also be viewed in pretty print form
by changing the value of the format
parameter to jsonfm
.