opencitations / api

Software for creating REST API
1 stars 1 forks source link

Parameter for excluding prefix #2

Open barney-walker opened 5 years ago

barney-walker commented 5 years ago

Is there a parameter I can send that will leave out the "coci => " prefix in the response fields? It makes it trickier to parse the results and I don't trust that my regular expressions won't be fragile to some case I haven't anticipated.

essepuntato commented 5 years ago

Hi @barney-walker

First, thanks for writing me.

Actually, in the "index" API, the prefixes are crucial in order to understand where such a piece of information is actually coming from. For instance, it would be possible that a citation between two papers is actually included in two distinct indexes. In that case, you need to actually know from where they are coming from.

Currently, you can think of using a specific solution for at least ask the API to separate such prefixes, by means of the "json" parameter (it works only if JSON is the return format).

https://w3id.org/oc/index/api/v1/citations/10.1002/adfm.201505328?json=dict(%22%20=%3E%20%22,citing,source,value).dict(%22%20=%3E%20%22,cited,source,value)

As you can see, the result in the fields "citing" and "cited" will be structured so as to make everything easily accessible via JSON.

I'm planning to extend the tool behind the API so as to make also more custom parameters, that in principle would allow one removing something from all the fields, though. Thus, thanks for the input!