wikitree api with python

+2 votes
835 views
Can anyone help with using the wikitree api with python?
in WikiTree Tech by David Anderson G2G6 (8.6k points)
What would you like to know? Do you already have code? You may PM me if you like.
I am trying to bring wt_apps up to date
Sorry, I am not sure I understand. wt_apps is the tag on G2G, right?

Or have you already written an app? If you can share the code bit you already have it is easier to help.

Chase's answer is mostly all you need (you might have to import json as well probably). I use post with a payload, but it all depends on how you want to approach it.

2 Answers

+6 votes

I played around with it for a bit. Here's sample code for using the getAncestors API function to get 2 generations of ancestors for Ashley-1966. Note that the end of the url is cut off. The full url is: ("https://api.wikitree.com/api.php?action=getAncestors&key=Ashley-1966&depth=2"). Just vary the action, key and fields (eg depth) per the API documentation and examples, depending on what you want to do.

import requests

response = requests.get("https://api.wikitree.com/api.php?action=getAncestors&key=Ashley-1966&depth=2")
data = response.json()
by Chase Ashley G2G6 Pilot (328k points)
edited by Chase Ashley
+2 votes
There's a full class implementation here:

https://github.com/chrrrisw/wikitree-api/blob/feature/python3_examples/examples/python3/wt_session.py

awaiting a pull request on the upstream repo.
by Chris Willoughby G2G6 Mach 2 (25.5k points)
There's also https://github.com/djhenderson/pywikitree by Doug Henderson.

Related questions

+1 vote
1 answer
+9 votes
1 answer
427 views asked Jan 19, 2022 in WikiTree Tech by Ken McEvoy G2G6 Mach 1 (14.6k points)
+3 votes
2 answers
344 views asked Apr 20, 2021 in WikiTree Tech by Stephen Ward G2G Rookie (220 points)
+6 votes
3 answers
+6 votes
2 answers
266 views asked Jan 8 in WikiTree Tech by Michel Vorenhout G2G6 Pilot (340k points)
+8 votes
2 answers
+10 votes
3 answers
301 views asked Sep 28, 2022 in WikiTree Tech by Przemek Więch G2G5 (5.4k points)
+21 votes
1 answer
593 views asked Jul 19, 2019 in WikiTree Tech by Jamie Nelson G2G6 Pilot (680k points)
+4 votes
2 answers
310 views asked Dec 27, 2017 in WikiTree Tech by Hans Boldt G2G1 (1.2k points)

WikiTree  ~  About  ~  Help Help  ~  Search Person Search  ~  Surname:

disclaimer - terms - copyright

...