Expanding API#10
Conversation
-Changed works to hidden method called get entities so that it works with authors, concepts, institutions, etc.... -Added global PAGE_LIMIT variable -Added method to set_email since it wasn't clear to me initially how to do that.
-Fleshed out author objects -Added fields to ids and years so they work with both authors and works
|
I took a peek at the code and really like the abstraction and introduction of a OpenAlexBaseDataType. Thanks 🤩 I have a lot on my plate right now, so it will probably take me a week or two to take a closer look. |
|
Sounds good. Personally, I would've dropped the two works methods and just made one list of entities method, but wanted to make it backwards compatible with current methods. Also, no worries. I will probably make a few more minor changes in next week or so as I continue to use before you get around to looking at it. |
|
I'm a fan of https://en.wikipedia.org/wiki/KISS_principle?wprov=sfti1 Let's remove redundant methods and keep general ones. |
|
Which ones do you suggest we remove? |
|
Well if it were me, I would probably remove all entity-specific methods and just keep get list of entities, not make it a private method, with an argument for entity type. I didn't write it this way because I didn't want to break what you already had. I would keep the cited,reference, and related works methods--I think they are great. For myself I needed to add the below, which should work with any entity type that supports associated_works (authors, venues, institutions). I needed all the header stuff to make sure it would work for dehydrated objects as well. I'm also going to fool around with a search method if you give me a day or two... |
|
Last couple of thoughts: -Institutions, Venues, and Author fields need to be expanded (but methods have to work with dehydrated values) |
Have you seen the search function in R here? https://github.com/KTH-Library/openalex/blob/main/R/open_alex_restclient.R |
|
Hi Dennis, If you give me less than an hour, I'm going to implement another branch. This one breaks current works functionality by generalizing for entities. The full set of changes I am adding:
Responses to your points:
|
Lots of changes: 1. Remove get_works and replace with universal get_entities 2. Exhaustively fleshed out ALL fields in OpenAlex API. This required making some new enums and classes (i.e., geo) 3. Added dehydrated objects for four core object types. Also added a convenience function hydrate. I had not planned to use dehydrated objects, but it does slow things down and I think it's good to clarify to users why fields are missing. 4. Added basic search functionality 5. Added get associated_works 6. Made explicit set_email method. I needed this to correct the headers using pydantic. Perhaps there is a better way, but I think it's good to allow users to change after construction. TODO: IMPORTANT: 1. More serious unit testing 2. Advanced search, filter, groupby functionality MINOR: 1. If theres a way to not have to do the backoff decorator every time that would be cool. 2.I struggled with the openaccess enum and allowing typing to do None so gave up. 3. I really hate how years are returned. If its possible to parse these as dict of lists rather list of dicts I'd be all for it.
|
Hi Dennis, I'm pretty much done with my rewrite in last major push. This does break existing get_works, but I think it does make API quite robust. I also changed my tune on dehydrated objects--they're added. Best, |
Lots of changes: 1. Remove get_works and replace with universal get_entities 2. Exhaustively fleshed out ALL fields in OpenAlex API. This required making some new enums and classes (i.e., geo) 3. Added dehydrated objects for four core object types. Also added a convenience function hydrate. I had not planned to use dehydrated objects, but it does slow things down and I think it's good to clarify to users why fields are missing. 4. Added basic search functionality 5. Added get associated_works 6. Made explicit set_email method. I needed this to correct the headers using pydantic. Perhaps there is a better way, but I think it's good to allow users to change after construction. TODO: IMPORTANT: 1. More serious unit testing 2. Advanced search, filter, groupby functionality MINOR: 1. If theres a way to not have to do the backoff decorator every time that would be cool. 2.I struggled with the openaccess enum and allowing typing to do None so gave up. 3. I really hate how years are returned. If its possible to parse these as dict of lists rather list of dicts I'd be all for it.
|
Big thanks for your effort. I'll try to make time to review it next week. Since we are still in alpha I don't have a problem with removing get_works() at this point. |
Hi Dennis,
Great API. I made some small changes to make the API more useful to me as a user:
Dunno if this is how you planned to extend things so no worries if this doesn't work for you!
Best,
Bernie