opencitations / api

Software for creating REST API
1 stars 1 forks source link

Citation count API returns 0 for DOI that does not exist #5

Open kdouda opened 3 years ago

kdouda commented 3 years ago

The citation-count API route returns 0 if no citation with the provided DOI exists. This requires an extra call to the metadata route to verify if the DOI is present in the OCI database or not, which slows down the process. The API call should (imho) return a different status code (404?) and not return a 0, instead either return a null or any non-numerical value (ie N/A).

For example, with a DOI that verifiably does not exist:

https://opencitations.net/index/api/v1/citation-count/10.asdf

returns

[
    {
        "count": "0"
    }
]

Call to the metadata API reveals that the DOI is not known to OCI:

https://opencitations.net/index/api/v1/metadata/10.asdf

I may be able to help with the implementation if needed, but I am not sure if I understand SPARQL well enough.