fabiobatalha / crossrefapi

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

order of sample and filter produces different API calls #15

Closed gbilder closed 6 years ago

gbilder commented 6 years ago

Does not seem to like filter before sample, but does not complain:

>>>works.filter(type='book').sample(10).url
https://api.crossref.org/works?sample=10

Sample before filter works as expected:

>>>works.sample(10).filter(type='book').url
https://api.crossref.org/works?sample=10&filter=type%3Abook
fabiobatalha commented 6 years ago

@gbilder

I will fix it.

fabiobatalha commented 6 years ago

Hello @gbilder

It seems it is a bug from previous versions. Are you trying with version 1.2.0?

Python 3.6.3 (default, Oct  3 2017, 21:45:48) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from crossref.restful import Works

In [2]: works = Works()

In [3]: works.filter(type='book').sample(10).url
Out[3]: 'https://api.crossref.org/works?filter=type%3Abook&sample=10'

In [4]: works.sample(10).filter(type='book').url
Out[4]: 'https://api.crossref.org/works?filter=type%3Abook&sample=10'