# Get Started
## For Developers
In case you have little to no experience with RDF you might want to read the [RDF Primer](https://www.w3.org/TR/rdf11-primer/) first, which gives a good basic introduction to the concepts of RDF.
### Load RDF Data in your Application
To interact with RDF, we need a RDF equivalent of `JSON.parse()`, but instead of JSON we load RDF from an existing resource.
#### Load from a File
https://github.com/rdf-ext/rdf-utils-fs
This example loads a local RDF file and parses the data into a dataset. It can parse common RDF formats automatically.
```javascript=
const fromFile = require('rdf-utils-fs/fromFile')
const stream = fromFile('example.ttl')
stream.on('data', quad => {
console.log(quad.subject.value)
})
```
#### Load from HTTP
https://github.com/rdfjs-base/fetch
This example loads an RDF file available on a HTTP resource and parses the data into a dataset. It can parse common RDF formats automatically.
```javascript=
const fetch = require('@rdfjs/fetch')
const res = await fetch('http://www.w3.org/2000/01/rdf-schema')
const dataset = await res.dataset())
for (const quad of dataset) {
console.log(quad.subject.value)
}
```
#### Load from SPARQL Endpoint
https://www.npmjs.com/package/sparql-http-client
This example is using the [SPARQL 1.1 Query Language](https://www.w3.org/TR/sparql11-query/), in particular a [CONSTRUCT](https://www.w3.org/TR/sparql11-query/#construct) query that returns an RDF graph.
```javascript=
const SparqlCient = require('sparql-http-client')
const client = new SparqlClient({ endpointUrl: '' })
const stream = client.query.construct('CONSTRUCT')
stream.on('data', quad => {
console.log(quad.value)
})
```
#### Load from SPARQL Graph Store
https://www.npmjs.com/package/sparql-http-client
This example is using the [SPARQL 1.1 Graph Store HTTP Protocol](http://www.w3.org/TR/sparql11-http-rdf-update/), which is an easy way to fetch a complete graph from an endpoint.
```javascript=
const SparqlCient = require('sparql-http-client')
const client = new SparqlClient({ storeUrl: '' })
const stream = client.store.get('http://example.org/graph')
stream.on('data', quad => {
console.log(quad.value)
})
```
#### Load into a dataset structure
TODO ich denke hier sollten wir noch zeigen wie wir von den oberen Beispielen in ein Dataset kommen
### Interact on RDF Data in your Application
#### Understand Namespaces
```javascript=
const namespace = require('@rdfjs/namespace')
const ns = {
schema: namespace('http://schema.org/'),
rdf: namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#')
}
// create given name named node
const givenName = ns.schema.givenName
const type = ns.rdf.type
```
https://github.com/rdfjs-base/namespace
#### Traverse a RDF Graph
https://github.com/rdf-ext/clownface
```javascript=
const cf = require('clownface')
const fetch = require('@rdfjs/fetch')
const namespace = require('@rdfjs/namespace')
const ns = {
schema: namespace('http://schema.org/'),
rdf: namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#')
}
const dataset = await fetch('http://zazuko.github.io/tbbt-ld/dist/tbbt.nt')
.then(response => response.dataset())
const tbbt = cf({ dataset })
const stuartBloom = tbbt.namedNode('http://localhost:8080/data/person/stuart-bloom')
stuartBloom
.out(ns.schema.knows')
.map((person) => {
const personalInformation = person.out([
ns.schema.givenName,
ns.schema.familyName
])
return personalInformation.values.join(' ')
})
.join(', ')
```
#### Create a new graph to the Clownface Library
https://github.com/rdf-ext/clownface
```javascript=
const cf = require('clownface')
const rdf = require('rdf-ext')
const namespace = require('@rdfjs/namespace')
const ns = {
schema: namespace('http://schema.org/'),
rdf: namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#')
}
const graph = cf({ dataset: rdf.dataset() })
graph
.namedNode('http://example.org/zazuko')
.addOut(ns.rdf.type, ns.schema.Organisation)
.addOut(ns.rdf.name, 'Zazuko')
```
### Persist RDF to Disk or Store
https://github.com/rdf-ext/rdf-utils-fs
```javascript=
const toFile = require('rdf-utils-fs/toFile')
await toFile(dataset.toStream())
```
### Analytics on the RDF Data
#### Run SPARQL Queries
https://www.npmjs.com/package/sparql-http-client
```javascript=
const SparqlCient = require('sparql-http-client')
const client = new SparqlClient({ endpointUrl: '' })
const stream = client.query.select('SELECT')
stream.on('data', row => {
console.log(row.name.value)
})
```
#### Create a Graphic from RDF Data
d3-sparql example.
### Futher documentation
To dive deeper into the topics please read.
https://github.com/rdf-ext
https://github.com/rdfjs-base/
https://github.com/rdf-ext/documentation
## For Domain Specialists
## For Decision Makers