Skip to main content

Notice

We are in the process of rolling out a soft launch of the RDA website, which includes a new member platform. Existing RDA members PLEASE REACTIVATE YOUR ACCOUNT using this link: https://rda-login.wicketcloud.com/users/confirmation. Visitors may encounter functionality issues with group pages, navigation, missing content, broken links, etc. As you explore the new site, please provide your feedback using the UserSnap tool on the bottom right corner of each page. Thank you for your understanding and support as we work through all issues as quickly as possible. Stay updated about upcoming features and functionalities: https://www.rd-alliance.org/rda-web-platform-upcoming-features-and-functionalities/

Simple Python client

  • Creator
    Discussion
  • #119934

    Dear all,
    We talked about clients accessing the collection API – I wrote a short
    Python script which uses only the two functions “Give me all
    collections” and “Give me all members of a collection” to create a
    (recursive) graph out of the content of a collectors API instance in Dot
    language.
    Visualized with GraphViz, the graph looks like this:
    https://github.com/TomZastrow/collection-api/blob/master/graph.png
    Here is the Python script:
    https://github.com/TomZastrow/collection-api/blob/master/recursion.py
    In general, this works only with collections on a local instance because
    we can’t detect if a member of collection is a collection somewhere
    else. Would need to integrate PIT API functionality for that.
    Best,
    Tom

  • Author
    Replies
  • #132093

    Hi Tom,
    neat and simple – this will make a good slide for the use case discussion!
    Best, Tobias

  • #132081

    Dear Thomas,
    unfortunately this client only works, if the base (in this case
    https://thomas-zastrow.de/collections/api.php/collections/) presents a
    collection, containing nothing else than all subsequent collections in
    play. So in some sense already the base needs to have a list of all the
    recursion contained in the collection tree. For instance if you would
    move demoCol3 from demoCol1 to demoCol2 and call demoCol1, you will not
    get anything below demoCol2, e.g. demoCol3.
    You need some sort of recursive function call here, like in the script
    attached.

  • #132079

    Hi Ulrich!
    Thanks for the script, and … yes and no 🙂
    My script is also working fine when for example, as you suggested, I
    move the “demoCol3” from “demoCol1” to “demoCol2”:
    http://thomas-zastrow.de/collections/graph.png
    But of course you are right, the script only works if it is uses the
    “root” of all collections as starting point and then can go through all
    collections and their members. But this is exactly one function our API
    defines 🙂 … if the starting point is just an arbitrary collection,
    then indeed your script does the work.
    Anyway, do you want to put your script also into the GitHub repository?
    If so, I can give you write access.
    Best,
    Tom

Log in to reply.