wikitree api with python

+2 votes
763 views
Can anyone help with using the wikitree api with python?
in WikiTree Tech by David Anderson G2G6 (7.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 (312k 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 (23.2k points)
There's also https://github.com/djhenderson/pywikitree by Doug Henderson.

Related questions

+1 vote
1 answer
+7 votes
1 answer
335 views asked Jan 19, 2022 in WikiTree Tech by Ken McEvoy G2G6 Mach 1 (12.1k points)
+3 votes
2 answers
294 views asked Apr 20, 2021 in WikiTree Tech by Stephen Ward G2G Rookie (220 points)
+6 votes
2 answers
155 views asked Jan 8 in WikiTree Tech by Michel Vorenhout G2G6 Pilot (315k points)
+7 votes
2 answers
+9 votes
3 answers
233 views asked Sep 28, 2022 in WikiTree Tech by Przemek Więch G2G5 (5.2k points)
+20 votes
1 answer
515 views asked Jul 19, 2019 in WikiTree Tech by Jamie Nelson G2G6 Pilot (626k points)
+4 votes
2 answers
242 views asked Dec 27, 2017 in WikiTree Tech by Hans Boldt G2G1 (1.2k points)
+8 votes
2 answers
1.0k views asked Sep 26, 2012 in WikiTree Tech by James Davis G2G Crew (910 points)

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

disclaimer - terms - copyright

...