JSON schema for content negotiation

Hi @ifarley and thanks for the quick responses!

After talking with others on the support team, we believe you might be asking about a grants example, like this one: https //api crossref org/works/10.46936/cpcy.proj.2019.50733/60006578

The example you’ve given here is similar to what I’ve been looking at – a DOI representing a grant.
The data structure under message has keys including award (value: “50733”) and project (value: nested data structure that includes project-title and funding).

The documentation of the /works/{doi} endpoint has an example 200 response and the model (WorkMessage) for that response, with the value of the message key given as a Work model. If you expand the Work model to see the keys/values beneath it, neither the award key nor the project key exist, and several of the starred (presumably required) fields do not exist in the object under the message key from the API URL you provided.

I am writing a parser for the CrossRef API to map the output to my local schema. I have a list of DOIs to look up, and I won’t know in advance whether they represent grants, datasets, journal articles, etc., etc. I need to know what data structures the endpoint outputs so I can extract the appropriate information from the API response. If I build a parser that assumes that the output of the /works/{doi} endpoint is always structured as a Work, as documented at api crossref org/swagger-ui/index.html#model-Work, I’ll obviously miss all the funding info.

Thus my question is: how can a parser know, without human intervention, what schema the REST API output from /works/{doi} is using?

1 Like