Web based family history software

Question REST API for 2.1

  • yann64
  • Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 2 months ago #1 by yann64
REST API for 2.1 was created by yann64
I would like to interact with webtrees from external applications and websites (there are several use cases I would like to implement).

For now I use a custom made PHP db wrapper fso I can include widgets on a website, and for custom chart generation (in image/PDF format) I directly query the database using a script triggered by the server cron.

Both options are clunky and would be much better if an official REST API was available. So, is there a REST API in v2.1.x?

I can find a message on the forum regarding v2.0 (entry point being client.php at the root directory) but that does not seem to be available in v2.1: www.webtrees.net/index.php/fr/forum/help-for-2-0/3664-using-res

Please Log in or Create an account to join the conversation.

More
2 years 2 months ago #2 by hermann
Replied by hermann on topic REST API for 2.1
There was such a function available in the very old phpGedView. I had some ideas to use this at that time (many years ago), but never finalized that, so I'm would be keen to try it again.

Hermann
Designer of the custom module "Extended Family"

webtrees 2.1.21 (all custom modules installed, PHP 8.3.12, MariaDB 10.6) @ ahnen.hartenthaler.eu

Please Log in or Create an account to join the conversation.

  • bertkoor
  • Offline
  • Platinum Member
  • Platinum Member
  • Greetings from Utrecht, Holland
More
2 years 2 months ago - 2 years 2 months ago #3 by bertkoor
Replied by bertkoor on topic REST API for 2.1
I think the first questions that need to be answered are:

- What data do you want to be returned by REST calls?
- Only allow data retrieval, or also accept modifications?
- What format should the returned data be in? json, xml, html, png, pdf?
- Do you want simple plain REST (fetch data from a repo) or with HATEOS ?


If you model a REST interface directly onto GEDCOM data, you'd have endpoints to query on persons, families, notes, objects, sources and repositories. I think that's probably not what's required. But then, what is? We all have different ideas on that, so it's hard to come up with something that satisfies more than one user.

stamboom.BertKoor.nl runs on webtrees v2.1.20
Last edit: 2 years 2 months ago by bertkoor.

Please Log in or Create an account to join the conversation.

  • yann64
  • Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 2 months ago - 2 years 2 months ago #4 by yann64
Replied by yann64 on topic REST API for 2.1
I actually have two very distinct use cases:
  1. I need to create simple widgets (mostly identical to the built-in webtrees graph/stats). I could actually live without a REST API if specific graph/stats could be incorporated as iframes in external webpages.
  2. I would like to be able to remotely access genealogical data (read-only, confidentiality based on credentials) so I can automate the generation of big/specific reports/charts/exports at regular intervals.
I know #1 is not possible for now, and for #2, looking at the source code, looks like REST was removed going from v2.0 to v2.1?
Last edit: 2 years 2 months ago by yann64.

Please Log in or Create an account to join the conversation.

More
2 years 1 month ago - 2 years 1 month ago #5 by hermann
Replied by hermann on topic REST API for 2.1
My idea is to set up a chat client (Telegram and Alexa) that allows asking questions like
- Hi, I'm Hermann. Are there any birthdays tomorrow?
- Where died Greatuncle John?
- What is the name of my niece Susan?
- How is my relationship with Karl The Great?
The answers should be a natural text and additionally maybe an image showing details.

> What data do you want to be returned by REST calls?
I would prefer not to operate on the GEDCOM level ("give me the GEDCOM for XREF=I123"), but using abstract webtrees objects and functions ("give me the parents of xxx") or "give me the full name of xxx" or "give me the relationship chart for the connection between xxx and yyy using the nearest common ancestor"); this includes the role model and access right defined by webtrees.

> Only allow data retrieval, or also accept modifications?
mainly retrieval; but maybe generation of a _TODO research task ("note that uncle John died last Monday, please")

> What format should the returned data be in? json, xml, html, png, pdf?
JSON, JSON-LD and png

> Do you want simple plain REST (fetch data from a repo) or with HATEOAS ?
The interface should be flexible, so HATEOAS and swagger files are maybe good ideas.

Hermann
Designer of the custom module "Extended Family"

webtrees 2.1.21 (all custom modules installed, PHP 8.3.12, MariaDB 10.6) @ ahnen.hartenthaler.eu
Last edit: 2 years 1 month ago by hermann.

Please Log in or Create an account to join the conversation.

More
3 months 3 weeks ago #6 by raslani
Replied by raslani on topic REST API for 2.1
Hello.

I find this interesting and very relevant. I'm wondering if you manage to do it and ready to share (a plugin ir juste siple ways to guide someone like me :)

I'm very interested in two things (restfull) : connexion and data retrieval in json. I have in mind a simple mobile application with a login and a quick display of data related to rhe user, and a button to open the browser fot full data (passing the session from mobile to browser)

Thank you in advance

Raslani

Please Log in or Create an account to join the conversation.

More
3 months 3 weeks ago #7 by Franz Frese
Replied by Franz Frese on topic REST API for 2.1
I see no reason to have an API for webtrees.
And if there would be one, you still have to create a (new) gui. (we already have the browser).

Please Log in or Create an account to join the conversation.

More
3 months 3 weeks ago #8 by hermann
Replied by hermann on topic REST API for 2.1
Yes, such a new UI could be a natural language interface. Maybe integrated in ChatGPT. Or part of a Telegram service. 

Hermann
Designer of the custom module "Extended Family"

webtrees 2.1.21 (all custom modules installed, PHP 8.3.12, MariaDB 10.6) @ ahnen.hartenthaler.eu

Please Log in or Create an account to join the conversation.

More
3 months 3 weeks ago #9 by Jefferson49
Replied by Jefferson49 on topic REST API for 2.1

I actually have two very distinct use cases:
  1. I need to create simple widgets (mostly identical to the built-in webtrees graph/stats). I could actually live without a REST API if specific graph/stats could be incorporated as iframes in external webpages.
  2.  
Maybe "widgets to show in an iFrame", is kind of simular to the way I am integrating webtrees into my Joomla CMS. Within my Joomla CMS, webtrees is shown in an iFrame-wrapper. Controlled by the menus of Joomla, certain webtrees pages are called and shown in the iFrame. For example, the following "widgets" are shown on my website:
  1. webtrees search
  2. family branches
  3. list of source s (generated by custom module RepositoryHierarchy)
I guess that these "widgets" are still far away from what you are thinking of. However, you could pick up the basic idea and work in the following direction:
  1. Create a specific webtrees theme, which does not show certain elements or presents other elements in the way you need it for your widgets
  2. Use the "CSS und JS" module to modify the webtrees views with CSS. This is a very powerful approach. For example, you can can hide all menus, side bars, etc.. You can see this on my website (e.g. links above), where I hide a significant part of the menus etc.
  3. Use the built-in webtrees routes (indeed some kind of available API) to call certain pages, e.g. ".../webtrees/tree/my_tree/individual/I100" to show individual "I100".

Please Log in or Create an account to join the conversation.

More
3 months 3 weeks ago #10 by Jefferson49
Replied by Jefferson49 on topic REST API for 2.1

  • I would like to be able to remotely access genealogical data (read-only, confidentiality based on credentials) so I can automate the generation of big/specific reports/charts/exports at regular intervals.
  • [/ol]
     
    If you are interested in downloading the GEDCOM data from webtrees, you can check the DownloadGedcomWithURL custom module. It provides an API for remote downloads of GEDCOM files from webtrees. Currently, I am working on an extension of this module, which will enable to filter the GEDCOM data before downloading.

    Please Log in or Create an account to join the conversation.

    Powered by Kunena Forum