Get attachments

Fetch metadata on files uploaded by the requesting user.

GET https://macports-gsoc.zulipchat.com/api/v1/attachments

Usage examples

#!/usr/bin/env python3

import zulip

# Pass the path to your zuliprc file here.
client = zulip.Client(config_file="~/zuliprc")

# Get your attachments.

result = client.get_attachments()
print(result)

curl -sSX GET -G https://macports-gsoc.zulipchat.com/api/v1/attachments \
    -u BOT_EMAIL_ADDRESS:BOT_API_KEY

Parameters

This endpoint does not accept any parameters.

Response

Return values

  • attachments: A list of attachment objects, each containing details about a file uploaded by the user.

    • id: The unique ID for the attachment.

    • name: Name of the uploaded file.

    • path_id: A representation of the path of the file within the repository of user-uploaded files. If the path_id of a file is {realm_id}/ab/cdef/temp_file.py, its URL will be: {server_url}/user_uploads/{realm_id}/ab/cdef/temp_file.py.

    • size: Size of the file in bytes.

    • create_time: Time when the attachment was uploaded as a UNIX timestamp multiplied by 1000 (matching the format of getTime() in JavaScript).

      Changes: Changed in Zulip 2.2 (feature level 22). This field was previously a floating point number.

    • messages: Contains basic details on any Zulip messages that have been sent referencing this uploaded file. This includes messages sent by any user in the Zulip organization who sent a message containing a link to the uploaded file.

      • date_sent: Time when the message was sent as a UNIX timestamp multiplied by 1000 (matching the format of getTime() in JavaScript).

        Changes: Changed in Zulip 2.2 (feature level 22). This field was previously strangely called name and was a floating point number.

      • id: The unique message ID. Messages should always be displayed sorted by ID.

  • upload_space_used: The total size of all files uploaded by in the organization, in bytes.

Example response

A typical successful JSON response may look like:

{
    "attachments": [
        {
            "create_time": 1588145417000,
            "id": 1,
            "messages": [
                {
                    "date_sent": 1588145424000,
                    "id": 102
                },
                {
                    "date_sent": 1588145448000,
                    "id": 103
                }
            ],
            "name": "166050.jpg",
            "path_id": "2/ce/DfOkzwdg_IwlrN3myw3KGtiJ/166050.jpg",
            "size": 571946
        }
    ],
    "msg": "",
    "result": "success",
    "upload_space_used": 571946
}