### JavaScript Example for API Usage Source: https://pixabay.com/api/docs This JavaScript example demonstrates how to use jQuery to fetch video data from the Pixabay API and log the page URLs of the results. ```APIDOC ## JavaScript Example ### Description Example of using JavaScript with jQuery to query the Pixabay API for videos and process the response. ### Code ```javascript var API_KEY = 'YOUR_API_KEY'; var URL = "https://pixabay.com/api/?key="+API_KEY+"&q="+encodeURIComponent('red roses'); $.getJSON(URL, function(data){ if (parseInt(data.totalHits) > 0) $.each(data.hits, function(i, hit){ console.log(hit.pageURL); }); else console.log('No hits'); }); ``` ``` -------------------------------- ### Example Photo Search Response Structure Source: https://pixabay.com/api/docs This is an example of the JSON response structure when searching for photos. It includes total counts and a list of 'hits', where each hit represents a photo with its metadata. ```JSON { "total": 4692, "totalHits": 500, "hits": [ { "id": 195893, "pageURL": "https://pixabay.com/en/blossom-bloom-flower-195893/", "type": "photo", "tags": "blossom, bloom, flower", "previewURL": "https://cdn.pixabay.com/photo/2013/10/15/09/12/flower-195893_150.jpg", "previewWidth": 150, "previewHeight": 84, "webformatURL": "https://pixabay.com/get/35bbf209e13e39d2_640.jpg", "webformatWidth": 640, "webformatHeight": 360, "largeImageURL": "https://pixabay.com/get/ed6a99fd0a76647_1280.jpg", "fullHDURL": "https://pixabay.com/get/ed6a9369fd0a76647_1920.jpg", "imageURL": "https://pixabay.com/get/ed6a9364a9fd0a76647.jpg", "imageWidth": 4000, "imageHeight": 2250, "imageSize": 4731420, "views": 7671, "downloads": 6439, "likes": 5, "comments": 2, "user_id": 48777, "user": "Josch13", "userImageURL": "https://cdn.pixabay.com/user/2013/11/05/02-10-23-764_250x250.jpg" }, { "id": 73424, "...": "..." }, ... ] } ``` -------------------------------- ### JavaScript Example for Retrieving Images Source: https://pixabay.com/api/docs This JavaScript snippet demonstrates how to fetch image data using the Pixabay API and log the page URLs of the results. It requires jQuery and an API key. ```JavaScript var API_KEY = 'YOUR_API_KEY'; var URL = "https://pixabay.com/api/?key="+API_KEY+"&q="+encodeURIComponent('red roses'); $.getJSON(URL, function(data){ if (parseInt(data.totalHits) > 0) $.each(data.hits, function(i, hit){ console.log(hit.pageURL); }); else console.log('No hits'); }); ``` -------------------------------- ### GET /api/videos/ - Search Videos Source: https://pixabay.com/api/docs Searches for videos based on various criteria. Requires an API key. ```APIDOC ## GET /api/videos/ ### Description Searches for videos based on various criteria. Requires an API key. ### Method GET ### Endpoint https://pixabay.com/api/videos/ ### Parameters #### Query Parameters - **key** (string) - Required - Your Pixabay API key. - **q** (string) - Optional - A URL encoded search term (max 100 characters). If omitted, all videos are returned. - **lang** (string) - Optional - Language code for search results. Defaults to "en". - **id** (string) - Optional - Retrieve individual videos by ID. - **video_type** (string) - Optional - Filter by video type: "all", "film", "animation". Defaults to "all". - **category** (string) - Optional - Filter by category (e.g., "nature", "sports", "music"). - **min_width** (integer) - Optional - Minimum video width. Defaults to 0. - **min_height** (integer) - Optional - Minimum video height. Defaults to 0. - **editors_choice** (boolean) - Optional - Filter for Editor's Choice videos. Accepts "true" or "false". Defaults to "false". - **safesearch** (boolean) - Optional - Filter for safe search results. Accepts "true" or "false". Defaults to "false". - **order** (string) - Optional - Order of results: "popular" or "latest". Defaults to "popular". - **page** (integer) - Optional - Page number for paginated results. Defaults to 1. - **per_page** (integer) - Optional - Number of results per page. Accepted values: 3 to 200. Defaults to 20. - **callback** (string) - Optional - JSONP callback function name. - **pretty** (boolean) - Optional - Indent JSON output. Accepts "true" or "false". Defaults to "false". ### Request Example ``` https://pixabay.com/api/videos/?key={ KEY }&q=yellow+flower&min_width=640 ``` ### Response #### Success Response (200) (Response structure for videos is similar to photos, with video-specific fields like video URLs and dimensions.) #### Response Example (Example response structure for videos would be provided here, detailing fields like video URLs, duration, etc.) ``` -------------------------------- ### GET /api/ - Search Photos Source: https://pixabay.com/api/docs Retrieves photos based on search criteria. The 'q' parameter must be URL encoded. Replace '{ KEY }' with your actual API key. ```APIDOC ## GET /api/ ### Description Retrieves photos based on search criteria. The 'q' parameter must be URL encoded. Replace '{ KEY }' with your actual API key. ### Method GET ### Endpoint https://pixabay.com/api/ ### Parameters #### Query Parameters - **key** (string) - Required - Your Pixabay API key. - **q** (string) - Optional - URL encoded search term (e.g., "yellow+flowers"). - **image_type** (string) - Optional - Filter by image type (e.g., "photo", "illustration", "vector"). ### Request Example ``` https://pixabay.com/api/?key={ KEY }&q=yellow+flowers&image_type=photo ``` ### Response #### Success Response (200) - **total** (integer) - The total number of hits. - **totalHits** (integer) - The number of images accessible through the API (max 500 per query). - **hits** (array) - An array of image objects. - **id** (integer) - A unique identifier for this image. - **pageURL** (string) - Source page URL on Pixabay. - **type** (string) - Type of the asset (e.g., "photo"). - **tags** (string) - Comma-separated tags associated with the image. - **previewURL** (string) - URL for a low-resolution preview image. - **previewWidth** (integer) - Width of the preview image. - **previewHeight** (integer) - Height of the preview image. - **webformatURL** (string) - URL for a medium-sized image (640px width). - **webformatWidth** (integer) - Width of the medium-sized image. - **webformatHeight** (integer) - Height of the medium-sized image. - **largeImageURL** (string) - URL for a large-sized image (1280px width). - **fullHDURL** (string) - URL for a Full HD image (1920px width) (requires full API access). - **imageURL** (string) - URL for the original image (requires full API access). - **imageWidth** (integer) - Width of the original image. - **imageHeight** (integer) - Height of the original image. - **imageSize** (integer) - Size of the original image in bytes. - **views** (integer) - Total number of views. - **downloads** (integer) - Total number of downloads. - **likes** (integer) - Total number of likes. - **comments** (integer) - Total number of comments. - **user_id** (integer) - User ID of the contributor. - **user** (string) - Username of the contributor. - **userImageURL** (string) - URL for the user's profile picture. #### Response Example ```json { "total": 4692, "totalHits": 500, "hits": [ { "id": 195893, "pageURL": "https://pixabay.com/en/blossom-bloom-flower-195893/", "type": "photo", "tags": "blossom, bloom, flower", "previewURL": "https://cdn.pixabay.com/photo/2013/10/15/09/12/flower-195893_150.jpg", "previewWidth": 150, "previewHeight": 84, "webformatURL": "https://pixabay.com/get/35bbf209e13e39d2_640.jpg", "webformatWidth": 640, "webformatHeight": 360, "largeImageURL": "https://pixabay.com/get/ed6a99fd0a76647_1280.jpg", "fullHDURL": "https://pixabay.com/get/ed6a9369fd0a76647_1920.jpg", "imageURL": "https://pixabay.com/get/ed6a9364a9fd0a76647.jpg", "imageWidth": 4000, "imageHeight": 2250, "imageSize": 4731420, "views": 7671, "downloads": 6439, "likes": 5, "comments": 2, "user_id": 48777, "user": "Josch13", "userImageURL": "https://cdn.pixabay.com/user/2013/11/05/02-10-23-764_250x250.jpg" } ] } ``` ``` -------------------------------- ### Search Photos by Keyword Source: https://pixabay.com/api/docs Use this endpoint to retrieve photos based on a search query. Ensure the query parameter 'q' is URL encoded. Replace '{ KEY }' with your actual API key. ```HTTP https://pixabay.com/api/?key={ KEY }&q=yellow+flowers&image_type=photo ``` -------------------------------- ### Retrieve Videos API Source: https://pixabay.com/api/docs This endpoint allows you to search for videos based on a query. The search term 'q' must be URL encoded, and '{ KEY }' must be replaced with your actual API key. ```APIDOC ## GET /api/videos/ ### Description Retrieves videos based on a search query. ### Method GET ### Endpoint https://pixabay.com/api/videos/ ### Query Parameters - **key** (string) - Required - Your Pixabay API key. - **q** (string) - Required - The search term, URL encoded. ### Request Example ``` https://pixabay.com/api/videos/?key={ KEY }&q=yellow+flowers ``` ### Response #### Success Response (200) - **total** (integer) - The total number of hits. - **totalHits** (integer) - The number of videos accessible through the API (max 500). - **hits** (array) - An array of video objects. - **id** (integer) - A unique identifier for this video. - **pageURL** (string) - Source page on Pixabay. - **type** (string) - Type of media (e.g., "film"). - **tags** (string) - Comma-separated tags. - **duration** (integer) - Duration of the video in seconds. - **videos** (object) - A set of differently sized video streams. - **large** (object) - Large video rendition details. - **url** (string) - The video URL. - **width** (integer) - Width of the video. - **height** (integer) - Height of the video. - **size** (integer) - Approximate size in bytes. - **thumbnail** (string) - URL of the poster image. - **medium** (object) - Medium video rendition details. - **small** (object) - Small video rendition details. - **tiny** (object) - Tiny video rendition details. - **views** (integer) - Total number of views. - **downloads** (integer) - Total number of downloads. - **likes** (integer) - Total number of likes. - **comments** (integer) - Total number of comments. - **user_id** (integer) - User ID of the contributor. - **user** (string) - Username of the contributor. - **userImageURL** (string) - Profile picture URL. #### Response Example ```json { "total": 42, "totalHits": 42, "hits": [ { "id": 125, "pageURL": "https://pixabay.com/videos/id-125/", "type": "film", "tags": "flowers, yellow, blossom", "duration": 12, "videos": { "large": { "url": "https://cdn.pixabay.com/video/2015/08/08/125-135736646_large.mp4", "width": 1920, "height": 1080, "size": 6615235, "thumbnail": "https://cdn.pixabay.com/video/2015/08/08/125-135736646_large.jpg" }, "medium": { "url": "https://cdn.pixabay.com/video/2015/08/08/125-135736646_medium.mp4", "width": 1280, "height": 720, "size": 3562083, "thumbnail": "https://cdn.pixabay.com/video/2015/08/08/125-135736646_medium.jpg" }, "small": { "url": "https://cdn.pixabay.com/video/2015/08/08/125-135736646_small.mp4", "width": 640, "height": 360, "size": 1030736, "thumbnail": "https://cdn.pixabay.com/video/2015/08/08/125-135736646_small.jpg" }, "tiny": { "url": "https://cdn.pixabay.com/video/2015/08/08/125-135736646_tiny.mp4", "width": 480, "height": 270, "size": 426799, "thumbnail": "https://cdn.pixabay.com/video/2015/08/08/125-135736646_tiny.jpg" } }, "views": 4462, "downloads": 1464, "likes": 18, "comments": 0, "user_id": 1281706, "user": "Coverr-Free-Footage", "userImageURL": "https://cdn.pixabay.com/user/2015/10/16/09-28-45-303_250x250.png" } ] } ``` ``` -------------------------------- ### Retrieve Videos about 'yellow flowers' Source: https://pixabay.com/api/docs Use this endpoint to search for videos. Ensure the search term 'q' is URL encoded and replace '{ KEY }' with your actual API key. ```HTTP https://pixabay.com/api/videos/?key={ KEY }&q=yellow+flowers ``` -------------------------------- ### Search Videos Endpoint Source: https://pixabay.com/api/docs This is the base URL for searching videos. Various parameters can be appended to filter and customize the search results. ```HTTP https://pixabay.com/api/videos/ ``` -------------------------------- ### Search Images API Source: https://pixabay.com/api/docs Allows searching for royalty-free images based on various criteria. ```APIDOC ## GET /api/ ### Description Search for images using various parameters like keywords, category, orientation, and more. ### Method GET ### Endpoint https://pixabay.com/api/ ### Parameters #### Query Parameters - **key** (str) - Required - Please login to see your API key here. - **q** (str) - Optional - A URL encoded search term. Max 100 characters. Example: "yellow+flower" - **lang** (str) - Optional - Language code for search. Default: "en" - **id** (str) - Optional - Retrieve individual images by ID. - **image_type** (str) - Optional - Filter by image type. Accepted values: "all", "photo", "illustration", "vector". Default: "all" - **orientation** (str) - Optional - Filter by orientation. Accepted values: "all", "horizontal", "vertical". Default: "all" - **category** (str) - Optional - Filter by category. Accepted values: backgrounds, fashion, nature, science, education, feelings, health, people, religion, places, animals, industry, computer, food, sports, transportation, travel, buildings, business, music. - **min_width** (int) - Optional - Minimum image width. Default: 0 - **min_height** (int) - Optional - Minimum image height. Default: 0 - **colors** (str) - Optional - Filter by color properties. Comma separated list. Accepted values: "grayscale", "transparent", "red", "orange", "yellow", "green", "turquoise", "blue", "lilac", "pink", "white", "gray", "black", "brown". - **editors_choice** (bool) - Optional - Select Editor's Choice images. Accepted values: "true", "false". Default: "false" - **safesearch** (bool) - Optional - Filter for safe search. Accepted values: "true", "false". Default: "false" - **order** (str) - Optional - How results should be ordered. Accepted values: "popular", "latest". Default: "popular" - **page** (int) - Optional - Page number for pagination. Default: 1 - **per_page** (int) - Optional - Number of results per page. Accepted values: 3 - 200. Default: 20 - **callback** (string) - Optional - JSONP callback function name. - **pretty** (bool) - Optional - Indent JSON output. Should not be used in production. Accepted values: "true", "false". Default: "false" ### Request Example ```json { "example": "https://pixabay.com/api/?key=YOUR_API_KEY&q=yellow+flower&image_type=photo" } ``` ### Response #### Success Response (200) - **field1** (type) - Description (Note: Specific response fields are not detailed in the provided text, but the API returns JSON-encoded objects.) #### Response Example ```json { "example": "(JSON response with image data)" } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.