Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag API Response #2348

Closed
sebgie opened this issue Mar 6, 2014 · 6 comments
Closed

Tag API Response #2348

sebgie opened this issue Mar 6, 2014 · 6 comments
Labels
affects:api Affects the Ghost API
Milestone

Comments

@sebgie
Copy link
Contributor

sebgie commented Mar 6, 2014

The structure of our JSON/REST APIs are up for spring cleaning #2124. I have compiled what I think could be changed to improve consistency and readability for tags?

Single Tag

GET /ghost/api/v0.1/tags/1 - not implemented yet

JSON Object (v0.1)

{
    id: 1,
    uuid: "9c8d3aa0-205d-440c-a49c-412f3ca4bc62",
    name: "tag",
    slug: "tag-post",
    description: null,
    parent_id: null,
    meta_title: null,
    meta_description: null,
    created_at: "2014-03-06T14:04:22.495Z",
    created_by: 1,
    updated_at: "2014-03-06T14:04:22.495Z",
    updated_by: 1
}

New JSON Object:

  • renamed parent_id to `parent and added as linked object.
  • wrapped in an object that contains a settings key and holds an array (jsonapi.org/format - singular ressource)
  • added links property (jsonapi.org/format - To-One Relationships)
  • added linked property (jsonapi.org/format - Compound documents)
  • Subject to change: created_by and updated_by could become expandable properties later (see Expanding JSON API Objects #2346).
{
    links: {
        tags.created_by: {
            href: "http://tbd.com",
            type: "users"
        },
        tags.updated_by: {
            href: "http://tbd.com",
            type: "users"
        },
        users.roles: {
            href: "http://tbd.com",
            type: "roles"
        },
        roles.permissions: {
            href: "http://tbd.com",
            type: "permissions"
        }
    },
    tags: [{
        id: 1,
        uuid: "9c8d3aa0-205d-440c-a49c-412f3ca4bc62",
        name: "tag",
        slug: "tag-post",
        description: null,
        meta_title: null,
        meta_description: null,
        created_at: "2014-03-06T14:04:22.495Z",
        updated_at: "2014-03-06T14:04:22.495Z",
        links: {
            parent: null,
            created_by: 1,
            updated_by: 1
        }
    ]},
    linked: {
        users: [
            {
                id: 1,
                uuid: '27771667-2134-4899-891a-551c22e3b815',
                name: 'Joe Bloggs',
                slug: 'joe-blogs',
                ...,
                links: {
                    roles: 1
                }
            }
        ],
        roles: [
            {
                id: 1,
                description: 'Administrators,
                name: 'Administrator',
                ...,
                links: {
                    permissions: [1]
                }
            }
        ],
        permissions: [
            {
                id: 1,
                name: 'Edit posts',
                ...,
            },
            {...}
        ]
    }
}

Tag Collection

GET /ghost/api/v0.1/tags/

JSON Object (v0.1)

[
    {...},
    {...}
]

New JSON Object:

  • respond with an object and move the tags array into a tags property
  • added linked property (jsonapi.org/format - Compound documents)
  • added links property (jsonapi.org/format - Compound documents)
{
    links: {...},
    tags: [
        {...},
        {...},
    ],
    linked: {
        users: [
            {...}
        ],
        roles: [
            {...}
        ],
        permissions: [
            {...},
            {...}
        ]
    }
}
@ErisDS ErisDS added this to the 0.5 milestone Mar 7, 2014
@sebgie sebgie mentioned this issue Mar 7, 2014
61 tasks
@ErisDS ErisDS added the api label Mar 7, 2014
@ErisDS
Copy link
Member

ErisDS commented Mar 7, 2014

👍

@sebgie
Copy link
Contributor Author

sebgie commented Mar 17, 2014

I updated the user responses to follow the JSON API format. See #2362.

@hswolff
Copy link
Contributor

hswolff commented Mar 18, 2014

Should parent_id also be linked?

@sebgie
Copy link
Contributor Author

sebgie commented Mar 18, 2014

Updated:
parent_id is renamed to parent and added as linked object. parent is not used or implemented at the moment.

@hswolff: 👍!

@ErisDS
Copy link
Member

ErisDS commented Apr 2, 2014

Another API response that's good to go

@ErisDS
Copy link
Member

ErisDS commented Apr 8, 2014

Single tag:

{ 
    tags: [{
        id: 1,
        uuid: "9c8d3aa0-205d-440c-a49c-412f3ca4bc62",
        name: "tag",
        slug: "tag-post",
        description: null,
        parent: {...}, (or null for now?)
        meta_title: null,
        meta_description: null,
        created_at: "2014-03-06T14:04:22.495Z",
        created_by: {...},
        updated_at: "2014-03-06T14:04:22.495Z",
        updated_by: {...}
    }]
}

Tag collection:

{
    tags: [{...}, {...}],
    meta: {
        ...
    }
}

Would need to be paginated but likely with a different default limit to posts? 15 is a weird limit for such a small thing as tags I think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects:api Affects the Ghost API
Projects
None yet
Development

No branches or pull requests

3 participants