### URL Rescue Examples Source: https://cdn.hackclub.com/docs/using-cdn-urls Examples of original URLs to use with the URL rescue endpoint. ```text /rescue?url=https://hc-cdn.hel1.your-objectstorage.com/s/v3/sdhfksdjfhskdjf.png ``` ```text /rescue?url=https://cloud-xxxx-hack-club-bot.vercel.app/0awawawa.png ``` -------------------------------- ### URL Rescue Endpoint Source: https://cdn.hackclub.com/docs/using-cdn-urls Use this GET request to find the new CDN URL for files migrated from legacy CDNs. ```http GET /rescue?url={original_url} ``` -------------------------------- ### Get User Info Source: https://cdn.hackclub.com/docs/api Retrieve information about the authenticated user, including storage usage and limits. ```APIDOC ## GET /api/v4/me ### Description Get the authenticated user and quota information. ### Method GET ### Endpoint https://cdn.hackclub.com/api/v4/me ### Request Example ```curl curl -H "Authorization: Bearer sk_cdn_your_key_here" \ https://cdn.hackclub.com/api/v4/me ``` ### Response #### Success Response (200) - **id** (string) - The user's unique identifier. - **email** (string) - The user's email address. - **name** (string) - The user's name. - **storage_used** (integer) - The amount of storage used in bytes. - **storage_limit** (integer) - The total storage limit in bytes. - **quota_tier** (string) - The user's quota tier (`unverified`, `verified`, or `functionally_unlimited`). #### Response Example ```json { "id": "usr_abc123", "email": "you@hackclub.com", "name": "Your Name", "storage_used": 1048576000, "storage_limit": 53687091200, "quota_tier": "verified" } ``` **Quota fields:** - `storage_used` — bytes used - `storage_limit` — bytes allowed - `quota_tier` — `"unverified"`, `"verified"`, or `"functionally_unlimited"` ``` -------------------------------- ### Get User and Quota Information via cURL Source: https://cdn.hackclub.com/docs/api Retrieve authenticated user details and storage quota information using a cURL GET request. This requires the Authorization header. ```curl curl -H "Authorization: Bearer sk_cdn_your_key_here" \ https://cdn.hackclub.com/api/v4/me ``` -------------------------------- ### Standard Error Response Source: https://cdn.hackclub.com/docs/api This is an example of a standard error response from the API, typically indicating missing parameters or validation failures. ```json { "error": "Missing file parameter" } ``` -------------------------------- ### Check Your Usage Source: https://cdn.hackclub.com/docs/quotas Retrieve your current storage usage, limit, and quota tier using your API key. ```APIDOC ## GET /api/v4/me ### Description Retrieves the current user's storage usage, limit, and quota tier. ### Method GET ### Endpoint https://cdn.hackclub.com/api/v4/me ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication (e.g., `Bearer YOUR_API_KEY`) ### Response #### Success Response (200) - **storage_used** (integer) - The amount of storage currently used in bytes. - **storage_limit** (integer) - The total storage limit in bytes. - **quota_tier** (string) - The current quota tier (e.g., "verified"). ### Response Example ```json { "storage_used": 1048576000, "storage_limit": 53687091200, "quota_tier": "verified" } ``` ``` -------------------------------- ### Check CDN Usage via API Source: https://cdn.hackclub.com/docs/quotas Use this curl command to fetch your current storage usage and limit from the CDN API. Replace YOUR_API_KEY with your actual API key. ```bash curl -H "Authorization: Bearer YOUR_API_KEY" \ https://cdn.hackclub.com/api/v4/me ``` -------------------------------- ### Upload from URL Source: https://cdn.hackclub.com/docs/api Upload an image to the Hack Club CDN from a given URL. Supports optional authentication for the source URL. ```APIDOC ## POST /api/v4/upload_from_url ### Description Upload an image from a URL. ### Method POST ### Endpoint https://cdn.hackclub.com/api/v4/upload_from_url ### Headers - **Authorization** (string) - Required - Bearer token for authentication. - **X-Download-Authorization** (string) - Optional - Bearer token for authenticating the source URL request. - **Content-Type** (string) - Required - Must be `application/json`. ### Parameters #### Request Body - **url** (string) - Required - The URL of the image to upload. ### Request Example ```curl # Standard upload curl -X POST \ -H "Authorization: Bearer sk_cdn_your_key_here" \ -H "Content-Type: application/json" \ -d '{"url":"https://example.com/image.jpg"}' \ https://cdn.hackclub.com/api/v4/upload_from_url # With authentication for the source URL: curl -X POST \ -H "Authorization: Bearer sk_cdn_your_key_here" \ -H "X-Download-Authorization: Bearer source_token_here" \ -H "Content-Type: application/json" \ -d '{"url":"https://protected.example.com/image.jpg"}' \ https://cdn.hackclub.com/api/v4/upload_from_url ``` ```javascript // Standard upload const response = await fetch('https://cdn.hackclub.com/api/v4/upload_from_url', { method: 'POST', headers: { 'Authorization': 'Bearer sk_cdn_your_key_here', 'Content-Type': 'application/json' }, body: JSON.stringify({ url: 'https://example.com/image.jpg' }) }); // With authentication for the source URL: const responseWithAuth = await fetch('https://cdn.hackclub.com/api/v4/upload_from_url', { method: 'POST', headers: { 'Authorization': 'Bearer sk_cdn_your_key_here', 'Content-Type': 'application/json', 'X-Download-Authorization': 'Bearer source_token_here' }, body: JSON.stringify({ url: 'https://protected.example.com/image.jpg' }) }); const { url } = await response.json(); ``` ### Response #### Success Response (200) - **url** (string) - The URL to access the uploaded file. #### Response Example ```json { "url": "https://cdn.hackclub.com/01234567-89ab-cdef-0123-456789abcdef/image.jpg" } ``` ``` -------------------------------- ### Upload Image from URL via JavaScript Fetch API Source: https://cdn.hackclub.com/docs/api This JavaScript snippet shows how to upload an image from a URL using the Fetch API. It includes optional support for authenticating the source URL via the `X-Download-Authorization` header. ```javascript const response = await fetch('https://cdn.hackclub.com/api/v4/upload_from_url', { method: 'POST', headers: { 'Authorization': 'Bearer sk_cdn_your_key_here', 'Content-Type': 'application/json', // Optional: auth for the source URL 'X-Download-Authorization': 'Bearer source_token_here' }, body: JSON.stringify({ url: 'https://example.com/image.jpg' }) }); const { url } = await response.json(); ``` -------------------------------- ### Authenticate with API Key Source: https://cdn.hackclub.com/docs/api API keys are required for authentication. Include your key in the Authorization header as a Bearer token. Keys are shown only once upon creation. ```text Authorization: Bearer sk_cdn_your_key_here ``` -------------------------------- ### Linking to a Document with CDN URL Source: https://cdn.hackclub.com/docs/using-cdn-urls Use this HTML structure to create links to documents hosted on the Hack Club CDN. ```html Download ``` -------------------------------- ### Upload Image from URL via cURL (Protected URL) Source: https://cdn.hackclub.com/docs/api Upload an image from a protected URL using cURL. The `X-Download-Authorization` header is used to pass authentication credentials for the source URL. ```curl curl -X POST \ -H "Authorization: Bearer sk_cdn_your_key_here" \ -H "X-Download-Authorization: Bearer source_token_here" \ -H "Content-Type: application/json" \ -d '{"url":"https://protected.example.com/image.jpg"}' \ https://cdn.hackclub.com/api/v4/upload_from_url ``` -------------------------------- ### Upload File via cURL Source: https://cdn.hackclub.com/docs/api Use this cURL command to upload a file using multipart form data. Ensure the file path is correct and the Authorization header contains a valid API key. ```curl curl -X POST \ -H "Authorization: Bearer sk_cdn_your_key_here" \ -F "file=@photo.jpg" \ https://cdn.hackclub.com/api/v4/upload ``` -------------------------------- ### Upload File via JavaScript Fetch API Source: https://cdn.hackclub.com/docs/api This JavaScript snippet demonstrates uploading a file using the Fetch API. It appends the file to FormData and includes the Authorization header. The response contains the URL of the uploaded file. ```javascript const formData = new FormData(); formData.append('file', fileInput.files[0]); const response = await fetch('https://cdn.hackclub.com/api/v4/upload', { method: 'POST', headers: { 'Authorization': 'Bearer sk_cdn_your_key_here' }, body: formData }); const { url } = await response.json(); ``` -------------------------------- ### Use Image in Markdown Source: https://cdn.hackclub.com/docs/getting-started Include an uploaded image in your Markdown documents using standard Markdown image syntax. ```markdown ![](https://cdn.hackclub.com/019505e2-c85b-7f80-9c31-4b2e5a8d9f12/photo.jpg) ``` -------------------------------- ### Upload File Source: https://cdn.hackclub.com/docs/api Upload a file to the Hack Club CDN using multipart form data. Requires an API key for authentication. ```APIDOC ## POST /api/v4/upload ### Description Upload a file via multipart form data. ### Method POST ### Endpoint https://cdn.hackclub.com/api/v4/upload ### Parameters #### Request Body - **file** (file) - Required - The file to upload. ### Request Example ```curl curl -X POST \ -H "Authorization: Bearer sk_cdn_your_key_here" \ -F "file=@photo.jpg" \ https://cdn.hackclub.com/api/v4/upload ``` ```javascript const formData = new FormData(); formData.append('file', fileInput.files[0]); const response = await fetch('https://cdn.hackclub.com/api/v4/upload', { method: 'POST', headers: { 'Authorization': 'Bearer sk_cdn_your_key_here' }, body: formData }); const { url } = await response.json(); ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the uploaded file. - **filename** (string) - The original name of the file. - **size** (integer) - The size of the file in bytes. - **content_type** (string) - The MIME type of the file. - **url** (string) - The URL to access the uploaded file. - **created_at** (string) - The timestamp when the file was uploaded (ISO 8601 format). #### Response Example ```json { "id": "01234567-89ab-cdef-0123-456789abcdef", "filename": "photo.jpg", "size": 12345, "content_type": "image/jpeg", "url": "https://cdn.hackclub.com/01234567-89ab-cdef-0123-456789abcdef/photo.jpg", "created_at": "2026-01-29T12:00:00Z" } ``` ``` -------------------------------- ### Use Image in HTML Source: https://cdn.hackclub.com/docs/getting-started Embed an uploaded image directly into your HTML pages using an `` tag. ```html My image ``` -------------------------------- ### Embedding an Image in Markdown with CDN URL Source: https://cdn.hackclub.com/docs/using-cdn-urls Use this Markdown syntax to embed images hosted on the Hack Club CDN. ```markdown ![](https://cdn.hackclub.com/019505e2-e7f3-7d40-a156-9c4e8b2d1f03/screenshot.png) ``` -------------------------------- ### Upload Image from URL via cURL (Public URL) Source: https://cdn.hackclub.com/docs/api Upload an image from a public URL using cURL. The request body must be JSON containing the URL, and the Authorization header must be included. ```curl curl -X POST \ -H "Authorization: Bearer sk_cdn_your_key_here" \ -H "Content-Type: application/json" \ -d '{"url":"https://example.com/image.jpg"}' \ https://cdn.hackclub.com/api/v4/upload_from_url ``` -------------------------------- ### CDN Usage Response Source: https://cdn.hackclub.com/docs/quotas This JSON object represents the response from the CDN API when checking your storage usage. It includes used storage, the limit, and your current quota tier. ```json { "storage_used": 1048576000, "storage_limit": 53687091200, "quota_tier": "verified" } ``` -------------------------------- ### Over Quota Error Response Source: https://cdn.hackclub.com/docs/quotas Details on the API response when a user exceeds their storage quota. ```APIDOC ## Over Quota Response ### Description When a user exceeds their storage quota, the API returns a `402 Payment Required` status code with a JSON body containing error details and quota information. ### Response #### Error Response (402) - **error** (string) - A message indicating the error, e.g., "Storage quota exceeded". - **quota** (object) - An object containing details about the quota: - **storage_used** (integer) - The amount of storage currently used in bytes. - **storage_limit** (integer) - The total storage limit in bytes. - **quota_tier** (string) - The current quota tier. - **percentage_used** (float) - The percentage of the storage limit that has been used. ### Response Example ```json { "error": "Storage quota exceeded", "quota": { "storage_used": 52428800, "storage_limit": 52428800, "quota_tier": "unverified", "percentage_used": 100.0 } } ``` ``` -------------------------------- ### Embedding an Image with CDN URL Source: https://cdn.hackclub.com/docs/using-cdn-urls Use this HTML structure to embed images hosted on the Hack Club CDN. ```html ``` -------------------------------- ### Hack Club CDN URL Structure Source: https://cdn.hackclub.com/docs/using-cdn-urls The base URL structure for accessing files on the Hack Club CDN. ```text https://cdn.hackclub.com/{id}/{filename} ``` -------------------------------- ### API Error Response for Exceeded Quota Source: https://cdn.hackclub.com/docs/quotas When you exceed your storage quota, the API will return a 402 error with this JSON payload, detailing the error and your quota status. ```json { "error": "Storage quota exceeded", "quota": { "storage_used": 52428800, "storage_limit": 52428800, "quota_tier": "unverified", "percentage_used": 100.0 } } ``` -------------------------------- ### Delete Uploaded File via JavaScript Fetch API Source: https://cdn.hackclub.com/docs/api This JavaScript snippet demonstrates deleting an uploaded file using the Fetch API with a DELETE request. It requires the file ID and the Authorization header. ```javascript const response = await fetch('https://cdn.hackclub.com/api/v4/upload/01234567-89ab-cdef-0123-456789abcdef', { method: 'DELETE', headers: { 'Authorization': 'Bearer sk_cdn_your_key_here' } }); const result = await response.json(); ``` -------------------------------- ### Delete Upload Source: https://cdn.hackclub.com/docs/api Delete an uploaded file from the Hack Club CDN using its unique ID. Requires an API key for authentication. ```APIDOC ## DELETE /api/v4/upload/:id ### Description Delete an uploaded file by its ID. ### Method DELETE ### Endpoint https://cdn.hackclub.com/api/v4/upload/:id ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the file to delete. ### Request Example ```curl curl -X DELETE \ -H "Authorization: Bearer sk_cdn_your_key_here" \ https://cdn.hackclub.com/api/v4/upload/01234567-89ab-cdef-0123-456789abcdef ``` ```javascript const response = await fetch('https://cdn.hackclub.com/api/v4/upload/01234567-89ab-cdef-0123-456789abcdef', { method: 'DELETE', headers: { 'Authorization': 'Bearer sk_cdn_your_key_here' } }); const result = await response.json(); ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the deleted file. - **deleted** (boolean) - Indicates if the file was successfully deleted. #### Response Example ```json { "id": "01234567-89ab-cdef-0123-456789abcdef", "deleted": true } ``` **Note:** Returns 404 if the upload doesn't exist or doesn't belong to the authenticated user. ``` -------------------------------- ### Delete Uploaded File via cURL Source: https://cdn.hackclub.com/docs/api Delete an uploaded file by its ID using a cURL DELETE request. The request requires the file's ID and a valid Authorization header. ```curl curl -X DELETE \ -H "Authorization: Bearer sk_cdn_your_key_here" \ https://cdn.hackclub.com/api/v4/upload/01234567-89ab-cdef-0123-456789abcdef ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.