Query endpoints and repositories
The repositories a query can run against: full, meta, text, per-type, per-key, spaces and trust, and how to combine them.
One network, several repositories
Nanopub Query, the service behind every page and API call, does not keep all nanopublications in one database. It keeps several repositories, each holding a slice of the network suited to a kind of question, and a query template names the one it runs against. Choosing the right repository is the difference between a query that answers in a moment and one that times out.
The general repositories
full holds every nanopublication with all its content; it answers anything, but slowly for broad questions. meta holds only the information about each nanopublication — who published it, when, what it supersedes or introduces — and is the fast choice for questions that do not need the content. text supports full-text search over the content, and last30d holds only recent nanopublications, for feeds and dashboards.
Repositories by type and by publisher
For each nanopublication type there is a repository holding only nanopublications of that type, and for each publisher's key one holding only theirs. A query about, say, presentations runs against the presentations repository and never touches the rest, which is what makes views fast. A type's repository comes into existence when the first nanopublication of that type is published — until then, a query naming it finds nothing — so a new kind of nanopublication is introduced with an example first.
The computed repositories
Two repositories hold state the service computes rather than nanopublications as published. spaces holds the validated picture of every space — its members and their roles, its resources, its sub-spaces — with the authority checks already applied. trust holds which keys belong to whom and whether the network trusts them. Queries about "who may" and "who is" go here rather than reconstructing the answer from raw grants and introductions.
Both keep the current state in a graph whose name changes on every recomputation, reached through a pointer; a query reads the pointer and the state in one go so it never sees a half-updated picture.
Combining repositories
A query on one repository can consult another with a federated service clause, typically to filter content by space membership: fetch the members from spaces, then keep only the rows whose publisher is among them. Such a clause is best written as a self-contained sub-query sharing no variables with the rest, so it runs once rather than once per row.
In a query template the repository is named with the generic address https://w3id.org/np/l/nanopub-query-1.1/repo/…, which resolves to whichever instance answers, never with the name of one server.
Calling a query
Every query template is also an API: https://query.knowledgepixels.com/api/<artifact code>/<query name>?resource=… runs it with the given parameters. The format of the answer follows the request's Accept header. A browser gets XML, which most show as an empty page, so add .csv or .json to the query name to see the rows there. Each repository also has a SPARQL editor of its own, linked from the repository's page on the service.
Scripts and bots are better served by https://router.knowledgepixels.com/query/…, which forwards each request to a query instance that is currently healthy. Two calls may then reach different instances, so a nanopublication published a moment ago can be visible to one and not yet to the next. The test network has a query service of its own, https://test.query.knowledgepixels.com/, which sees only what was published there.
This page is a copy of the topic Query endpoints and repositories of the Nanopublication Docs. Each paragraph is a nanopublication. In Nanodash you also find their examples, related paragraphs, and version history, and members of the nanopub space can edit them there.