-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSPARQLES_APIS.py
56 lines (54 loc) · 1.93 KB
/
SPARQLES_APIS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import requests
def get_endpoint_info(url):
try:
response = requests.get(f'https://sparqles.demo.openlinksw.com/api/endpoint/info?uri={url}')
if response.status_code == 200:
response = response.json()
if len(response) == 0:
return 'KG not found on SPARQLES'
else:
enpoint_status = response[0].get('availability').get('upNow')
return enpoint_status
else:
print("Connection failed to SPARQLES")
return False
except:
print('Connection failed to SPARQLES')
return False
def get_void_availability(url):
try:
response = requests.get(f"https://sparqles.demo.openlinksw.com/api/endpoint/info?uri={url}")
if response.status_code == 200:
response = response.json()
if len(response) == 0:
return 'KG not found on SPARQLES'
else:
void_list = response[0].get('discoverability').get('VoIDDescription')
for el in void_list:
void_status = el.get('value')
if void_status == True:
return True
return False
else:
print("Connection failed to SPARQLES")
return False
except:
print('Connection failed to SPARQLES')
return False
def get_all_sparql_link():
try:
response = requests.get("https://sparqles.demo.openlinksw.com/api/endpoint/list")
if response.status_code == 200:
response = response.json()
if len(response) == 0:
return []
else:
sparqles_links = []
for kg in response:
datasets = kg['datasets']
sparqles_links.append(datasets[0]['uri'])
return sparqles_links
else:
return []
except:
return []