---
question: How do I export workspace triples from Knowledge Graph?
kind: task
via_web: available
via_cli: na
via_python: available
via_api: available
via_config: na
ref_web: Knowledge Graph › File › Export Triples…
ref_python: triple_store.export
ref_api: GET /api/graph/export
next:
  - /capabilities/build/knowledge-graph/add-data
  - /capabilities/build/knowledge-graph/explore-the-graph
---

# Export data

An export writes one named graph to a file: Turtle (`.ttl`), OWL as RDF/XML (`.owl`) or N-Triples (`.nt`).

## Web UI

### Prepare the export

In the Nexus workspace, open **Knowledge Graph**, then **File › Export Triples…**. Pick the graph and the format, then **Export as .ttl** (the button follows the format).

![Knowledge Graph export screen](/abi/Screenshot_Graph_Export.png)

*Knowledge Graph › File › Export Triples…: pick a graph and a format, then prepare the download.*

### Download it

The export runs in the background. In **Export History**, a row goes from Processing to Ready, or to Error with the message on hover. Choose **Download** on a Ready row.

The history is kept in this browser for 7 days. Another browser or another member does not see it.

## CLI

Not applicable. There is no `abi` command that exports a graph. `abi stack snapshot` copies the Docker volumes, Fuseki's included, as a backup; it is not an RDF file. Use another tab on this page.

## Python

The module lists `TripleStoreService` in its dependencies: see [Add data](/user-guide/build/knowledge-graph/add-data?via=python).

### Stream the graph into a file

```python
from rdflib import Graph, URIRef

store = self.engine.services.triple_store
graph = Graph()
with store.export(URIRef("http://ontology.naas.ai/graph/my_module")) as triples:
    for triple in triples:
        graph.add(triple)
graph.serialize("my_module.ttl", format="turtle")
```

`export(graph_name)` yields the triples of one named graph. Without a name it yields the whole store. A pipeline's `run` already returns an `rdflib.Graph`: call `serialize` on it to save what it built. See [Run a pipeline](/user-guide/build/pipelines/run-a-pipeline).

## REST API

The graph routes of the Nexus API. Auth: a Nexus session of a workspace member (`POST /api/auth/login` returns the access token). The workspace must be allowed to read the graph.

### Download the file

```bash
curl -OJ "http://localhost:9879/api/graph/export?workspace_id=$WORKSPACE_ID&graph_uri=http://ontology.naas.ai/graph/my_module&format=ttl" \
  -H "Authorization: Bearer $NEXUS_TOKEN"
```

`format` is `ttl`, `owl` or `nt`. The file is named after the last segment of the graph IRI. The headers `X-Triple-Count` and `X-Named-Individual-Count` give the counts.

## Config

Not applicable. An export is an action, not a setting.
