Skip to content

Use PUT for ScienceDirectSearch() #395

@nils-herrmann

Description

@nils-herrmann

The documentation of the ScienceDirectSearch API recommends using the PUT method instead of the GET method. Although the GET method should work it seems that doing something simple like filtering by date does not work:

Consider the example of finding documents with keywords iab-bamf-soep and integration between 2015 and 2020. Doing the query in the website and using the PUT method yields 5 documents.

# There seems no way to filter the results by date
sds = ScienceDirectSearch("iab-bamf-soep AND integration AND date(2015-2020)")
print(f"Number of results: {len(sds.results)}")

sds = ScienceDirectSearch("iab-bamf-soep AND integration", date="2015-2020")
print(f"Number of results: {len(sds.results)}")

sds = ScienceDirectSearch("iab-bamf-soep AND integration AND pub-date bef 2020")
print(f"Number of results: {len(sds.results)}")

24
24
Scopus400Error: Unable to translate query provided: Comparison operator BEF and/or < is not supported!

Any ideas @Michael-E-Rose ?

The implementation of the PUT looks as follows:

url = "https://api.elsevier.com/content/search/sciencedirect"
headers = {"X-ELS-APIKey": scopus_key, "X-ELS-Insttoken": scopus_token}
body = {
    "qs": "iab-bamf-soep AND integration",
    "date": "2015-2020",
    "display": {
        "offset": 0,
        "show": 25,
        "sortBy": "date"
    }
}


res = put(url=url, headers=headers, json=body)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions