[API] Role enum mapping

Hi all, asking because I haven’t seen an answer in the forums yet: what’s the mapping between the Role enum values (found in the perms field for memberships) and the user-facing Roles in the app? I can puzzle out Author since I have instances of that, but it’d be great to know the others. I’m currently working on a small tool that uses the API to fetch cards (it’s a CLI like @jcassee’s sn, but not as performant since I’m writing in Kotlin, not Rust. I’m mostly doing it for fun)

Thanks!
Scott

1 Like

Hi Scott,

Happy to see you’re using the API. Fair warning though, in the next version (slated to be released in the next week or two) the API contract will be undergoing major changes in preparation for full-offline support (and generally just future-proofing for other fun features in the pipeline). We are also trying to change as much as we can in this release so that we can guarantee a much more stable API contract in the near future. The query for fetching cards stays the same, but the format of the underlying cards will be changing a bit. Here is a sneak peak of the format in 2.2:

    "a9e1945e-417c-4fad-b5f0-6ed8e1dcb6a1": {
        "data": {
            "id": "a9e1945e-417c-4fad-b5f0-6ed8e1dcb6a1",
            "owner_id": "b73bb65e-b980-4c08-a392-cbd25a95af97",
            "name": "A Demo Card",
            "markup": "my content",
            "html": "<p>my content</p>",
            "icon": null,
            "tags": [
                "a tag goes here"
            ],
            "created_when": "2021-06-05T18:27:59.398",
            "modified_when": "2021-11-03T14:34:41.738611",
            "modified_by_id": "66c8987e-90f5-4c37-acf9-1e3c5edf25b0",
            "synced_when": "2021-11-03T14:34:41.738611",
            "targeted_when": null,
            "likes": 0,
            "member_count": 2,
            "comment_count": 2,
            "public_child_count": 10
        },
        "membership": {
            "id": "22e695a6-9802-4621-9792-cec2a828463d",
            "personal_tags": [],
            "liked": null,
            "color": null,
            "perms": 2097151,
            "via_type": 0,
            "via_id": null,
            "created_when": "2021-06-05T18:27:59.398",
            "modified_when": "2021-06-05T18:29:22.547767",
            "enrolled_when": "2021-06-05T18:27:59.398",
            "opened_when": null,
            "auto_publish_children": null,
            "visibility": 0,
            "status": 2,
            "has_commented": false,
            "total_child_count": 12
        },
        "backlinks": [
            "758adfb3-78ae-4dac-9b72-9afcc0def4d1",
            "70401898-c990-414b-acf5-c0149088dbda",
            "6e44a459-3058-4070-a59b-a5899bd5b267"
        ],
        "parents": {
            "9acb625b-27cc-44ab-88c3-717533e35421": {
                "owner_id": "b73bb65e-b980-4c08-a392-cbd25a95af97",
                "parent_id": "9acb625b-27cc-44ab-88c3-717533e35421",
                "created_when": "2021-06-05T18:29:22.551211",
                "publishing_perms": -1,
                "archived": null,
                "parent_membership_status": 2
            }
        }
    }

Now back to your question, which is a valid one! We need to update our docs to make sure Enum names are actually included somehow.

The enum is as follows:

AUTHOR: 2097151
MODERATOR: 524287
EDITOR: 211951
CONTRIBUTOR: 207823
READER: 207695

Would love to see your tool when it’s finished!

Thanks, Connor! Thanks for the heads up about the upcoming changes too, looks like a nice improvement over the current schema!