cpitclaudel / biblio.el

Browse and import bibliographic references from CrossRef, DBLP, HAL, arXiv, Dissemin, and doi.org from Emacs
GNU General Public License v3.0
180 stars 14 forks source link

Feature request: support for ADS #28

Open smaret opened 5 years ago

smaret commented 5 years ago

It would be great if biblio.el could support the Astrophysical Data System (ADS). ADS is the main bibliographic database for Astronomy and Astrophysics. It has a well-documented public API.

CC @adsabs @aaccomazzi @ehenneken @kelockhart @krisbukovi @romanchyla @seasidesparrow @spacemansteve @thostetler

cpitclaudel commented 5 years ago

Sound great to me. I've tried to do my very best to make it easy to add new backends (see https://github.com/cpitclaudel/biblio.el#extending-biblioel), but I realize the task can still be a bit intimidating. When writing a new backend, I usually start by copying an existing one, and editing the relevant bits one by one.

Would you like to give it a try? I can assist if you run into issues.

smaret commented 4 years ago

Sorry for not responding earlier. I can give it a try.

The first problem I ran into is authentification: ADS requires an auth token that must be passed in the HTTP header, e.g:

curl -v -H "Authorization: Bearer <token>" 'https://api.adsabs.harvard.edu/v1/search/query?q=star'

How can I do this in biblio.el? None of the other backend seem to require an auth token.

cpitclaudel commented 4 years ago

None of the other backend seem to require an auth token.

The IEEE and Crossref backends do, actually, and so does the biblio-bibsonomy package, IIRC. There are three ways to go:

smaret commented 4 years ago

Thanks for your answer! I've seen the token in IEEE and Crossref, but if I understand correctly, in both cases the token as passed in the URL itself, for example:

http://ieeexploreapi.ieee.org/api/v1/search/articles?querytext=xxx&apikey=xxx

This is different for the ADS: according to the documentation, the auth token must be passed in the HTTP header. There is indeed a url-request-extra-headers variable that could be used for that:

url-request-extra-headers is a variable defined in ‘url-vars.el’.
Its value is nil

Documentation:
A list of extra headers to send with the next request.
Should be an assoc list of headers/contents.

I also had a look biblio-bibliosonomy.el code and it uses a different implementation:

  (format "https://%s:%s@%s/posts?resourcetype=bibtex&format=bibtex&search=%s"
          biblio-bibsonomy-username biblio-bibsonomy-api-key
          biblio-bibsonomy--api-url-root (url-encode-url query)))

However, this appears to be deprecated so I'm not sure if that's a good idea?

cpitclaudel commented 4 years ago

Hmm, excellent point. There's no support for this in biblio.el right now. The best way would be to change the value returned by 'url. We could allow it to return a function, or we could use something slightly less generic and allow a url with extra headers.