Unicat API Reference

Up - API Reference - Home


/api/p/<project gid>/init

Requires JWT

Get initial user, projects data, and initial data for the current project.

Making this call to the project api will give you specific initial data for that project and its members - but only if the user is actually a member or the owner of the project.

Request

GET /api/p/<project gid>/init
Authorization: Bearer <JWT>

Success response

Authorization: <JWT>

{
    "success": true,
    "result": {
        "user": "<user gid>",
        "user_projects": {
            "<project gid>": [
                "owner"
            ],
            
        },
        "project": "<project gid>",
        "project_members": ["<user gid>", "<member user gid>", ],
        "last_backed_up": 1612184925.9805226,
        "cc.version": "2022.01.001",
        "cc.cursor": 4132,
        "cursor": 7864,
    },
    "data": {
        "cc.users": {
            "<user gid>": {
                "gid": "<user gid>",
                "username": "user-name",
                "email": "<user email>",
                "name": "User Name",
                "avatar": "1ad71cbd-9b97-4ea7-94ef-bcdd86c6467c.jpg",
                "status": "active",
                "options": {
                    "language": "en",
                    "timezone": "Europe/Amsterdam"
                }
            },
            "<member user gid>": {
                "gid": "<member user gid>",
                "username": "member-name",
                "name": "Member Name",
                "avatar": "f2e64fe0-9ffa-4d9a-8750-d561d6542453.png",
                "status": "active",
            },
            
        },
        "cc.projects": {
            "<project gid>": {
                "gid": "<project gid>",
                "name": "Project Name",
                "icon": "<project gid>.jpg",
                "owner": "<user gid>",
                "status": "active",
                
            },
            
        },
        "cc.projects_members": [
            {
                "project_gid": "<project gid>",
                "user_gid": "<user gid>",
                "status": "active",
                "roles": [
                    "owner"
                ],
                "options": {
                    "notifications": {
                        "email": "<user email>",
                        "events": [
                            "all"
                        ],
                        "frequency": "immediate"
                    },
                    "rate_limit_per_second": null
                }
            },
            {
                "project_gid": "<project gid>",
                "user_gid": "<member user gid>",
                "status": "active",
                "roles": [
                    "member"
                ]
            },
            
        ],
        "cc.languages": {
            "da": "Danish",
            "nl": "Dutch",
            
        },
        "definitions": {},
        "classes": {},
        "fields": {},
        "layouts": {},
        "queries": {},
    }
}

An updated JWT may be in the Authorization header.

result

user is the user gid if the login is successful.
user_projects is a list of zero or more projects that are owned by this user.
project is the project gid if the user is a member of the project. If not, this value will be null, but the login is still valid.
project_members is a list of project members gids (these are user gids).
last_backed_up is a server-side timestamp for the last backup of the database, or null if it was never backed up.
cc.version is the current version.
cc.cursor a sync cursor, to keep cc-data in sync.
cursor a sync cursor, to keep project-data in sync.

data

cc.users is a dictionary with a full entry for the current user, and reduced metadata for all the other members.
cc.projects is a dictionary with a full entry for the current project, and reduced metadata for each other owned project.
cc.projects_members is a list with metadata for all project-member relations.
cc.languages available languages for internationalization and localization.

definitions is a dictionary holding all definitions for the project.
classes is a dictionary holding all classes for the project.
fields is a dictionary holding all fields for the project.
layouts is a dictionary holding all layouts for the project.
queries is a dictionary holding all queries for the project.

Error response

401 Unauthorized - missing or expired JWT
403 Forbidden - not a member of the project

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="JWT access to Unicat."

{
    "success": false,
    "data": null,
    "error": {
        "code": 401,
        "message": "Permission denied",
        "info": {}
    }
}
HTTP/1.1 403 Forbidden

{
    "success": false,
    "result": {
        "code": 403,
        "message": "Forbidden",
        "info": {}
    },
    "data": {}
}