In order to sync data to the Genealogies system, use the following process:
- Obtain access token for the user.
- Create a new Genealogies Tree.
- Add data to the Genealogies Tree.
- Update persons and relationships.
- Get the matches.
This is accomplished by sending the user through the OAuth 2 authentication and authorization process. More information can be found here.
A Tree in the Genealogies system is the container which will hold all of the tree persons and information regarding the user's tree. This is roughly equivalent to the user's file containing tree information for a desktop genealogy application. A user can create and access multiple trees, so it is important to keep a mapping to the ID of the tree created.
To create the Tree, send a POST
request to the Genealogies Tree resource. The documentation provides an example request for creating the tree.
There are a few different methods for adding information to the user's tree.
The Genealogies system uses a GEDCOM X data model consisting of Person, Relationship, and SourceDescription records.
The relationship model is different from the GEDCOM 5.x model consisting of Person and Family records. Two relationship types are used by GEDCOM X, namely http://gedcomx.org/ParentChild
and http://gedcomx.org/Couple
. The ParentChild
relationship is a directional relationship, meaning that person1
represents the parent and person2
represents the child. From these two relationship types, you represent the relationships implied in the Family record individually.
For more information, see the GEDCOM X Conceptual Model documentation.
You can either add persons and relationships one at a time, or add multiple persons and relationships in in bulk.
To add persons one at a time, send a POST
request to the Genealogies Persons resource. Your request should include a GEDCOM X representation of the person, names, facts, etc. The response should provide an ID or URI of the person as a header.
To add relationships one at a time, send a POST
request to the Genealogies Relationships resource. Your request should include a GEDCOM X representation of the relationship, including the identifiers to the related persons.
To add multiple persons at a time, send a POST
request to the Genealogies Tree resource. The Genealogies Tree
resource will accept a payload containing up to 100 persons represented in a GEDCOM X document. At this time, it is unclear how to retrieve the IDs for each of the persons created. This is an open issue and will be addressed by FamilySearch engineers.
To add multiple relationships at a time, send a POST
request to the Genealogies Tree resource. It is advised to add all persons to the the tree prior to adding the relationships, so that you have identifiers for all persons represented in the requests. Relationship IDs are composed of the IDs of the persons involved in the relationships.
- Adding persons (TODO)
- Adding relationships (TODO)
As person data changes in your application, you will need to keep the user's data in sync with the tree found in the Genealogies system. The Genealogies API supports additions and deletions. If the same fact value is written twice, ((TODO: does it ignore the new one or update the timestamp?)).
TODO: Information on Relationship updates.
The strategy for keeping the data up to date depends upon the capabilities of your system.
If your system is able to track individual changes in the form of a change log, then the process to keep the Genealogies Tree up to date is a matter of replaying the same changes on the remote tree.
- If a new person with new relationships was added to the local tree, your application would add the new person with the new relationships to the remote tree.
- If a new fact was added on the local tree, the new fact could be added to the person in the remote tree.
- If a fact was changed on the local tree, the previous fact would be deleted and the new fact added.
If your system does not keep track of changes, then the best way to keep in sync is to compare your data with what is in the Genealogies system and to calculate the difference.
One approach for doing this would be to create a GEDCOM X representation of the person and to compare that GEDCOM X representation to the GEDCOM X person read from the Genealogies system. As you develop this method, it may be helpful to test your comparison algorithms by following these steps:
- Create a GEDCOM X document representing your local person. Let's call this
gx1
. POST
this person to the Genealogies API. You will receive back the ID for this person.GET
the person from the Genealogies API. Let's call thisgx1'
.- Compare
gx1
togx1'
. Your comparison algorithm should indicate that they are the same.
The last step in this process is to get matches (or hints) from the Genealogies API. The match resource will support the ability to read matches for both Family Tree persons as well as historical records.
Jimmy, we now have a way to get the IDs for the persons created back. When the endpoint is hit the response will be a GedcomX document with a list of SourceDescriptions, one for each person created. Each source description will have as its ID the id of the person element passed in (that caused the person to be created) and an Ark for the person that was created. In this way the client will be able to associate IDs for person in the client system with the Ark in Genealogies.