Accessing Geni Profiles - Thimxx/pyGenealogical-Tools GitHub Wiki

Set up the access to Geni database

In order to access Geni data the first action is to determine the single access token to Geni. This code gets obsolete every day and requires regular update.

For obtaining the Geni Key, just go to this page. If there is no project declared, create your own project and finally get the token. Copy paste in your code

from pyGeni import set_token

My_token = "Include your Geni key here"

set_token(My_token)

Obtain a single profile

Once the token is set-up all Geni operations will be reading that token. In order to access to a single profile, the next step is to firstly copy the web address of the profile and later on declare a new instance of a Geni profile.

Below an example is done with a public profile that shall be accessible to all users of Geni.

from pyGeni import set_token
from pyGeni.profile import profile

My_token = "Include your Geni key here"

Profile_web_address = "https://www.geni.com/people/Felipe-IV-el-Grande-rey-de-Espa%C3%B1a-y-Portugal/6000000000837888160"

set_token(My_token)
#Now the profile will be philip
philip = profile(Profile_web_address)

Access to the profile data

Several functions are available at profile level to provide access to the different profile data:

philip = profile(profile_web_address)

#Basic information as Name, Surname, Gender and if the person is living or not
philip.getName()
philip.getSurname()
philip.getGender()
philip.getLiving()

#The internal ID of the profile (used by the code as internal reference)
philip.get_id()

#Commnents on the profile
philip.getComments()

#The way event (like birth) is stored is in a dictionary containing the location of such event and the date of the event
#All events of hte profile can be accessed, as well an specific one or the location of an specific event
# Event name supprted today are: birth, death, burial, marriage, residence, baptism
philip.getEvents()
philip.get_specific_event(event_name)
philip.get_location_event(event_name)

Accessing more profiles

Essentially the basic access to a profile has been described above, however, when navigating inside Geni it is needed to be able to access to the different family. In this case, there is a wrapper to the Geni database, in this case is easier to first access the wrapper

from pyGeni import set_token
from pyGeni.interface_geni_database import geni_database_interface

My_token = "Include your Geni key here"
set_token(My_token)
db_geni = geni_database_interface()

philip = db_geni.get_profile_by_ID(Profile_web_address)

Afterwards, it is possible to access to all releated family of such profile

db_geni.get_all_children(Profile_web_address)
db_geni.get_father_from_child(Profile_web_address)
db_geni.get_mother_from_child(Profile_web_address)
db_geni.get_parents_from_child(Profile_web_address)

All functions will give 2 results, the first output are the internal ID of Geni (that you can use to access the profile) and the second output is the a "geni profile" instance of the profile.

Accessing stored events

When accessing events, the output will be provided as an instance of the class "event_profile", which is described in the event section.

#Will provide a list with all events available for the profile
philip.getEvents()
#Will provide the specific event or None is the event is not stored
philip.get_specific_event("birth")
#Will provide the value of accuracy of the date of the specific event
philip.get_accuracy_event("death")
#Will provide the location of the specific event.
philip.get_location_event("burial")

How to test without jeopardizing the public database

There is a sandbox available in Geni which is used for testing of this sofware. I do encourage to use such database for testing, as it is not a production environment. In order to access the Sandbox just do the following (after creating your own account in the Sandbox, of course):

from pyGeni import set_token, update_geni_address

update_geni_address("https://sandbox.geni.com")

#Different token is used for sandbox and geni production
My_sandbox_token = "Include your Geni key here"

The token for the sandbox is different from the one used in the production enviroment, just use this following link