Skip to content

Instantly share code, notes, and snippets.

@Septem151
Last active August 17, 2023 03:25
Show Gist options
  • Save Septem151/fe9408b471b1e63f26cb5c14f768a691 to your computer and use it in GitHub Desktop.
Save Septem151/fe9408b471b1e63f26cb5c14f768a691 to your computer and use it in GitHub Desktop.
GifSync API Spitballing

GifSync

Table of Contents

GifSync lets you sync gifs to music, with Spotify integration for real-time syncing.

Requirements

Users should be able to:

  • create an account
  • login via username and password
  • login via Spotify integration
  • use as guest
  • upload images to sync
  • view all personal synced images
  • view synced images separately
  • edit synced image properties
    • name
    • tempo
    • speed multiplier
  • delete synced images
  • edit personal user preferences
    • background color
    • minimum tempo
    • maximum tempo
  • connect Spotify to existing login
  • remove added Spotify integration
  • persist logins across sessions
  • logout
  • delete all personal synced images
  • change password if username login
  • view profile information
  • download synced images
  • reload view of synced images

API

The GifSync API v1 is located at https://api.gifsync.io/v1.

Data Types

These are the data types defined in the GifSync API. Data Types are used for convenience and for processing both client and server requests/responses.

declBoolean

declBoolean represents a filter declaration in which the type of val is boolean. The key is the name of the variable to declare comparison against.

{
    "type": "boolean",
    "key": string,
    "val": boolean
}

declString

declString represents a filter declaration in which the type of val is string. The key is the name of the variable to declare comparison against.

{
    "type": "string",
    "key": string,
    "val": string
}

declInteger

declInteger represents a filter declaration in which the type of val is integer. The key is the name of the variable to declare comparison against.

{
    "type": "integer",
    "key": string,
    "val": integer
}

declFloat

declFloat represents a filter declaration in which the type of val is float. The key is the name of the variable to declare comparison against.

{
    "type": "float",
    "key": string,
    "val": float
}

filter

filter represents a filter to be applied on a paginated request. The filter data type is a complex object that can be recursively defined. Application of the filter will apply precedence from the top-level down, and any keys on the same level will be applied as an AND.

{
    "and"?: filter[],
    "or"?: filter[],
    "not"?: filter,
    "eq"?: declString | declBoolean | declInteger | declFloat,
    "gt"?: declString | declBoolean | declInteger | declFloat,
    "lt"?: declString | declBoolean | declInteger | declFloat,
    "regex"?: declString,
    "glob"?: declString
}

kind: image

image represents an image that has been uploaded by a user. An image's data is specified by its kind key, and has a link to the resource.

An image contains data about its extension (ex: "gif"), when the image was uploaded, and links to the image file and its thumbnail.

{
    "kind": "image",
    "link": string,
    "id": string,
    "extension": string,
    "fileLink": string,
    "thumbLink": string,
    "syncsCount": integer,
    "relations": {
        "syncs": string
    },
    "timeCreated": datetime
}

kind: sync

sync represents a synced image that has been created by a user. A sync's data is specified by its kind key, and has a link to the resource.

A sync contains data about its name, tempo, speed multiplier, when the sync was created and last updated, its owner, the image this sync is modifying, and links to the sync file and its thumbnail.

{
    "kind": "sync",
    "link": string,
    "id": string,
    "name": string,
    "tempo": float,
    "speedMultiplier": float,
    "fileLink": string,
    "thumbLink": string,
    "owner": user,
    "image": image,
    "timeCreated": datetime,
    "lastUpdated": datetime
}

kind: user

user represents both anonymous and registered users.

{
    "kind": "user",
    "link": string,
    "id": string,
    "name": string,
    "spotifyIntegration": boolean,
    "preferences": {
        "bgColor": string,
        "minTempo": float,
        "maxTempo": float
    },
    "syncsCount": integer,
    "relations": {
        "syncs": string
    },
    "timeCreated": datetime,
    "lastLogin": datetime
}

kind: page<T>

{
    "kind": "page",
    "link": string,
    "currPage": integer,
    "nextPage"?: integer,
    "prevPage"?: integer,
    "firstPage": integer,
    "lastPage": integer,
    "itemsPerPage": integer,
    "itemsCount": integer,
    "itemsTotal": integer,
    "items": T[]
    
}

Examples

Below are some example requests and responses that return objects corresponding to the above data types.

GET /users/{id}

GET /users/sUq2TLYxocpMPw
200 OK
{
    "apiVersion": 1,
    "kind": "user",
    "link": "https://api.gifsync.io/v1/users/sUq2TLYxocpMPw",
    "id": "sUq2TLYxocpMPw",
    "name": "Example User",
    "spotifyIntegration": true,
    "preferences": {
        "bgColor": "#171717",
        "minTempo": 80.0,
        "maxTempo": 180.0
    },
    "syncsCount": 2,
    "relations": {
        "syncs": "https://api.gifsync.io/v1/users/sUq2TLYxocpMPw/syncs"
    },
    "timeCreated": "2023-08-17T02:30:57Z",
    "lastLogin": "2023-08-17T02:35:24Z"
}

GET /users/{id}/syncs

GET /users/sUq2TLYxocpMPw/syncs
200 OK
{
    "apiVersion": 1,
    "kind": "page",
    "link": "https://api.gifsync.io/v1/users/sUq2TLYxocpMPw/syncs?page=1&perPage=2",
    "currPage": 1,
    "nextPage": 2,
    "firstPage": 1,
    "lastPage": 3,
    "itemsPerPage": 2,
    "itemsCount": 2,
    "itemsTotal": 5,
    "items": [
        {
            "kind": "sync",
            "link": "https://api.gifsync.io/v1/syncs/tcfNGLG0uO1igw",
            "id": "tcfNGLG0uO1igw",
            "name": "Example Sync 1",
            "tempo": 100.0,
            "speedMultiplier": 1.0,
            "fileLink": "https://s3.gifsync.io/syncs/2023/08/16/tcfNGLG0uO1igw.gif",
            "thumbLink": "https://s3.gifsync.io/thumbs/2023/08/16/EszjqTCXKO41AA.jpg",
            "owner": {
                "kind": "user",
                "link": "https://api.gifsync.io/v1/users/sUq2TLYxocpMPw",
                "id": "sUq2TLYxocpMPw",
                "name": "Example User",
                "spotifyIntegration": true,
                "preferences": {
                    "bgColor": "#171717",
                    "minTempo": 80.0,
                    "maxTempo": 180.0
                },
                "syncsCount": 2,
                "relations": {
                    "syncs": "https://api.gifsync.io/v1/users/sUq2TLYxocpMPw/syncs"
                },
                "timeCreated": "2023-08-17T02:30:57Z",
                "lastLogin": "2023-08-17T02:35:24Z"
            },
            "image": {
                "kind": "image",
                "link": "https://api.gifsync.io/v1/images/EszjqTCXKO41AA",
                "id": "EszjqTCXKO41AA",
                "extension": "gif",
                "fileLink": "https://s3.gifsync.io/images/2023/08/16/EszjqTCXKO41AA.gif",
                "thumbLink": "https://s3.gifsync.io/thumbs/2023/08/16/EszjqTCXKO41AA.jpg",
                "syncsCount": 1,
                "relations": {
                    "syncs": "https://api.gifsync.io/v1/images/EszjqTCXKO41AA/syncs"
                },
                "timeCreated": "2023‐08‐17T02:39:10Z"
            },
            "timeCreated": "2023-08-17T02:39:19Z",
            "lastUpdated": "2023-08-17T02:40:01Z"
        },
        {
            "kind": "sync",
            "link": "https://api.gifsync.io/v1/syncs/T3PXw33vyFY63w",
            "id": "T3PXw33vyFY63w",
            "name": "Example Sync 2",
            "tempo": 100.0,
            "speedMultiplier": 1.0,
            "fileLink": "https://s3.gifsync.io/syncs/2023/08/16/T3PXw33vyFY63w.gif",
            "thumbLink": "https://s3.gifsync.io/thumbs/2023/08/16/5rZMJviwA3Yn-g.jpg",
            "owner": {
                "kind": "user",
                "link": "https://api.gifsync.io/v1/users/sUq2TLYxocpMPw",
                "id": "sUq2TLYxocpMPw",
                "name": "Example User",
                "spotifyIntegration": true,
                "preferences": {
                    "bgColor": "#171717",
                    "minTempo": 80.0,
                    "maxTempo": 180.0
                },
                "syncsCount": 2,
                "relations": {
                    "syncs": "https://api.gifsync.io/v1/users/sUq2TLYxocpMPw/syncs"
                },
                "timeCreated": "2023-08-17T02:30:57Z",
                "lastLogin": "2023-08-17T02:35:24Z"
            },
            "image": {
                "kind": "image",
                "link": "https://api.gifsync.io/v1/images/5rZMJviwA3Yn-g",
                "id": "5rZMJviwA3Yn-g",
                "extension": "gif",
                "fileLink": "https://s3.gifsync.io/images/2023/08/16/5rZMJviwA3Yn-g.gif",
                "thumbLink": "https://s3.gifsync.io/thumbs/2023/08/16/5rZMJviwA3Yn-g.jpg",
                "syncsCount": 1,
                "relations": {
                    "syncs": "https://api.gifsync.io/v1/images/5rZMJviwA3Yn-g/syncs"
                },
                "timeCreated": "2023-08-17T02:39:10Z"
            },
            "timeCreated": "2023-08-17T02:39:19Z",
            "lastUpdated": "2023-08-17T02:40:01Z"
        }
    ]
}

GET /images/{id}

GET /images/5rZMJviwA3Yn-g
200 OK
{
    "apiVersion": 1,
    "kind": "image",
    "link": "https://api.gifsync.io/v1/images/5rZMJviwA3Yn-g",
    "id": "5rZMJviwA3Yn-g",
    "extension": "gif",
    "fileLink": "https://s3.gifsync.io/images/2023/08/16/5rZMJviwA3Yn-g.gif",
    "thumbLink": "https://s3.gifsync.io/thumbs/2023/08/16/5rZMJviwA3Yn-g.jpg",
    "syncsCount": 1,
    "relations": {
        "syncs": "https://api.gifsync.io/v1/images/5rZMJviwA3Yn-g/syncs"
    },
    "timeCreated": "2023-08-17T02:39:10Z"
}

GET /syncs/{id}

GET /syncs/T3PXw33vyFY63w
200 OK
{
    "kind": "sync",
    "link": "https://api.gifsync.io/v1/syncs/T3PXw33vyFY63w",
    "id": "T3PXw33vyFY63w",
    "name": "Example Sync 2",
    "tempo": 100.0,
    "speedMultiplier": 1.0,
    "fileLink": "https://s3.gifsync.io/syncs/2023/08/16/T3PXw33vyFY63w.gif",
    "thumbLink": "https://s3.gifsync.io/thumbs/2023/08/16/5rZMJviwA3Yn-g.jpg",
    "owner": {
        "kind": "user",
        "link": "https://api.gifsync.io/v1/users/sUq2TLYxocpMPw",
        "id": "sUq2TLYxocpMPw",
        "name": "Example User",
        "spotifyIntegration": true,
        "preferences": {
            "bgColor": "#171717",
            "minTempo": 80.0,
            "maxTempo": 180.0
        },
        "syncsCount": 2,
        "relations": {
            "syncs": "https://api.gifsync.io/v1/users/sUq2TLYxocpMPw/syncs"
        },
        "timeCreated": "2023-08-17T02:30:57Z",
        "lastLogin": "2023-08-17T02:35:24Z"
    },
    "image": {
        "kind": "image",
        "link": "https://api.gifsync.io/v1/images/5rZMJviwA3Yn-g",
        "id": "5rZMJviwA3Yn-g",
        "extension": "gif",
        "fileLink": "https://s3.gifsync.io/images/2023/08/16/5rZMJviwA3Yn-g.gif",
        "thumbLink": "https://s3.gifsync.io/thumbs/2023/08/16/5rZMJviwA3Yn-g.jpg",
        "syncsCount": 1,
        "relations": {
            "syncs": "https://api.gifsync.io/v1/images/5rZMJviwA3Yn-g/syncs"
        },
        "timeCreated": "2023-08-17T02:39:10Z"
    },
    "timeCreated": "2023-08-17T02:39:19Z",
    "lastUpdated": "2023-08-17T02:40:01Z"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment