fabiobatalha / crossrefapi

A python library that implements the Crossref API.
BSD 2-Clause "Simplified" License
280 stars 44 forks source link

Configuration for different API endpoint (test crossref site) #11

Closed sjtower closed 7 years ago

sjtower commented 7 years ago

It would be useful if you could set the API url for crossref API requests.

For example, as we are testing, it would be good to make requests to test.crossref.org instead of api.crossref.org so that we are not testing using the production site.

Thanks!

fabiobatalha commented 7 years ago

Hello @sjtower

Do you know the correct test url for the Crossref API?

it seems the test.crossref.org is not working and there are no references for this in their documentation. https://github.com/CrossRef/rest-api-doc

by the way, you can just redefine de constant API of the restful module to redefine the API domain.


Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.0.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from crossref.restful import Works

In [2]: from crossref import restful

In [3]: restful.API
Out[3]: 'api.crossref.org'

In [4]: Works().filter(has_funder='true', has_license='true').url
Out[4]: 'https://api.crossref.org/works?filter=has-license%3Atrue%2Chas-funder%3Atrue'

In [5]: restful.API = 'test.crossref.org'

In [6]: Works().filter(has_funder='true', has_license='true').url
Out[6]: 'https://test.crossref.org/works?filter=has-license%3Atrue%2Chas-funder%3Atrue'
sjtower commented 7 years ago

Thanks for the response. I realized that I don't know the url for the test Crossref API, or if it even exists! I'm talking to Crossref now. Please feel free to close. Thanks again.