### Get List Information Success Response Source: https://pixeldrain.com/api HTTP 200 OK response for retrieving information about a file list. Includes basic file information and a 'detail_href' for more details. ```json { "success": true, "id": "L8bhwx", "title": "Rust in Peace", "date_created": 2020-02-04T18:34:13.466276Z, "files": [ { "detail_href": "/file/_SqVWi/info", "description": "", "success": true, "id": "_SqVWi", "name": "01 Holy Wars... The Punishment Due.mp3", "size": 123456, "date_created": 2020-02-04T18:34:13.466276Z, "date_last_view": 2020-02-04T18:34:13.466276Z, "mime_type": "audio/mp3", "views": 1, "bandwidth_used": 1234567890, "thumbnail_href": "/file/_SqVWi/thumbnail" }, { "detail_href": "/file/RKwgZb/info", "description": "", "success": true, "id": "RKwgZb", "name": "02 Hangar 18.mp3", "size": 123456, "date_created": 2020-02-04T18:34:13.466276Z, "date_last_view": 2020-02-04T18:34:13.466276Z, "mime_type": "audio/mp3", "views": 2, "bandwidth_used": 1234567890, "thumbnail_href": "/file/RKwgZb/thumbnail" }, { "detail_href": "/file/DRaL_e/info", "description": "", "success": true, "id": "DRaL_e", "name": "03 Take No Prisoners.mp3", "size": 123456, "date_created": 2020-02-04T18:34:13.466276Z, "date_last_view": 2020-02-04T18:34:13.466276Z, "mime_type": "audio/mp3", "views": 3, "bandwidth_used": 1234567890, "thumbnail_href": "/file/DRaL_e/thumbnail" } ] } ``` -------------------------------- ### Create List POST Body Example Source: https://pixeldrain.com/api Use this JSON structure to create a new list. The 'title' defaults to 'Pixeldrain List' and 'anonymous' defaults to false. A list can contain up to 10000 files. ```json { "title": "My beautiful photos", // Defaults to "Pixeldrain List" "anonymous": false / true, // If true this list will not be linked to your user account. Defaults to "false" "files": [ // Ordered array of files to add to the list { "id": "abc123", "description": "First photo of the week, such a beautiful valley" }, { "id": "123abc", "description": "The week went by so quickly, here's a photo from the plane back" } ] } ``` -------------------------------- ### Get List Information Source: https://pixeldrain.com/api Retrieves information about a specific file list and the files it contains. ```APIDOC ## GET /list/{id} ### Description Returns information about a file list and the files in it. ### Method GET ### Endpoint /list/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the list to retrieve. ### Returns The API will return basic information about each file in the list. Each file object includes a `detail_href` field which is a relative URL to the file's info API. Appending this URL to the API base URL will provide more detailed information about the file. #### Success Response (200 OK) - **success** (boolean) - Indicates if the operation was successful. - **id** (string) - The ID of the list. - **title** (string) - The title of the list. - **date_created** (string) - The date and time the list was created (ISO 8601 format). - **files** (array) - An array of file objects included in the list. - **detail_href** (string) - Relative URL to get detailed information about the file. - **description** (string) - Description of the file within the list. - **success** (boolean) - Indicates if the file information retrieval was successful. - **id** (string) - The ID of the file. - **name** (string) - The name of the file. - **size** (integer) - The size of the file in bytes. - **date_created** (string) - The date and time the file was created (ISO 8601 format). - **date_last_view** (string) - The date and time the file was last viewed (ISO 8601 format). - **mime_type** (string) - The MIME type of the file. - **views** (integer) - The number of times the file has been viewed. - **bandwidth_used** (integer) - The total bandwidth used by the file in bytes. - **thumbnail_href** (string) - Relative URL to the file's thumbnail. #### Response Example ```json { "success": true, "id": "L8bhwx", "title": "Rust in Peace", "date_created": "2020-02-04T18:34:13.466276Z", "files": [ { "detail_href": "/file/_SqVWi/info", "description": "", "success": true, "id": "_SqVWi", "name": "01 Holy Wars... The Punishment Due.mp3", "size": 123456, "date_created": "2020-02-04T18:34:13.466276Z", "date_last_view": "2020-02-04T18:34:13.466276Z", "mime_type": "audio/mp3", "views": 1, "bandwidth_used": 1234567890, "thumbnail_href": "/file/_SqVWi/thumbnail" } ] } ``` #### Error Responses - **404 Not Found (list_not_found)**: The specified list ID was not found. ``` -------------------------------- ### Retrieve File (GET /file/{id}) Source: https://pixeldrain.com/api Retrieve a file using its ID. ```APIDOC ## GET /file/{id} ``` -------------------------------- ### GET /file/{id}/thumbnail Source: https://pixeldrain.com/api Generates and returns a PNG thumbnail image for the specified file. Optional `width` and `height` parameters can be provided to customize the thumbnail dimensions, which must be multiples of 16. ```APIDOC ## GET /file/{id}/thumbnail ### Description Returns a PNG thumbnail image representing the file. The thumbnail image will be 128x128 px by default. You can specify the width and height with parameters in the URL. The width and height parameters need to be a multiple of 16. So the allowed values are 16, 32, 48, 64, 80, 96, 112 and 128. If a thumbnail cannot be generated for the file you will be redirected to a mime type image of 128x128 px. ### Method GET ### Endpoint /file/{id}/thumbnail ### Parameters #### Path Parameters - **id** (string) - Required - ID of the file to get a thumbnail for #### Query Parameters - **width** (integer) - Optional - Width of the thumbnail image (multiple of 16) - **height** (integer) - Optional - Height of the thumbnail image (multiple of 16) ### Returns A PNG image if a thumbnail can be generated. If a thumbnail cannot be generated you will get a 301 redirect to an image representing the type of the file. ``` -------------------------------- ### Upload File using curl Source: https://pixeldrain.com/api Upload a file to Pixeldrain using the curl command-line tool. Replace the example API key with your own. This method uses the API key directly in the URL for authentication. ```bash curl -T "file_name.txt" -u :5f45f184-64bb-4eaa-be19-4a5f0459db49 https://pixeldrain.com/api/file/ ``` -------------------------------- ### GET /file/{id} Source: https://pixeldrain.com/api Retrieves the full file associated with the given ID. Supports byte range requests and can be configured to force download via the `?download` query parameter. ```APIDOC ## GET /file/{id} ### Description Returns the full file associated with the ID. Supports byte range requests. When ‘?download’ is added to the URL the server will send an attachment header instead of inline rendering, which causes the browser to show a ‘Save File’ dialog. ### Method GET ### Endpoint /file/{id} ### Parameters #### Path Parameters - **id** (string) - Required - ID of the file to request #### Query Parameters - **download** (boolean) - Optional - Sends attachment header instead of inline rendering. ### Response #### Success Response (200) Requested file data #### Error Response (404) ```json { "success": false, "value": "not_found", "message": "The entity you requested could not be found" } ``` #### Error Response (403 - Rate Limited) ```json { "success": false, "value": "file_rate_limited_captcha_required", "message": "This file is using too much bandwidth. For anonymous downloads a captcha is required now. The captcha entry is available on the download page" } ``` #### Error Response (403 - Virus Detected) ```json { "success": false, "value": "virus_detected_captcha_required", "message": "This file has been marked as malware by our scanning systems. To avoid infecting other systems through automated downloads we require you to enter a captcha. The captcha entry is available on the download page" } ``` ``` -------------------------------- ### GET /file/{id}/info Source: https://pixeldrain.com/api Retrieves information about a specific file using its ID. Can also accept a comma-separated list of IDs to retrieve information for multiple files in a single request (up to 1000 files). ```APIDOC ## GET /file/{id}/info ### Description Returns information about one or more files. You can also put a comma separated list of file IDs in the URL and it will return an array of file info, instead of a single object. There’s a limit of 1000 files per request. ### Method GET ### Endpoint /file/{id}/info ### Parameters #### Path Parameters - **id** (string) - Required - ID of the file ### Response #### Success Response (200) ```json { "id": "1234abcd", "name": "screenshot.png", "size": 5694837, "views": 1234, "bandwidth_used": 1234567890, "bandwidth_used_paid": 1234567890, "downloads": 1234, "date_upload": "2020-02-04T18:34:05.706801Z", "date_last_view": "2020-02-04T18:34:05.706801Z", "mime_type": "image/png", "thumbnail_href": "/file/1234abcd/thumbnail", "hash_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "can_edit": true } ``` #### Error Response (404) ```json { "success": false, "value": "file_not_found" } ``` ``` -------------------------------- ### Authenticate and List User Files with JavaScript Source: https://pixeldrain.com/api Demonstrates how to authenticate using an API key with Basic Access Authentication and fetch a list of user files. Ensure your API key is correctly formatted and the `btoa` function is available for Base64 encoding. ```javascript const resp = await fetch( "https://pixeldrain.com/api/user/files", headers: { "Authorization": "Basic "+btoa(":"+api_key), // The btoa function encodes the key to Base64 }, ) if(resp.status >= 400) { throw new Error(await resp.json()) } result = await resp.json() ``` -------------------------------- ### List Creation Empty List Error Source: https://pixeldrain.com/api HTTP 422 Unprocessable Entity response when attempting to create a list with no files. ```json { "success": false, "value": "cannot_create_empty_list", "message": "You cannot make a list with no files." } ``` -------------------------------- ### Create List Source: https://pixeldrain.com/api Creates a new file list. The POST body should be a JSON object. A list can contain at most 10000 files. ```APIDOC ## POST /list ### Description Creates a new file list with specified files and metadata. ### Method POST ### Endpoint /list ### Parameters #### Request Body - **title** (string) - Optional - Defaults to "Pixeldrain List". The title of the list. - **anonymous** (boolean) - Optional - If true, the list will not be linked to your user account. Defaults to "false". - **files** (array) - Required - An ordered array of files to add to the list. Each file object must contain an `id` and optionally a `description`. - **id** (string) - Required - The ID of the file to add. - **description** (string) - Optional - A description for the file within the list. ### Request Example ```json { "title": "My beautiful photos", "anonymous": false, "files": [ { "id": "abc123", "description": "First photo of the week, such a beautiful valley" }, { "id": "123abc", "description": "The week went by so quickly, here's a photo from the plane back" } ] } ``` ### Response #### Success Response (200 OK) - **success** (boolean) - Indicates if the operation was successful. - **id** (string) - The ID of the newly created list. #### Response Example ```json { "success": true, "id": "yay137" } ``` #### Error Responses - **422 Unprocessable Entity (list_file_not_found)**: A file ID provided in the `files` array was not found. - **413 Payload too large (too_many_files)**: The list contains more than 10000 files. - **422 Unprocessable Entity (json_parse_failed)**: The request body could not be parsed as JSON. - **413 Payload too large (title_too_long)**: The list title exceeds the maximum allowed length (300 characters). - **413 Payload too large (description_too_long)**: A file description exceeds the maximum allowed length (3000 characters). - **422 Unprocessable Entity (cannot_create_empty_list)**: The list was created with no files. ``` -------------------------------- ### List Creation File Not Found Error Source: https://pixeldrain.com/api HTTP 422 Unprocessable Entity response when a file ID provided in the request does not exist. ```json { "success": false, "value": "list_file_not_found", "message": "File Oh42No was not found in the database.", "extra": { "file_not_found": "0h42No" // The file you tried to add with this ID does not exist } } ``` -------------------------------- ### POST /list Source: https://pixeldrain.com/api Creates a list of files that can be viewed together on the file viewer page. ```APIDOC ## POST /list ### Description Creates a list of files that can be viewed together on the file viewer page. ### Method POST ### Endpoint /list ``` -------------------------------- ### List Creation Success Response Source: https://pixeldrain.com/api HTTP 200 OK response upon successful list creation. Includes the ID of the newly created list. ```json { "success": true, "id": "yay137" // ID of the newly created list } ``` -------------------------------- ### List Creation Too Many Files Error Source: https://pixeldrain.com/api HTTP 413 Payload Too Large response when the list exceeds the maximum of 10000 files. ```json { "success": false, "value": "too_many_files", "message": "This list contains too many files, max 10000 allowed." } ``` -------------------------------- ### List Creation File Description Too Long Error Source: https://pixeldrain.com/api HTTP 413 Payload Too Large response when a file description within the list exceeds the maximum of 3000 characters. ```json { "success": false, "value": "description_too_long", "message": "The description of one of the files in the list is too long, max 3000 characters allowed." } ``` -------------------------------- ### Upload File (POST /file) Source: https://pixeldrain.com/api Upload a file using a POST request. It is recommended to use the PUT API instead due to potential performance issues with multipart encoding in certain environments. ```APIDOC ## POST /file ### Description Upload a file. I recommend that you use the PUT API instead of the POST API. It’s easier to use and the multipart encoding of the POST API can cause performance issues in certain environments. ### Parameters Param | Type | Required | Maximum Size | Default | Description ---|---|---|---|---|--- name | string | false | 255 characters | multipart file name | Name of the file to upload file | multipart file | true | Depends on user subscription | none | File to upload ### Returns HTTP 200: OK ```json { "success": true, "id": "abc123" // ID of the newly uploaded file } ``` HTTP 422: Unprocessable Entity ```json { "success": false, "value": "no_file", "message": "The file does not exist or is empty." } ``` HTTP 500: Internal Server Error ```json { "success": false, "value": "internal", "message": "An internal server error occurred." } ``` HTTP 413: Payload Too Large ```json { "success": false, "value": "file_too_large", "message": "The file you tried to upload is too large" } ``` HTTP 500: Internal Server Error ```json { "success": false, "value": "writing", "message": "Something went wrong while writing the file to disk, the server may be out of storage space." } ``` HTTP 413: Payload Too Large ```json { "success": false, "value": "name_too_long", "message": "File Name is too long, Max 255 characters allowed." } ``` ``` -------------------------------- ### List Not Found Error Response Source: https://pixeldrain.com/api HTTP 404 Not Found response when the requested list ID does not exist. ```json { "success": false, "value": "list_not_found" } ``` -------------------------------- ### Upload File (PUT /file/{name}) Source: https://pixeldrain.com/api Upload a file using a PUT request, specifying the file name in the URL. ```APIDOC ## PUT /file/{name} ### Description Upload a file. ### Parameters Param | Type | Required | Location | Maximum Size | Default | Description ---|---|---|---|---|---|--- name | string | true | URL | 255 characters | none | Name of the file to upload file | file | true | request body | Depends on user subscription | none | File to upload ### Returns HTTP 201: OK ```json { "id": "abc123" // ID of the newly uploaded file } ``` HTTP 422: Unprocessable Entity ```json { "success": false, "value": "no_file", "message": "The file does not exist or is empty." } ``` HTTP 500: Internal Server Error ```json { "success": false, "value": "internal", "message": "An internal server error occurred." } ``` HTTP 413: Payload Too Large ```json { "success": false, "value": "file_too_large", "message": "The file you tried to upload is too large" } ``` HTTP 500: Internal Server Error ```json { "success": false, "value": "writing", "message": "Something went wrong while writing the file to disk, the server may be out of storage space." } ``` HTTP 413: Payload Too Large ```json { "success": false, "value": "name_too_long", "message": "File Name is too long, Max 255 characters allowed." } ``` ``` -------------------------------- ### List Creation JSON Parse Error Source: https://pixeldrain.com/api HTTP 422 Unprocessable Entity response when the request body's JSON is invalid. ```json { "success": false, "value": "json_parse_failed", "message": "The JSON object in the request body could not be read." } ``` -------------------------------- ### Handle File Writing Error (POST) Source: https://pixeldrain.com/api This JSON response indicates an error occurred while writing the file to disk during a POST upload, possibly due to insufficient storage space. ```json { "success": false, "value": "writing", "message": "Something went wrong while writing the file to disk, the server may be out of storage space." } ``` -------------------------------- ### Handle Successful File Upload (POST) Source: https://pixeldrain.com/api This JSON response indicates a successful file upload using the POST method, returning the ID of the newly uploaded file. ```json { "success": true, "id": "abc123" // ID of the newly uploaded file } ``` -------------------------------- ### Handle File Too Large Error (POST) Source: https://pixeldrain.com/api This JSON response indicates that the file being uploaded via POST exceeds the allowed size limit. ```json { "success": false, "value": "file_too_large", "message": "The file you tried to upload is too large" } ``` -------------------------------- ### Handle Successful File Upload (PUT) Source: https://pixeldrain.com/api This JSON response indicates a successful file upload using the PUT method, returning the ID of the newly uploaded file. ```json { "id": "abc123" // ID of the newly uploaded file } ``` -------------------------------- ### List Creation Title Too Long Error Source: https://pixeldrain.com/api HTTP 413 Payload Too Large response when the list title exceeds the maximum of 300 characters. ```json { "success": false, "value": "title_too_long", "message": "The title of this list is too long, max 300 characters allowed." } ``` -------------------------------- ### DELETE /file/{id} Source: https://pixeldrain.com/api Deletes a file. This operation is only permitted for the owner of the file. ```APIDOC ## DELETE /file/{id} ### Description Deletes a file. Only works when the users owns the file. ### Method DELETE ### Endpoint /file/{id} ### Parameters #### Path Parameters - **id** (string) - Required - ID of the file to delete ### Response #### Success Response (200) ```json { "success": true, "value": "file_deleted", "message": "The file has been deleted." } ``` #### Error Response (404) ```json { "success": false, "value": "file_not_found", "message": "File ID was not found in the database." } ``` #### Error Response (401) ```json { "success": false, "value": "unauthorized", "message": "You are not logged in." } ``` #### Error Response (403) ```json { "success": false, "value": "forbidden", "message": "This is not your file." } ``` ``` -------------------------------- ### Handle Unprocessable Entity Error (POST) Source: https://pixeldrain.com/api This JSON response indicates an unprocessable entity error during file upload via POST, typically because the file is missing or empty. ```json { "success": false, "value": "no_file", "message": "The file does not exist or is empty." } ``` -------------------------------- ### Handle File Name Too Long Error (POST) Source: https://pixeldrain.com/api This JSON response indicates that the provided file name exceeds the maximum allowed length of 255 characters during a POST upload. ```json { "success": false, "value": "name_too_long", "message": "File Name is too long, Max 255 characters allowed." } ``` -------------------------------- ### Handle Internal Server Error (POST) Source: https://pixeldrain.com/api This JSON response indicates an internal server error during file upload via POST. This could be due to various server-side issues. ```json { "success": false, "value": "internal", "message": "An internal server error occurred." } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.