Skip to content

Commit

Permalink
Add ability to specify request parameters to "all" function.
Browse files Browse the repository at this point in the history
At present, the request parameters are always set to an empty dictionary. However, the Crossref Labs API, which provides additional experimental functionality, has various options that are controlled by querystring parameters. It is, therefore, useful to have a way to set this as it allows for the usage of these aternative API endpoints.

An example usage might be:

    members = Members(
                etiquette=my_etiquette,
            )
    crossref.restful.API = "api.labs.crossref.org"
    members.ENDPOINT = "members"

    members.all(request_params={"rows":"all", "simple":"True"})

More about the Crossref Labs API can be found at https://api.labs.crossref.org and https://api.labs.crossref.org/docs.

Disclaimer: the author of this commit, Martin Paul Eve, works for Crossref. This does not imply correctness or safety of the submitted code, which is subject to the disclaimers of the LICENSE file.
  • Loading branch information
MartinPaulEve authored and fabiobatalha committed Jul 12, 2023
1 parent 839f69f commit 714e296
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crossref/restful.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,12 @@ def url(self):

return req.url

def all(self):
def all(self, request_params: dict = None):
context = str(self.context)
request_url = build_url_endpoint(self.ENDPOINT, context)
request_params = {}

if request_params is None:
request_params = {}

return iter(
self.__class__(
Expand Down

0 comments on commit 714e296

Please sign in to comment.