Java example to retrieve metadata?

Hello,

I am trying to get the main metadatas (type, title, date, authors, …) of a document via the CrossRef API. I am trying to develop it in JAVA. Did any of you already develop some JAVA codes that queries the CrossRef API and would accept to share it ?

If no, maybe you could still help me. I am querying the API if the following way :

Hello,

I am trying to get the main metadatas (type, title, date, authors, …) of a document via the CrossRef API. I am trying to develop it in JAVA. Did any of you already develop some JAVA codes that queries the CrossRef API and would accept to share it ?

If no, maybe you could still help me. I am querying the API if the following way :

doi crossref org / search/doi?pid=[mogin/password]&format=unixsd&doi=10.1787/9789264275928-fr

Then I using expressions to get the metadata. My main problem is that the structure of the XML is depending of the type of the document. For example, the title will be store in the following path in case of In press articles:

/crossref_result/query_result/body/query/doi_record/crossref/posted_content/titles/title

But it will be stored in the following path in case of published articles:

/crossref_result/query_result/body/query/doi_record/crossref/journal/journal_article/titles/title

How do you manage all these path for all the different kind of documents?

Thanks,
Fred

Hi Fred,

Crossref hasn’t developed a Java library or Java-based application for metadata retrieval via our API. Perhaps other API users who come across this post might be aware of one developed by someone else.

If no, maybe you could still help me. I am querying the API if the following way :

doi crossref org / search/doi?pid=[mogin/password]&format=unixsd&doi=10.1787/9789264275928-fr

So, that’s a query against our older, XML API. You might have more luck using the REST API instead. You can find the full documentation for the REST API at api.crossref.org

My main problem is that the structure of the XML is depending of the type of the document.

This will always be true. Not only because different metadata elements are supported in different content types (e.g. a book can have an ISBN, but a preprint will not; a conference proceedings will have a conference date, but no other types do, etc.) but also because only a relatively small amount of metadata is strictly required, and publishers vary greatly from one to another regarding how much of the optional metadata they choose to supply.

However, using the REST API, if you’re only looking for a small subset of the metadata elements, you can use the ‘select’ function to limit the results to just those elements.

For, example, this is the equivalent query in the REST API to the example you gave from the REST API, which shows the full metadata record for 10.1787/9789264275928-fr
https://0-api-crossref-org.libus.csd.mu.edu/works/10.1787/9789264275928-fr

However, if you were to query all works associated with that title, by filtering by its ISBN like this
https://0-api-crossref-org.libus.csd.mu.edu/works?filter=isbn:9789264275911

You could then use ‘select’ to return, for example, just the DOIs, title, container (i.e. book) title, and authors like this
https://0-api-crossref-org.libus.csd.mu.edu/works?filter=isbn:9789264275911&select=DOI,title,container-title,author

Note, that the book DOI 10.1787/9789264275928-fr doesn’t have a container title, because the book itself is the container work.

I’m not sure if that will solve your problem entirely, but it might simplify it.

Best,
Shayn

2 Likes

Hi Shayn,

thanks a lot for your answer. Your new REST API seems much more easier to use ! That’s exactly what I needed, thanks !

Best,
Fred

1 Like