Answers.Body: <p>You could start with API Explorer v4:</p>
  <ul>
  <li>Set the <code>Entity</code> to <code>CustomGroup</code> and <code>Action</code> to <code>get</code>.</li>
  <li>In the <code>Chain</code> section, set <code>Entity</code> to <code>CustomField</code> and <code>Action</code> to <code>get</code>.  The next box should autopopulate to <code>{where: [[custom_group_id, =, $id]]}</code></li>
  </ul>
  <p><a href="https://dmaster.demo.civicrm.org/civicrm/api4#/explorer/CustomGroup/get?chain=%5B%5B%22name_me_0%22,%5B%22CustomField%22,%22get%22,%22%7Bwhere:%20%5B%5Bcustom_group_id,%20%3D,%20$id%5D%5D%7D%22,%22%22%5D%5D%5D" rel="nofollow noreferrer">Basic example</a></p>
  <p>From there, you can limit the fields returned both for the CustomGroup and the CustomFields and maybe sort them.  Once that shows what you want, remove the <code>Limit</code> so see all the data.</p>
  <p><a href="https://dmaster.demo.civicrm.org/civicrm/api4#/explorer/CustomGroup/get?chain=%5B%5B%22name_me_0%22,%5B%22CustomField%22,%22get%22,%22%7Bwhere:%20%5B%5Bcustom_group_id,%20%3D,%20$id%5D%5D,%20select:%20%5B%5C%22label%5C%22,%5C%22name%5C%22,%5C%22data_type%5C%22,%5C%22html_type%5C%22%5D%7D%22,%22%22%5D%5D%5D&amp;select=%5B%22title%22,%22name%22,%22extends%22%5D&amp;orderBy=%5B%5B%22extends%22,%22ASC%22%5D,%5B%22title%22,%22ASC%22%5D%5D" rel="nofollow noreferrer">Example with selected fields</a></p>
  <p>From there, you can copy/paste the generated code to a php file and do what you like with the output.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-14T10:01:16.653Z
Answers.Text: Oh super, thanks, I hadn't found this in the API and sounds like a good way forward.
Answers.UserDisplayName: minbori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-13T18:49:42.463Z
Answers.LastActivityDate: 2020-11-13T18:49:42.463Z
Answers.UserDisplayName: Aidan
Answers.Body: <p>You could also check out <a href="https://doc.symbiotic.coop/dev/civicrm/latest/schema/index.html" rel="nofollow noreferrer">https://doc.symbiotic.coop/dev/civicrm/latest/schema/index.html</a> which is derived using SchemaSpy per the answer here</p>
  <p><a href="https://civicrm.stackexchange.com/a/20160/96">https://civicrm.stackexchange.com/a/20160/96</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-13T19:38:19.653Z
Answers.Text: Very useful as a general guide, but specifically for custom fields it doesn't really tell you how they match up. There are some foreign key-ish fields that aren't really foreign keys, like custom_group.table_name and custom_field.column_name. And extends_XXX can be tricky, like a custom group that is for activities of type A and C but not B.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-14T10:03:12.790Z
Answers.Text: Thanks, I did look into the database schema documentation which was super helpful, but as demerit says, it didn't really help me with the custom data.
Answers.UserDisplayName: minbori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-13T19:08:59.710Z
Answers.LastActivityDate: 2020-11-13T19:08:59.710Z
Answers.UserDisplayName: petednz - fuzion
Body: <p>I'm looking for some recommendations.  I've inherited a CiviCRM instance with a quite complicated custom data structure, and I want to review and update it.  I was wondering if there were any tools or APIs that would help me export or visualize the data schema/fields for different object types?</p>
  <p>The best option I can find is exporting all the fields for each type using the Export to CSV function, but that will require manually selecting hundreds of custom fields for each contact type in the field mapping GUI. UUUUggghhh! :-)</p>
  <p>I've found the Data Explorer extension (<a href="https://civicrm.org/extensions/data-explorer" rel="nofollow noreferrer">https://civicrm.org/extensions/data-explorer</a>) and am checking if that's a possibility, but that seems to have the same issues as the Exporter -- lots of manual selection.</p>
  <p>Can anyone suggest a better way? Thanks!</p>
  
Tags: <custom-fields><export><data>
Title: exporting custom data structure
ThreadText: # exporting custom data structure
  
  (Asked by: username_0 on 2020-11-13)
  
  I'm looking for some recommendations. I've inherited a CiviCRM instance with a quite complicated custom data structure, and I want to review and update it. I was wondering if there were any tools or APIs that would help me export or visualize the data schema/fields for different object types?
  
  The best option I can find is exporting all the fields for each type using the Export to CSV function, but that will require manually selecting hundreds of custom fields for each contact type in the field mapping GUI. UUUUggghhh! :-)
  
  I've found the Data Explorer extension (<https://civicrm.org/extensions/data-explorer>) and am checking if that's a possibility, but that seems to have the same issues as the Exporter -- lots of manual selection.
  
  Can anyone suggest a better way? Thanks!
  
  **Tags:** custom-fields, export, data
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-11-13. Score: 1
  
  You could start with API Explorer v4:
  
  * Set the `Entity` to `CustomGroup` and `Action` to `get`.
  * In the `Chain` section, set `Entity` to `CustomField` and `Action` to `get`. The next box should autopopulate to `{where: [[custom_group_id, =, $id]]}`
  
  [Basic example](https://dmaster.demo.civicrm.org/civicrm/api4#/explorer/CustomGroup/get?chain=%5B%5B%22name_me_0%22,%5B%22CustomField%22,%22get%22,%22%7Bwhere:%20%5B%5Bcustom_group_id,%20%3D,%20$id%5D%5D%7D%22,%22%22%5D%5D%5D)
  
  From there, you can limit the fields returned both for the CustomGroup and the CustomFields and maybe sort them. Once that shows what you want, remove the `Limit` so see all the data.
  
  [Example with selected fields](https://dmaster.demo.civicrm.org/civicrm/api4#/explorer/CustomGroup/get?chain=%5B%5B%22name_me_0%22,%5B%22CustomField%22,%22get%22,%22%7Bwhere:%20%5B%5Bcustom_group_id,%20%3D,%20$id%5D%5D,%20select:%20%5B%5C%22label%5C%22,%5C%22name%5C%22,%5C%22data_type%5C%22,%5C%22html_type%5C%22%5D%7D%22,%22%22%5D%5D%5D&select=%5B%22title%22,%22name%22,%22extends%22%5D&orderBy=%5B%5B%22extends%22,%22ASC%22%5D,%5B%22title%22,%22ASC%22%5D%5D)
  
  From there, you can copy/paste the generated code to a php file and do what you like with the output.
  
  > **Comments:**
  > **username_0**: Oh super, thanks, I hadn't found this in the API and sounds like a good way forward.  
  
  ---
  
  ### Answer by username_2 on 2020-11-13. Score: 0
  
  You could also check out <https://doc.symbiotic.coop/dev/civicrm/latest/schema/index.html> which is derived using SchemaSpy per the answer here
  
  <https://civicrm.stackexchange.com/a/20160/96>
  
  > **Comments:**
  > **username_3**: Very useful as a general guide, but specifically for custom fields it doesn't really tell you how they match up. There are some foreign key-ish fields that aren't really foreign keys, like custom_group.table_name and custom_field.column_name. And extends_XXX can be tricky, like a custom group that is for activities of type A and C but not B.  
  > **username_0**: Thanks, I did look into the database schema documentation which was super helpful, but as demerit says, it didn't really help me with the custom data.  
  
  ---
  
  