create a bibtex entry from crossref api in matlab

To create a BibTeX entry from the CrossRef API in MATLAB, you can use the following steps:

  1. Install the "webread" function in MATLAB if you haven't already. You can install it using the Package Manager by searching for "HTTP Toolbox."

  2. Use the "webread" function to retrieve the metadata of the desired publication from the CrossRef API. You need to provide the DOI (Digital Object Identifier) of the publication as an input to the API.

main.m
doi = '10.1109/ACCESS.2020.3005231';
url = ['https://api.crossref.org/works/',doi];
response = webread(url);
109 chars
4 lines
  1. Extract the necessary information from the API response. Usually, the API response contains multiple fields, including the title, authors, journal name, year, and other metadata. You can extract the required fields using the dot notation.
main.m
title = response.message.title;
authors = response.message.author;
journal = response.message['container-title'];
year = response.message['published-online']['date-parts'][1];
176 chars
5 lines
  1. Construct the BibTeX entry using the extracted information.
main.m
bibtexEntry = sprintf('@article{%s,\n', doi);
bibtexEntry = [bibtexEntry, '  title = {', title, '},\n'];
bibtexEntry = [bibtexEntry, '  author = {', authors, '},\n'];
bibtexEntry = [bibtexEntry, '  journal = {', journal, '},\n'];
bibtexEntry = [bibtexEntry, '  year = {', num2str(year), '}\n'];
bibtexEntry = [bibtexEntry, '}'];
329 chars
7 lines

Make sure to replace the doi variable with the actual DOI of the publication you want to retrieve.

  1. Optionally, you can save the BibTeX entry to a file.
main.m
filename = 'output.bib';
fileID = fopen(filename, 'w');
fprintf(fileID, bibtexEntry);
fclose(fileID);
102 chars
5 lines

Remember to replace the filename variable with the desired name and location of the output file.

That's it! You should now have a BibTeX entry created from the CrossRef API in MATLAB.

related categories

gistlibby LogSnag