Skip to content

Commit 58b8e65

Browse files
committed
Update OEKG-SPARQL WEB API docs
1 parent cb2ffc3 commit 58b8e65

File tree

1 file changed

+11
-2
lines changed
  • docs/oeplatform-code/web-api/oekg-api

1 file changed

+11
-2
lines changed

docs/oeplatform-code/web-api/oekg-api/index.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,28 @@ In this document we describe how you can access the contents of the OEKG via Web
1515

1616
Here is an example of how to query the Open Energy Knowledge Graph (OEKG) using SPARQL using python and the requests library for http requests.
1717

18+
!!! Info "OEP-API Token"
19+
20+
For authentication with the OEP-REST-API you have to register on <https://openenergyplatform.org/accounts/signup/> or sign in with you institution.
21+
Once you are registered you can find your API Token in you Profile page under the "Settings" Tab. Clicks "Show Token" and copy the hash value.
22+
23+
See our more detailed guide on [how to get started with the OpenEnergyPlatform](https://openenergyplatform.github.io/academy/courses/02_start/#how-do-i-get-started-with-the-oep).
24+
1825
```python
1926
import requests
2027

28+
OEP_API_TOKEN = "<Add-Your-Token>"
29+
HEADER = {"Authorization": f"Token {OEP_API_TOKEN}"}
2130
sparql_endpoint = "https://openenergy-platform.org/api/v0/oekg/sparql/"
2231
payload = {
2332
"query": """SELECT ?s ?p ?o
2433
WHERE {
2534
?s ?p ?o
26-
}"""
35+
}""",
2736
"format": "json"
2837
}
2938

30-
r = requests.post(url=sparql_endpoint, json=payload)
39+
r = requests.post(url=sparql_endpoint, json=payload, headers=HEADER)
3140
print(r.json())
3241
```
3342

0 commit comments

Comments
 (0)