Help: 2. Categories

Help Portal » Knowledgebase » WhisperGifts API » 2. Categories

How can I get a list of current categories that an item may be included in?

Read-only access is available to the list of predefined item categories. This list may change in the future, however the ID for a given category will always remain static.

Any time a category is shown to a user, you should show them the name. The ID must be used internally for all item creation or update requests.

List All Categories

Request

curl -X GET "https://www.whispergifts.com/api/categories/" -H "API-Auth: user_id:api_key"

Response

A JSON object is returned that includes pagination option, plus an objects object which contains a list of categories.

{
    count: 17,
    per_page: 50,
    num_pages: 1,
    page: 1,
    objects: [
        {
            id: 1,
            name: "Dinnerware"
        },
        {
            id: 2,
            name: "Cookware"
        },
        {
            id: 3,
            name: "Kitchenware"
        },
        {
            id: 4,
            name: "Glassware"
        },
        ...
    ]
}

It is recommended that you fetch the category list on a semi-regular basis and cache it locally for best performance. Doing so will avoid having to load individual categories.

Retrieve A Single Category

If necessary you can fetch a single category, however since the list set is so small and easily manageable in a local cache it is not likely that you will need to retrieve these individually.

Request

curl -X GET "https://www.whispergifts.com/api/v0/categories/1/" -H "API-Auth: user_id:api_key"

Response

A JSON object is returned showing the id and name of the requested category.

{
        id: 1,
        name: "Dinnerware"
        }

Create or Update Categories

Categories are used by all WhisperGifts users and as such are only editable by the WhisperGifts team as necessary. The API does not allow for authenticated users to create, modify, or delete category data.