Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No TLDRs when using Data Partner's API #43

Closed
alexmaehon opened this issue Nov 21, 2022 · 4 comments
Closed

No TLDRs when using Data Partner's API #43

alexmaehon opened this issue Nov 21, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@alexmaehon
Copy link

Regular use of 'sch.get_paper' has TLDR, while access through Data Partner's API does not.
What's wrong?

@danielnsilva
Copy link
Owner

Maybe this was caused by Partner's default URL, which calls the API deprecating endpoints.

DEFAULT_PARTNER_API_URL = 'https://partner.semanticscholar.org/v1'

Try setting a custom URL.

from semanticscholar import SemanticScholar
s2_api_key = '40-CharacterPrivateKeyProvidedToPartners'
s2_api_url = 'https://partner.semanticscholar.org/graph/v1'
sch = SemanticScholar(api_key=s2_api_key, api_url=s2_api_url)

Please let me know if this works for you.

@alexmaehon
Copy link
Author

It works, thank you!

@danielnsilva danielnsilva added the bug Something isn't working label Nov 22, 2022
@xinyi6666
Copy link

@danielnsilva I encountered the following error message when I try
results = sch.search_paper('Computing Machinery and Intelligence')
without custom url. It went away after I added the custom url. Probably worthy adding the custom url part in the README?


---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/tmp/ipykernel_74557/4191216135.py in <module>
----> 1 results = sch.search_paper('Computing Machinery and Intelligence')

~/.local/lib/python3.8/site-packages/semanticscholar/SemanticScholar.py in search_paper(self, query, year, fields_of_study, fields, limit)
    141             query += f'&fields_of_study={fields_of_study}'
    142 
--> 143         results = PaginatedResults(
    144                 self._requester,
    145                 Paper,

~/.local/lib/python3.8/site-packages/semanticscholar/PaginatedResults.py in __init__(self, requester, data_type, url, query, fields, limit, headers)
     36         self._items = []
     37 
---> 38         self.__get_next_page()
     39 
     40     @property

~/.local/lib/python3.8/site-packages/semanticscholar/PaginatedResults.py in __get_next_page(self)
    101             )
    102 
--> 103         self._data = results['data']
    104         self._total = results['total']
    105         self._offset = results['offset']

@danielnsilva
Copy link
Owner

Yes, but changing the default URL in the code is the best solution. I will do that shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants