Current revision is 0.1.0-wip
Subtyping is written using the <:
operator: Apple <: Fruit
.
This notation will make this text shorter (and slightly more formal).
By default tenant have almost no access (e.g. banned tenant have no modification capabilities).
Enum uint
with following values:
0
- anonymous guest a.k.a. unauthorized user.1
- authorized user with default capabilities set (read-only access).2
- private uploader: allows uploading of private assets.3
- public uploader: allows uploading of public assets.4
- voter: allows affect voting on tags.5
- tag assigner: allows voting (assigning) for a new tag.6
- tag creator: allows creating new tags.7
- private album creator: allows creating private albums (and deletion of owned private albums).8
- public album creator: allows creating public albums (and deletion of owned public albums).256
- global admin.257
- debug view, this role must only provide access to debug data.258
- tag vote moderator: allows tag vote deletion.259
- tag moderator: allows deletion of tags and associated votes.260
- uploads moderator: allows edit and deletion of accessible assets.261
- public album moderator: allows edit and deletion of public albums.262
- private album moderator: allows edit, view and deletion of private albums.263
- user tenant moderator: allows edit of user tenants.264
- allows deletion of user tenants.265
- (service) create user tenants: allows creation of user tenants.266
- (service) authorize user tenants: allows creation of user tenants.
Enum string
with following values:
"guest"
- guest tenant."user"
- user tenant."service"
- service tenant, used for example by integrated systems, such as external registration.
Enum string
with following values:
"internal/system"
- tenant of internal origin. Such tenants mostly an artificial entities created as part of internal API implementation."internal/user"
- tenant created via internal user registration."internal/service"
- tenant created for service integration."external/tg"
- tenant created via external registration provider: Telegram.
Enum string
with following values:
"image"
- image asset.
Enum uint
with following values:
0
- down vote.1
- up vote.
Editor note: Some objects may have seemingly unnecessary inheritance, but such choice is made to allow future reusability of object definitions and generally make API easier to extend with new capabilities.
There are following objects in API, all fields are required unless explicitly stated otherwise.
Is a string
blur hash as described by BlurHash spec.
Example:
"LKN]Rv%2Tw=w]~RBVZRi};RPxuwH"
Generic supertype for all objects that have an ID in form of unsigned integer.
Example:
{
"id": 0, // uint
}
Where:
id
is unsigned integer ID of object.
Tenant <: ModelObject
Tenant is used to work work with authorization and perform actions on behalf of user.
It must be noted that Tenant is NOT necessary a Person.
First is used to interact with the system, the other is to display a public profile of an entity.
There is exist a Guest
tenant. It is required for anonymous iterations,
such as updating views counts.
Editor note: This separation allows to make a public entities that are not a physical user and act on their behalf e.g. communities governed by multiple users.
API implementers must pay attention to roles view access, as not all tenant roles are visible for other tenants.
Example:
{
"roles": [ 0, ], // Array<TenantRole>
"type": "string", // TenantType
"origin": "string", // TenantOrigin
"display_name": "string",
"unique_name": "string",
"is_restricted": false,
"extremist_date": 0, // optional: unix ts
"foreign_agent_date": 0, // optional: unix ts
}
Where
roles
is an array of unsigned integer enums of typeTenantRole
. Tenant may not have access to view all of available roles, e.g. non admin tenant examines another tenant.type
is an enum ofTenantType
indicating type of tenant.origin
is an enum of typeTenantOrigin
indicating origin.display_name
is a string used to display a tenant name.unique_name
is unique tenet name.is_restricted
is a boolean indicating that tenant has any restrictions (a.k.a. bans).extremist_date
is an optional UNIX timestamp indicating that tenant has been listed in list of extremist materials by Ministry of Justice of Russian Federation.Editor note: for users from Russia, this hides any tenant's associated galleries.
foreign_agent_date
is an optional UNIX timestamp indicating that tenant has been listed in registry of foreign agents by Ministry of Justice of Russian Federation.
TenantProfile <: Tenant
Tenant public profile.
Example:
{
"public_galleries": [ 0, ], // Array<uint>
"private_galleries": [ 0, ], // Array<uint>
}
Where
public_galleries
is anArray
of unsigned integer IDs of associated publicGalleries
.private_galleries
is anArray
of unsigned integer IDs of associated privateGalleries
.
Meme <: ModelObject
Object describing a single unit of gallery.
Example:
{
"author_id": 0, // uint
"asset_id": 0, // uint
"tag_ids": [ 0, ], // Array<uint>
"title": "string",
"description": "string", // Reserved for future
}
Where:
author_id
is unsigned integer ID of authorUser
.asset_id
is unsigned integer ID of associatedAsset
.tag_ids
is anArray
of unsigned integer IDs of associatedTag
s.title
is a string title of the meme.description
is a string value reserved for future use.
Asset <: ModelObject
Generic asset base type.
Example:
{
"type": "string", // enum AssetType
"blurhash": "string", // BlurHash
}
Where:
Image <: Asset
Image asset with a single quality level. Image is accessible though WWW and MIME type is provided via appropriate HTTP header.
Editor note:
uri
is chosen overurl
to make it possible to extend for custom storages in future, e.g. Amazon S3s3://example-bucket/path/to/object
, or localfile:///path/to/object
.
Example:
{
"uri": "string",
}
Where:
uri
is a string URI that points to target image asset, must havehttp
orhttps
scheme.
Tag <: ModelObject
Generic tag object.
Example:
{
"name": "string",
}
Where
name
is a string name of this tag.
MemeTag <: Tag
Tag instance associated with an individual Meme.
Example:
{
"meme_id": 0, // uint
"score": 0, // int
"my_vote": 0, // optional: enum VoteType
}
Where
meme_id
is unsigned integer ID of associatedMeme
.Editor note: This is required to make Tag object's data sufficient to update it.
score
is an integer indicating score of this tag application.my_vote
is an optional integer enum of typeVoteType
. This field is omitted if user haven't voted for a tag, or in guest access.
Person <: Tenant
Person is an object defining public part of a tenant it can be used to display user reference e.g. author.
Editor note: In current design fully inherits Tenant.
PersonProfile <: TenantProfile
Person's public profile.
Editor note: In current design fully inherits TenantProfile.
Gallery <: ModelObject
Gallery of Meme
s
{
"owner_id": 0, // uint
"contributor_ids": [ 0, ], // Array<uint>
"name": "string",
"description": "string",
"public": false,
"owned_by_extremist": false,
"current_tenant_can_edit": false,
}
Where:
owner_id
is unsigned integer ID of associatedTenant
owner.contributor_ids
is an array of unsigned integer IDs ofTenant
s contributors.name
is a string name of gallery.description
is a string description of gallery.public
is a boolean flag indicating whether gallery is public or private.owned_by_extremist
is a boolean flag indicating that associated ownerTenant
owner has been listed as extremist.Editor note: For users from Russia this will prevent further loading of gallery.
current_tenant_can_edit
is a boolean flag indicating whether current tenant has edit access to this gallery.
Feed response item.
{
"gallery_id": 0, // uint
"meme_id": 0, // uint
}
Where:
User authorization is handled via any of the following ways:
X-API-Token
HTTP header.x_api_token
HTTP cookie.token
HTTP GET parameter.
All API endpoints return results in following form:
{
"error": false,
"result": null,
"related": {}, // optional
}
Where:
error
is a boolean indicating whether it is an error response.result
is a result of request as described by API endpoint or error object details with following format:Where:{ "code": 0, "message": "string", }
code
is an integer error code.message
is a string message of an occurred error.
related
is optional object with related objects.Editor note: TODO add format for related objects.
This is an API for external registration that is exposed only to integrated services.
Used tenant defines type of managed tenants.
Warning
Requires service tenant.
Issue authorization token for managed tenant.
Editor note:
This method issues token without any checks except for whether user is managed by corresponding service tenant. Any service API should be guarded, but this method is especially dangerous and API implementers should take notice.
URI parameters:
id
is an ID of managedTenant
to be authorized.
Body:
- Object with following fields:
full_name
- User first and last names combined as provided by Telegram.username
- User tag as provided by Telegram.Editor note: can be an empty string.
Returns:
- String token to be used to impersonate tenant.
Retrieve user feed of public memes.
Editor note: This endpoint should also include memes which are accessible through contributors system.
Returns:
Array<
FeedItem
>
.
Retrieve user feed of recommended memes.
Note
Requires non-guest tenant.
Returns:
Array<
FeedItem
>
.
For every user tenant there must be a special synthetic galleries:
-100
- recycle bin. Private gallery for deleted memes.-200
- quick uploads/unsorted/misc. Private for gallery for anything.
Create a new Gallery
.
Body:
Gallery
-like object with only following fields allowed:name
description
public
Returns:
Retrieve an existing Gallery
.
URI parameters:
id
is an ID of requestedGallery
.
Returns:
Partially update an existing Gallery
.
URI parameters:
id
is an ID ofGallery
needed to be updated.
Body:
Gallery
-like object with only following fields allowed:name
description
public
Returns:
Delete an existing Gallery
.
URI parameters:
id
is an ID ofGallery
needed to be deleted.
Returns:
- boolean flag indicating whether gallery was deleted or not.
Editor note: always
true
, otherwise error is raised, e.g. permissions issue.
Add contributor to an existing Gallery
.
URI parameters:
id
is an ID ofGallery
needed to be updated.
Body:
Array<uint>
is an array of IDs ofTenant
s to be added to gallery as contributors.
Returns:
Remove contributors from an existing Gallery
.
URI parameters:
id
is an ID ofGallery
needed to be updated.
Body:
Array<uint>
is an array of IDs ofTenant
s to be removed from gallery contributors.
Returns:
Upload file for following meme creation.
Query parameters:
type
is an enum of typeAssetType
.
Body:
- Asset content.
Returns:
- String with temporary asset ticket to be used to create a meme.
Get tags suggestions for uploaded file.
Query parameters:
asset
asset ticked obtained via Asset upload.
Returns:
- Array of
Tag
s.
Create a new Meme
.
Non-existing tags are automatically created.
Query parameters:
asset
asset ticked obtained via Asset upload.gallery_id
is an ID ofGallery
this meme to be added to.
Body:
-
{ "title": "string", "description": "string", // Reserved for future "tags": [ "string", ], }
Editor note: Implementers must treat tags array as a list of auto vote tags.
Returns:
Meme
.
Retrieve an existing Meme
.
URI parameters:
gallery_id
is an ID ofGallery
this meme is accessed via.Editor note: This simplifies access management for API implementers.
id
is an ID of requestedMeme
.
Returns:
Meme
.
Partially update an existing Meme
.
URI parameters:
id
is an ID ofMeme
needed to be updated.
Body:
Meme
-like object with only following fields allowed:title
description
Returns:
Meme
.
Delete an existing Meme
.
URI parameters:
Returns:
- boolean flag indicating whether meme was deleted or not.
Editor note: false unless deleted from recycle bin.
Retrieve feed of similar memes.
URI parameters:
Returns:
Array<
FeedItem
>
.
Retrieve tags of an existing Meme
.
URI parameters:
gallery_id
is an ID ofGallery
this meme is accessed via.Editor note: This simplifies access management for API implementers.
id
is an ID of requestedMeme
.
Returns:
- Array<
MemeTag
>.
Create a new Meme
.
Non-existing tags are automatically created.
Query parameters:
Body:
-
Where:
{ "type": null, // null|VoteType }
type
isVoteType
ornull
if you want to remove your vote.
Returns:
- Array<
MemeTag
>.
Retrieve current Tenant
from authorization.
Editor note: For unauthorized users this method will return Anonymous tenant.
Returns:
Tenant
or it's descendant.
Retrieve an existing Tenant
.
URI parameters:
id
is an ID of requestedTenant
.
Returns:
Tenant
or it's descendant.
Retrieve a TenantProfile
.
URI parameters:
id
is an ID of requestedTenantProfile
.
Returns:
TenantProfile
or it's descendant.