### Generate Database Quickstart Guide Source: https://docs.bunny.net/cli/commands/db Generate a quickstart guide for connecting to a database. You can generate a general guide or specify a database ID and preferred language. ```bash bunny db quickstart ``` ```bash bunny db quickstart --lang bun ``` -------------------------------- ### Install libsql-client-go Source: https://docs.bunny.net/database/connect/go Install the libSQL client package for Go using the go get command. ```bash go get github.com/tursodatabase/libsql-client-go/libsql ``` -------------------------------- ### Install Dependencies and Run Locally Source: https://docs.bunny.net/magic-containers/guides/node-express-api Commands to install project dependencies using npm and start the development server. ```bash npm install npm run dev ``` -------------------------------- ### Quickstart Vimeo2Bunny CLI Commands Source: https://docs.bunny.net/stream/vimeo2bunny Run the initial configuration and start a migration using npx. ```bash npx vimeo2bunny config npx vimeo2bunny migrate ``` -------------------------------- ### Install Dependencies and Run Locally Source: https://docs.bunny.net/magic-containers/guides/python-fastapi Commands to install project dependencies using pip and start the FastAPI development server with automatic reloading. ```bash pip install -r requirements.txt uvicorn main:app --reload ``` -------------------------------- ### Install libSQL Client with bun Source: https://docs.bunny.net/database/connect/typescript Install the libSQL client package using bun. ```bash bun add @libsql/client ``` -------------------------------- ### Install libSQL Client with yarn Source: https://docs.bunny.net/database/connect/typescript Install the libSQL client package using yarn. ```bash yarn add @libsql/client ``` -------------------------------- ### Install Vimeo2Bunny CLI from Source Source: https://docs.bunny.net/stream/vimeo2bunny Clone the repository, install dependencies, build the project, and link it globally to use the CLI. ```bash git clone https://github.com/BunnyWay/vimeo2bunny.git cd vimeo2bunny npm install npm run build npm link # makes `vimeo2bunny` available globally ``` -------------------------------- ### Install libSQL Client with pnpm Source: https://docs.bunny.net/database/connect/typescript Install the libSQL client package using pnpm. ```bash pnpm add @libsql/client ``` -------------------------------- ### Install LibSQL Client Package (.NET) Source: https://docs.bunny.net/database/quickstart Install the LibSQL client package for .NET using the dotnet CLI. ```bash dotnet add package Libsql.Client ``` -------------------------------- ### Terraform Apply Output Example Source: https://docs.bunny.net/integrations/terraform/quickstart Example output after successfully applying Terraform configuration, indicating resources have been created. ```text bunnynet_storage_zone.my_storage: Creating... bunnynet_storage_zone.my_storage: Creation complete after 3s bunnynet_pullzone.my_cdn: Creating... bunnynet_pullzone.my_cdn: Creation complete after 0s bunnynet_storage_file.index: Creating... bunnynet_storage_file.index: Creation complete after 0s Apply complete! Resources: 3 added, 0 changed, 0 destroyed. ``` -------------------------------- ### Authentication Example Source: https://docs.bunny.net/api-reference/storage/index This example demonstrates how to authenticate your requests using the AccessKey header with your storage zone password. ```APIDOC ## Authentication Example ### Description Authenticate using the `AccessKey` header with your storage zone password. ### Method GET ### Endpoint `https://{region}.storage.bunny.com/{storageZoneName}/` ### Headers - **AccessKey** (string) - Required - Your storage zone password. ### Request Example ```bash curl --request GET \ --url https://storage.bunnycdn.com/{storageZoneName}/ \ --header 'AccessKey: YOUR_STORAGE_ZONE_PASSWORD' ``` Use your storage zone password, not your account API key. Find it in the **FTP & API Access** tab of your storage zone. ``` -------------------------------- ### Install Bunny Storage TypeScript SDK Source: https://docs.bunny.net/storage/typescript-sdk Install the SDK using npm. This is the first step before using any of the SDK functionalities. ```bash npm install @bunny.net/storage-sdk ``` -------------------------------- ### Install Vimeo2Bunny CLI with npx Source: https://docs.bunny.net/stream/vimeo2bunny Use npx for zero installation. Prefix any command with `npx` to run the tool. ```bash npx vimeo2bunny ``` -------------------------------- ### Initialize Slim Project with Composer Source: https://docs.bunny.net/magic-containers/guides/php-slim Create a new directory and install Slim Framework and PSR-7 dependencies using Composer. ```bash mkdir app-slim-api cd app-slim-api composer require slim/slim slim/psr7 ``` -------------------------------- ### Example API Request with Authentication Source: https://docs.bunny.net/api-reference/authentication This example demonstrates how to make an authenticated GET request to the /dnszone endpoint using curl. It shows the required 'AccessKey' header. ```APIDOC ## GET /dnszone ### Description Fetches DNS zone information. This is an example endpoint to demonstrate authentication. ### Method GET ### Endpoint https://api.bunny.net/dnszone ### Parameters #### Headers - **AccessKey** (string) - Required - Your API key for authentication. ### Request Example ```bash curl --request GET \ --url https://api.bunny.net/dnszone \ --header 'AccessKey: YOUR_API_KEY' ``` ### Response #### Success Response (200) (Response structure not detailed in the source text) #### Response Example (Response example not detailed in the source text) ``` -------------------------------- ### Authenticate GET Request with API Key Source: https://docs.bunny.net/api-reference/authentication This example demonstrates how to authenticate a GET request to the DNS zone API using curl. Ensure you replace 'YOUR_API_KEY' with your actual API key. ```bash curl --request GET \ --url https://api.bunny.net/dnszone \ --header 'AccessKey: YOUR_API_KEY' ``` -------------------------------- ### Connect with .NET Client Library Source: https://docs.bunny.net/database/connect/authorization Example of creating a database client in .NET using Libsql.Client. Configure the URL and AuthToken options. ```csharp using Libsql.Client; var client = DatabaseClient.Create(opts => { opts.Url = "libsql://[your-database-id].lite.bunnydb.net"; opts.AuthToken = "your-access-token"; }); ``` -------------------------------- ### Crop, Resize, and Optimize Image Source: https://docs.bunny.net/optimizer/dynamic-images/quality This example demonstrates a comprehensive optimization pipeline, including cropping, resizing, and applying quality compression. ```bash https://yourzone.b-cdn.net/image.jpg?crop=600,400&width=300&quality=80 ``` -------------------------------- ### Authenticate Stream API Request Source: https://docs.bunny.net/api-reference/stream/index Example of authenticating a GET request to list videos using the AccessKey header. ```bash curl --request GET \ --url https://video.bunnycdn.com/library/{libraryId}/videos \ --header 'AccessKey: YOUR_STREAM_API_KEY' ``` -------------------------------- ### Install Bunny.LibSQL.Client via NuGet Source: https://docs.bunny.net/database/connect/dotnet Use this command to add the necessary client library to your .NET project. ```bash dotnet add package Bunny.LibSql.Client ``` -------------------------------- ### Get Shield Zone Detailed Metrics Overview Source: https://docs.bunny.net/api-reference/shield/metrics/get-a-detailed-metrics-overview-for-the-specified-shield-zone-within-the-selected-time-range-and-resolution Fetches detailed metrics for a given Shield Zone. You can specify start and end dates, and the desired resolution for the data. ```APIDOC ## GET /shield/metrics/overview/{shieldZoneId}/detailed ### Description Retrieves a detailed metrics overview for the specified Shield Zone within the selected time range and resolution. ### Method GET ### Endpoint /shield/metrics/overview/{shieldZoneId}/detailed ### Parameters #### Path Parameters - **shieldZoneId** (integer) - Required - The ID of the Shield Zone. #### Query Parameters - **StartDate** (string) - Optional - The start date and time for the metrics range (ISO 8601 format). - **EndDate** (string) - Optional - The end date and time for the metrics range (ISO 8601 format). - **Resolution** (integer) - Optional - The desired resolution for the metrics data. Possible values: 0 (Auto), 1 (TwoMinutes), 2 (TenMinutes), 3 (Hourly), 4 (Daily), 5 (Weekly), 6 (Monthly). ### Responses #### Success Response (200) - **data** (object) - Contains the detailed metrics for WAF, DDoS, Rate Limiting, Access Lists, Bot Detection, Upload Scanning, API Guardian, total clean requests, total billable requests this month, and resolution. - **error** (object) - Contains error details if the request was not successful. #### Error Response (401) - **statusCode** (integer) - Indicates an unauthorized access attempt. ``` -------------------------------- ### Get DNS Query Statistics Source: https://docs.bunny.net/api-reference/core/dns-zone/get-dns-query-statistics Fetches the statistics for DNS queries for a specified DNS zone ID. You can optionally provide start and end dates to filter the statistics. ```APIDOC ## GET /dnszone/{id}/statistics ### Description Retrieves statistics for DNS queries made to a specific DNS zone. ### Method GET ### Endpoint /dnszone/{id}/statistics ### Parameters #### Path Parameters - **id** (integer) - Required - The ID of the DNS Zone for which the statistics will be returned #### Query Parameters - **dateFrom** (string) - Optional - The start date of the statistics. If no value is passed, the last 30 days will be returned - **dateTo** (string) - Optional - The end date of the statistics. If no value is passed, the last 30 days will be returned ### Responses #### Success Response (200) - **TotalQueriesServed** (integer) - Total number of DNS queries served. - **QueriesServedChart** (object) - A chart object representing the total queries served over time. - **NormalQueriesServedChart** (object) - A chart object representing normal queries served over time. - **SmartQueriesServedChart** (object) - A chart object representing smart queries served over time. - **QueriesByTypeChart** (object) - A chart object representing queries categorized by type. #### Error Responses - **401** - The request authorization failed - **404** - The DNS Zone with the requested ID does not exist - **500** - Internal Server Error ``` -------------------------------- ### Initialize libSQL Client Source: https://docs.bunny.net/database/connect/typescript Create a client instance using your database URL and authentication token, typically stored as environment variables. ```typescript import { createClient } from "@libsql/client/web"; const client = createClient({ url: process.env.BUNNY_DATABASE_URL, authToken: process.env.BUNNY_DATABASE_AUTH_TOKEN, }); ``` -------------------------------- ### Direct Play URL with Seek Time Source: https://docs.bunny.net/stream/embedding Use the 't' query parameter to start video playback at a specific time. This example shows how to begin playback at 30 seconds. ```bash https://player.mediadelivery.net/play/{video_library_id}/{video_id}?t=30s ``` -------------------------------- ### Start HTTP Server with Basic Response Source: https://docs.bunny.net/scripting/standalone/overview This snippet demonstrates how to start an HTTP server using the `serve` function and return a simple 'Hello from the edge!' response to all incoming requests. ```typescript import * as BunnySDK from "@bunny.net/edgescript-sdk"; BunnySDK.net.http.serve(async (request: Request) => { return new Response("Hello from the edge!"); }); ``` -------------------------------- ### Get Origin Shield Queue Statistics Source: https://docs.bunny.net/api-reference/core/statistics/get-origin-shield-queue-statistics Fetches the Origin Shield queue statistics for a specified pull zone. You can optionally provide start and end dates, and specify if you want hourly data. ```APIDOC ## GET /pullzone/{pullZoneId}/originshield/queuestatistics ### Description Retrieves statistics for the Origin Shield queue for a given pull zone. This includes data on concurrent and queued requests. ### Method GET ### Endpoint /pullzone/{pullZoneId}/originshield/queuestatistics ### Parameters #### Path Parameters - **pullZoneId** (integer) - Required - The ID of the Pull Zone for which to retrieve statistics. #### Query Parameters - **dateFrom** (string) - Optional - The start date for the statistics. If not provided, the last 30 days are returned. Format: date-time. - **dateTo** (string) - Optional - The end date for the statistics. If not provided, the last 30 days are returned. Format: date-time. - **hourly** (boolean) - Optional - If true, statistics data will be returned in hourly groupings. Defaults to false. ### Responses #### Success Response (200) - **ConcurrentRequestsChart** (object) - The constructed chart of origin shield concurrent requests. Additional properties are integers representing counts. - **QueuedRequestsChart** (object) - The constructed chart of origin shield requests. Additional properties are integers representing counts. #### Error Responses - **401** - The request authorization failed. - **500** - Internal Server Error. ``` -------------------------------- ### Authentication Example Source: https://docs.bunny.net/api-reference/core/index Demonstrates how to authenticate with the Core Platform API using an AccessKey header. ```APIDOC ## Authentication Example ### Description Authenticate using the `AccessKey` header with your account API key. ### Method GET ### Endpoint https://api.bunny.net/pullzone ### Headers - **AccessKey** (string) - Required - Your account API key ### Request Example ```bash curl --request GET \ --url https://api.bunny.net/pullzone \ --header 'AccessKey: YOUR_API_KEY' ``` ### Response #### Success Response (200) Details about pull zones. ``` -------------------------------- ### Quick Start: Modify H1 Content Source: https://docs.bunny.net/scripting/html-rewriter A basic middleware example demonstrating how to use HTMLRewriter to change the content of all H1 elements in a response. This snippet registers a handler for 'h1' tags and sets their inner content to 'Modified Title'. ```javascript import * as BunnySDK from "https://esm.sh/@bunny.net/edgescript-sdk@0.11.2"; BunnySDK.net.http.servePullZone() .onOriginResponse(async ({ response }) => { return new HTMLRewriter() .on("h1", { element(el) { el.setInnerContent("Modified Title"); }, }) .transform(response); }); ``` -------------------------------- ### Connect with Go Client Library Source: https://docs.bunny.net/database/connect/authorization Example of opening a database connection in Go using the libsql-client-go library. The auth token is appended to the URL. ```go import _ "github.com/tursodatabase/libsql-client-go/libsql" url := "libsql://[your-database-id].lite.bunnydb.net?authToken=your-access-token" db, err := sql.Open("libsql", url) ``` -------------------------------- ### Get SafeHop Statistics Source: https://docs.bunny.net/api-reference/core/statistics/get-safehop-statistics Fetches SafeHop statistics for a specified pull zone. You can optionally provide a start date (`dateFrom`), an end date (`dateTo`), and a boolean flag (`hourly`) to group the results by hour. If date parameters are omitted, statistics for the last 30 days are returned. ```APIDOC ## GET /pullzone/{pullZoneId}/safehop/statistics ### Description Retrieves SafeHop statistics for a specified pull zone. This includes data on retried and saved requests. The results can be filtered by date and grouped hourly. ### Method GET ### Endpoint /pullzone/{pullZoneId}/safehop/statistics ### Parameters #### Path Parameters - **pullZoneId** (integer) - Required - The ID of the Pull Zone for which to retrieve statistics. #### Query Parameters - **dateFrom** (string) - Optional - The start date for the statistics. If not provided, the last 30 days will be used. Format: date-time. - **dateTo** (string) - Optional - The end date for the statistics. If not provided, the last 30 days will be used. Format: date-time. - **hourly** (boolean) - Optional - If true, statistics data will be returned in hourly grouping. Defaults to false. ### Responses #### Success Response (200) - **RequestsRetriedChart** (object) - The constructed chart of requests retried. Additional properties are integers representing counts. - **RequestsSavedChart** (object) - The constructed chart of requests saved. Additional properties are integers representing counts. - **TotalRequestsRetried** (number) - The total number of retried requests. - **TotalRequestsSaved** (number) - The total number of saved requests. #### Error Response (401) - Description: The request authorization failed. #### Error Response (500) - Description: Internal Server Error. ``` -------------------------------- ### Verify Bunny CLI Installation Source: https://docs.bunny.net/cli/installation Run this command after installation to confirm that the Bunny CLI is installed correctly and accessible in your PATH. ```bash bunny ``` -------------------------------- ### Install Bunny CLI with npm Source: https://docs.bunny.net/cli/installation Install the Bunny CLI globally using npm if you have Node.js installed. This is a convenient option for existing Node.js users. ```bash npm install -g @bunny.net/cli ``` -------------------------------- ### Install Content Replacer Plugin via Composer Source: https://docs.bunny.net/cdn/integrations/cms/typo3 Use this Composer command to install the 'Content Replacer' plugin if your Typo3 installation is managed with Composer. ```bash composer req jweiland/replacer ``` -------------------------------- ### Initialize Database Context and Apply Migrations Source: https://docs.bunny.net/database/connect/dotnet Instantiate your database context using environment variables for credentials and then apply any pending database migrations asynchronously. ```csharp var db = new AppDb( Environment.GetEnvironmentVariable("BUNNY_DATABASE_URL"), Environment.GetEnvironmentVariable("BUNNY_DATABASE_AUTH_TOKEN") ); await db.ApplyMigrationsAsync(); ``` -------------------------------- ### Get log-forwarding configuration Source: https://docs.bunny.net/llms.txt Get a specific log-forwarding configuration by ID. ```APIDOC ## Get log-forwarding configuration ### Description Get a specific log-forwarding configuration by ID. ### Method GET ### Endpoint /log-forwarding/get-log-forwarding-configuration ``` -------------------------------- ### Basic Player Initialization and Event Handling Source: https://docs.bunny.net/stream/playback-api Initialize a player object and set up event listeners for 'ready', 'play', and 'mute' actions. This example demonstrates basic interaction with the player. ```javascript const player = new playerjs.Player("iframe"); player.on("ready", () => { player.on("play", () => { console.log("play"); }); player.getDuration((duration) => console.log(duration)); if (player.supports("method", "mute")) { player.mute(); } player.play(); }); ``` -------------------------------- ### Authenticate and Fetch Apps Source: https://docs.bunny.net/api-reference/magic-containers/overview Demonstrates how to authenticate using the AccessKey header and fetch a list of your Magic Containers applications. ```bash curl --request GET \ --url https://api.bunny.net/mc/apps \ --header 'AccessKey: YOUR_API_KEY' ``` -------------------------------- ### Example Configuration for Redirect Source: https://docs.bunny.net/cdn/edge-rules/redirect-hostname An example configuration for a pull zone named 'mycdn' with a custom hostname 'cdn.example.com', demonstrating the Redirect To URL action, status code, and Request URL condition. ```text Action: Redirect To URL Redirect URL: https://cdn.example.com{{path}} Status Code: 301 Condition Type: Request URL Condition Value: *://mycdn.b-cdn.net/* ``` -------------------------------- ### Authentication Example Source: https://docs.bunny.net/storage/api-reference Example of how to authenticate requests to the Bunny.net Storage API using the AccessKey header. ```APIDOC ## Authentication Example ### Description This example demonstrates how to authenticate your requests to the Bunny.net Storage API using your storage zone password. ### Method GET ### Endpoint `https://{region}.storage.bunnycdn.com/{storageZoneName}/` ### Headers - **AccessKey** (string) - Required - Your storage zone password. ### Request Example ```bash curl --request GET \ --url https://storage.bunnycdn.com/{storageZoneName}/ \ --header 'AccessKey: YOUR_STORAGE_ZONE_PASSWORD' ``` ### Note Use your storage zone password, not your account API key. This can be found in the **FTP & API Access** tab of your storage zone. ```