Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[bioontology-support] BioPortal API Key for SPARQL queries

Michael Dorf mdorf at stanford.edu
Fri Apr 28 16:01:09 PDT 2017


Hi Maulik,

I am not intimately familiar with our SPARQL endpoint API, but a cursory look at the documentation (I looked at the examples in Java and Ruby) reveal that the API key needs to be passed as a query parameter rather than a header var:

https://github.com/ncbo/sparql-code-examples/blob/master/java/src/org/ncbo/stanford/sparql/examples/GetAllTerms.java#L47
https://github.com/ncbo/sparql-code-examples/blob/master/ruby/sparql1.rb#L22

Have you tried passing it that way?

Misha


On Apr 27, 2017, at 3:12 PM, Maulik Kamdar <maulikrk at stanford.edu<mailto:maulikrk at stanford.edu>> wrote:


Hi Jennifer, Michael,

I was wondering if I need to submit my BioPortal API key when I execute SPARQL queries against the BioPortal endpoint?

I am using a simple python module SPARQLWrapper to execute queries and it seems to be failing for BioPortal, whereas it works for most other SPARQL endpoints in the Linked Data cloud. I tried including the Authorization key value pair (or should I have username-API key pair?) -- it is similar to when I used to execute GET Requests against the BioPortal API. Please let me know, if I am doing anything incorrect!

Thanks!

-- code below

def get_simple_results_normal(endpoint, query):
    sparql = SPARQLWrapper(endpoint)
    sparql.setQuery(query)
    sparql.setReturnFormat(JSON)
    sparql.addParameter('Authorization', 'apikey token=' + API_KEY)
    try:
        results = sparql.query().convert()
    except Exception:
        print "Error encountered for " + query
        return None
    return results


qe4 = "http://sparql.bioontology.org/sparql/"<http://sparql.bioontology.org/sparql/>

query5 = "PREFIX omv: <http://omv.ontoware.org/2005/05/ontology#><http://omv.ontoware.org/2005/05/ontology#> SELECT ?ont ?name ?acr WHERE { ?ont a omv:Ontology . ?ont omv:acronym ?acr . ?ont omv:name ?name .}"

res5 = get_simple_results_normal(qe4, query5)
Error encountered for PREFIX omv: <http://omv.ontoware.org/2005/05/ontology#><http://omv.ontoware.org/2005/05/ontology#> SELECT ?ont ?name ?acr WHERE { ?ont a omv:Ontology . ?ont omv:acronym ?acr . ?ont omv:name ?name .}

--
----------------
Regards,
Maulik R. Kamdar
Stanford Center for Biomedical Informatics Research
Stanford University School of Medicine
http://www.stanford.edu/~maulikrk
Google Scholar: https://goo.gl/Q7AFLl

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/bioontology-support/attachments/20170428/605d33d6/attachment.html>


More information about the bioontology-support mailing list