Initially this library is designed to make RDF queries to Solid PODs, but it can be easily extended with the methods that it already has. I encourage you to participate on its growth and spread. Let's make rdf-query the main RDF library and unify all RDF related staff in it!
let rdfq = require("rdf-query");
Or
import {...} from "rdf-query";
Method | Description |
---|---|
getName(profile) | Returns the name of the profile passed as a parameter |
getImage(profile) | Returns the URI of the image of the specified profile |
getFriends(profile) | Returns an array of URIs, that represent the list of friends of the profile specified as a parameter |
getInfoFromProfile(profile) | Returns the name, friends (as URIs), and image (as URI) from the specified profile |
getMultipleValuesFromFoaf(profile, field) | Returns an array of values from the foaf namespace |
getSingleValueFromFoaf(profile, field) | Returns an object containing the value from the foaf namespace |
getSingleValueFromVcard(profile, field) | Returns an object containing the value from the vcard namespace |
getMultipleValuesFromNamespace(profile, field, ns) | Returns an array containing objects with the information of the field you requested, from the specified namespace |
getSingleValueFromNamespace(profile, field, ns) | Returns an object containing the value of the field you requested, from the specified namespace |
This would be the code to get the name of a user, given his/her webId
const rdf = require("rdf-query");
rdf
.getName("https://timbl.solid.community/profile/card#me")
.then(name => console.log(name.value));
Which will give us:
"Tim Berners-Lee (solid.community)";
To get the URIs of the friends of a user, we will use this code:
rdf
.getFriends("https://timbl.solid.community/profile/card#me")
.then(friends => {
friends.map(friend => {
console.log(friend.object.value);
});
});
Which returns:
"http://www.w3.org/People/Berners-Lee/card#i";
"https://angelo.veltens.org/profile/card#me";
"https://gaia.solid.community/";
"https://jollyorc.solid.community/profile/card#me";
"https://melvin.solid.community/profile/card#me";
"https://nada.solid.community/profile/card#me";
"https://spoggy.solid.community/profile/card#me";