Api call for list of databases and spaces

What is the api endpoint to get a list of all databases and spaces? I found fibery.getSchema() but it appears to return a ton of other things like enums and there doesn’t seem to be any fields to distinguish what type of entity it is (space or database). Is there a simple way to just get a list of spaces and their databases?

fibery.getSchema() is the way to go, but yes you do have to look at the properties of the types to determine whether they are true databases, select fields, add-ins (comments, files, etc.) or whatever.
Oh, and I think you can’t get a list of spaces explicitly, only by getting types and finding the space they belong to.

OK so would it be safe to say that if fibery/enum? does not exist, or is set to false, and 'fibery/deleted?': false then it’s a current database in the system?

Or maybe if 'fibery/domain?': true, then it’s a database? Not sure what everything means under 'fibery/meta'.

// This is a database
  {
    'fibery/name': 'Todo List/Task',
    'fibery/fields': [
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object]
    ],
    'fibery/meta': {
      'fibery/primitive?': false,
      'fibery/domain?': true,
      'ui/color': '#9c2baf',
      'fibery/secured?': true,
      'app/mixins': [Object]
    },
    'fibery/id': 'xxx',
    'fibery/deleted?': false
  },
// this is an enum cause 'fibery/enum?': true, is set
  {
    'fibery/name': 'Sessions/Vacation Visibility Enum',
    'fibery/fields': [
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object]
    ],
    'fibery/meta': {
      'fibery/primitive?': false,
      'fibery/domain?': false,
      'fibery/enum?': true,
      'fibery/secured?': true,
      'app/mixins': [Object],
      'fibery/type-component?': true
    },
    'fibery/id': 'xxx',
    'fibery/deleted?': false
  },
// what is this? would I filter it out because 'fibery/schema-only?': true,
  {
    'fibery/name': 'avatar/avatar-mixin',
    'fibery/fields': [ [Object] ],
    'fibery/meta': {
      'fibery/primitive?': false,
      'fibery/domain?': false,
      'ui/color': '#249118',
      'ui/mixin-icon': ':icon/extension/avatar',
      'app/mixin?': true,
      'fibery/schema-only?': true,
      'fibery/platform?': true
    },
    'fibery/id': 'xxx',
    'fibery/deleted?': false
  },

I actually asked one of the devs a similar question a couple of years ago, and this was the answer:

if type marked as NOT fibery/primitive? then it is compound complex object and its values we call Entities. Entity may have many fields of complex types or primitive types.
Primitive type implies that its value is a simple value like string or number e.g. fibery/text or fibery/decimal.fibery/domain? is a category of Complex Types (non primitive) which we allow to select on Views (Board, Gird, etc) as Cards. Such type must have a certain enumeration of fields e.g. Creation Date, Modification Date, Public ID

example of non primitive domain type is Feature,
example of non primitive and non domain type is Single Select

So you basically got very close with your guesswork(!)

But note, the logic of looking for domain non-primitive types will also return the Fibery User database which may or many not be what you want.

Thanks for the response. This is what I came up with to create a object with all the spaces and their associated types. I’m not 100% sure my logic is correct, but it seems to be working on my instance:

    const fibery = new Fibery({ host: FIBERY_URL, token: FIBERY_TOKEN });
    const schema = await fibery.getSchema();

    const types = schema.filter((item) => {
      const isDeleted = item['fibery/deleted?']
      const isDomain = item['fibery/meta']?.['fibery/domain?'];
      const isPlatform = item['fibery/meta']?.['fibery/platform?'];
      return !isDeleted && isDomain && !isPlatform;
    })

  const spaces = types.reduce((acc, item) => {
    const parts = item['fibery/name'].split('/');
    const spaceName = parts[0].replace(/\s/g, '_');
    const typeName = parts[1].replace(/\s/g, '_');
    acc[spaceName] = acc[spaceName] || [];
    acc[spaceName].push(typeName);
    return acc;
  }, {});

  const space_and_types = Object.entries(spaces).map(([spaceName, types]) => {
    return {
      space_id: spaceName,
      types,
    }
  })

I’m curious to know what your end goal is with this?

I’ve currently developed a MCP server that will allow your llm to output a valid graphql statement for your fibery instance using natural language (ie find me all tasks and their related users which have a due date in the next 2 weeks).

The MCP has 3 tools:

  • list_spaces_and_types (this is the one I needed to fetch the space and type names)
  • get_schema_sdl
  • validate_fibery_graphql

So far it’s working pretty good. Once I have it tested a bit more I’ll post a link to it here.

2 Likes

For anyone interested in the MCP here’s the code:

1 Like

Did you try using the Fibery MCP server?
Did it fail to generate valid GraphQL queries?

Yeah I had issues with it generating valid graphql from the official mcp. Some of the filtering it doesn’t get quite right. Also it makes some incorrect assumptions about naming, then doesn’t have a way to validate the graphql and get feedback. I’d actually be more than happy for the Fibery team to use this to port into the official python mcp.