This script gets the public biography from WikiTree for a person or free-space profile, based on the WikiTree ID in the key
parameter.
Use of the optional client
parameter—a unique ID
(such as your WikiTree ID) that is passed to WikiTree for tracking—is recommended to prevent your code from being blocked if another user abuses the system.
No other authentication is required at this time.
Usage of this feature is tracked by WikiTree, and any abuse of their API could cause access to this app to be throttled or restricted in the future. It should only be used for the occasional query from lightly-used websites.
Because of CORS limitations, it must be included as a JSONP <script>
(which requires the callback
parameter—a local function name only, such as loadBio
—on the URL).
For testing purposes only, you can browse to the URL with no callback to see the HTML output,
but CORS will not allow it to be embedded in an <iframe>
or for fetch
, $.ajax
, or XMLHttpRequest
to request this URL from another website.
I also created a simple CSS file to format the HTML more closely to WikiTree's style. You should copy a minified version to your local website rather than referencing the URL on this server.
For more fully-featured examples, see the source of this page or my website at jduke79.com.
<!DOCTYPE html> <html> <body> <div id="bio"></div> <script> function loadBio(response) { document.getElementById("bio").innerHTML = response; } </script> <script src="https://apps.wikitree.com/apps/duke5773/embeddable.php?callback=loadBio&key=Space:Jonathan_Duke_(jduke79)&client=Example-1"></script> <script> (function (el) { if (el.childNodes.length === 0) { el.innerText = ("The biography data was not loaded."); } })(document.getElementById("bio")); </script> </body> </html>