wikitree api with python

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

Related questions

+1 vote
1 answer
+6 votes
1 answer
+3 votes
2 answers
143 views asked Apr 20, 2021 in WikiTree Tech by Stephen Ward G2G Rookie (220 points)
+4 votes
2 answers
+6 votes
3 answers
111 views asked Sep 28 in WikiTree Tech by Przemek Więch G2G4 (4.8k points)
+19 votes
1 answer
463 views asked Jul 19, 2019 in WikiTree Tech by Jamie Nelson G2G6 Pilot (475k points)
+4 votes
2 answers
197 views asked Dec 27, 2017 in WikiTree Tech by Hans Boldt G2G1 (1.1k points)
+8 votes
2 answers
920 views asked Sep 26, 2012 in WikiTree Tech by James Davis G2G Crew (910 points)
+18 votes
1 answer
410 views asked Jul 10, 2015 in The Tree House by Chris Whitten G2G Astronaut (1.3m points)

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

disclaimer - terms - copyright

...