Skip to content

Commit 730a580

Browse files
committed
example of introspection usage
1 parent 4bb553b commit 730a580

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

examples/introspection.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This is free and unencumbered software released into the public domain.
2+
# For more information, please refer to <http://unlicense.org/>
3+
#
4+
# This script uses "requests-oauthlib" library
5+
# For more information, please refer to <https://github.com/requests/requests-oauthlib#installation>
6+
import json
7+
import urllib
8+
9+
import requests
10+
from requests_oauthlib import OAuth1
11+
12+
13+
# CHANGE THESE variables
14+
consumer_token = 'consumer_token'
15+
consumer_secret = 'consumer_secret'
16+
access_token = 'access_token'
17+
access_secret = 'access_secret'
18+
graph_iri = 'http://example.com/graph'
19+
20+
21+
oauth = OAuth1(consumer_token, consumer_secret, access_token, access_secret, signature_type='auth_header')
22+
23+
_predicates = requests.get('https://api.grids.by/v1/predicates.json?%s' % (urllib.urlencode({'graph': graph_iri})), auth=oauth)
24+
predicates = json.loads(_predicates.content)
25+
26+
for predicate in predicates:
27+
print(predicate)
28+
29+
_values = requests.get('https://api.grids.by/v1/values.json?%s' % (urllib.urlencode({'graph': graph_iri, 'predicate': predicate})), auth=oauth)
30+
values = json.loads(_values.content)
31+
32+
for value in values:
33+
print("--> %s" % (value))

0 commit comments

Comments
 (0)