Quickstart¶
This walkthrough uses a local development installation to create an instance, publish it and query it. You need
Docker, curl and jq.
1. Start MarmotGraph¶
Follow Development setup to start the infrastructure and Core. Afterwards, Core is available at http://localhost:8000.
For local use only
The credentials below are hard coded in the development setup. Never reuse them in a deployment.
2. Get an access token¶
Every API call needs a bearer token. The development setup provides a service account with administrator rights:
export CORE=http://localhost:8000/v4
export TOKEN=$(curl -s http://localhost:9001/realms/marmotgraph/protocol/openid-connect/token \
-d grant_type=client_credentials \
-d client_id=demo-data-uploader \
-d client_secret=demoDataUpload | jq -r .access_token)
To explore interactively, open the Swagger UI at http://localhost:8000/swagger-ui/index.html and log in as admin
with the password helloMarmotGraph.
3. Create an instance¶
export ID=$(curl -s -X POST "$CORE/instances?space=quickstart" \
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{
"@type": "https://example.org/types/Book",
"https://example.org/properties/title": "Notes on the Analytical Engine"
}' | jq -r '.data."@id"')
echo $ID
The space quickstart and the type Book didn't exist before. Core created them for you.
4. Read it back¶
The same request with stage=RELEASED fails, because the instance hasn't been released yet.
5. Give the type a readable label¶
curl -s -X PUT "$CORE/types/specification?type=https://example.org/types/Book" \
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{
"name": "Book",
"color": "#00897b",
"labelProperty": "https://example.org/properties/title"
}'
6. Release it¶
curl -s -X PUT "$CORE/instances/$ID/release" -H "Authorization: Bearer $TOKEN"
curl -s "$CORE/instances/$ID?stage=RELEASED" -H "Authorization: Bearer $TOKEN" | jq .data
7. Query it¶
curl -s -X POST "$CORE/queries?stage=RELEASED" \
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{
"meta": {"type": "https://example.org/types/Book"},
"structure": [
{"propertyName": "title", "path": "https://example.org/properties/title"}
]
}' | jq .data
Next steps¶
- Understand the response format, pagination and errors.
- Prefer Python or Java? Use one of the SDKs.
- Explore the demo data: the development setup loads a sample graph into the space
demo, including validation schemas and scopes.