Open smaret opened 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.
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.
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:
Ask the API provider to make a token for biblio.el. This works if tokens are usually per-application, and you need to get permission from the provider to publish that token publicly. That's what's done in the IEEE backend.
Let users provide a token, but degrade gracefully if they don't; that's what we do in Crossref, because crossfreff still allows anonymous queries
Add a defcustom that lets users specify their token, and fail if that's not properly set. This is how the bibsonomy backend works.
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?
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.
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