---
title: "YouTube General Search API (V1)"
description: "Search YouTube videos by keyword with optional language, upload-date, duration, and sort filters, or continue with a pagination token. Use it to discover public videos or browse additional result pages."
aiUsagePrompt: true
---

# YouTube General Search API \(V1\)

<ApiTester
  method="GET"
  :path='JSON.parse("\"/api/youtube/search/v1\"")'
  :summary='JSON.parse("\"General Search (V1)\"")'
  openapiDefinitionUrl="https://docs.justoneapi.com/openapi/youtube/general-search-v1-en.json"
  openapiVersion="3.1.0"
  :parameters='JSON.parse("[{\"name\":\"token\",\"in\":\"query\",\"description\":\"Access token for this API service.\",\"required\":true,\"schema\":{\"type\":\"string\"}},{\"name\":\"keyword\",\"in\":\"query\",\"description\":\"Search term. Required for the first page; leave empty when using nextToken.\",\"required\":false,\"schema\":{\"type\":\"string\",\"default\":\"\"}},{\"name\":\"lang\",\"in\":\"query\",\"description\":\"Optional IETF language tag for localized results, such as en-US. Leave empty to use the default language.\",\"required\":false,\"schema\":{\"type\":\"string\"}},{\"name\":\"uploadDate\",\"in\":\"query\",\"description\":\"Upload-date filter.\\n\\nAvailable Values:\\n- `all`: No upload-date limit\\n- `lastHour`: Uploaded within the last hour\\n- `today`: Uploaded today\\n- `thisWeek`: Uploaded this week\\n- `thisMonth`: Uploaded this month\\n- `thisYear`: Uploaded this year\",\"required\":false,\"schema\":{\"type\":\"string\",\"default\":\"all\",\"description\":\"YouTube search upload date filter\",\"enum\":[\"all\",\"lastHour\",\"today\",\"thisWeek\",\"thisMonth\",\"thisYear\"]}},{\"name\":\"duration\",\"in\":\"query\",\"description\":\"Video-duration filter.\\n\\nAvailable Values:\\n- `all`: No duration limit\\n- `short`: Short videos under 4 minutes\\n- `medium`: Medium videos from 4 to 20 minutes\\n- `long`: Long videos over 20 minutes\",\"required\":false,\"schema\":{\"type\":\"string\",\"default\":\"all\",\"description\":\"YouTube search video duration filter\",\"enum\":[\"all\",\"short\",\"medium\",\"long\"]}},{\"name\":\"sortBy\",\"in\":\"query\",\"description\":\"Sort order for search results.\\n\\nAvailable Values:\\n- `relevance`: Sort by relevance\\n- `uploadDate`: Sort by upload date\\n- `viewCount`: Sort by view count\\n- `rating`: Sort by rating\",\"required\":false,\"schema\":{\"type\":\"string\",\"default\":\"relevance\",\"description\":\"YouTube search sort order\",\"enum\":[\"relevance\",\"uploadDate\",\"viewCount\",\"rating\"]}},{\"name\":\"nextToken\",\"in\":\"query\",\"description\":\"Pagination token returned by the previous response. When provided, the keyword and filter parameters are ignored; very long tokens may exceed GET URL limits.\",\"required\":false,\"schema\":{\"type\":\"string\"}}]")'
  :requestBody='JSON.parse("null")'
  :responses='JSON.parse("{\"200\":{\"description\":\"OK\",\"content\":{\"application/json\":{\"schema\":{\"if\":{\"properties\":{\"code\":{\"const\":0}},\"required\":[\"code\"]},\"then\":{\"properties\":{\"data\":{\"type\":\"object\",\"description\":\"YouTube video search results and continuation information.\",\"properties\":{\"errorId\":{\"type\":\"string\",\"description\":\"Search status text. Successful searches in the verified samples report Success.\"},\"nextToken\":{\"type\":\"string\",\"description\":\"Pass this value unchanged as the nextToken query parameter to continue. An empty string indicates that no continuation was returned.\"},\"items\":{\"type\":\"array\",\"description\":\"YouTube videos returned on this page. The list can be empty.\",\"items\":{\"type\":\"object\",\"description\":\"A YouTube video search result.\",\"properties\":{\"type\":{\"type\":\"string\",\"description\":\"Type of the search result. The verified results use video.\"},\"id\":{\"type\":\"string\",\"description\":\"YouTube video identifier.\"},\"title\":{\"type\":\"string\",\"description\":\"Title of the video.\"},\"description\":{\"type\":\"string\",\"description\":\"Video description text shown in the search result.\"},\"channel\":{\"type\":\"object\",\"description\":\"Public channel associated with this video.\",\"properties\":{\"type\":{\"type\":\"string\",\"description\":\"Type of the associated result entity. The verified results use channel.\"},\"id\":{\"type\":\"string\",\"description\":\"YouTube channel identifier.\"},\"name\":{\"type\":\"string\",\"description\":\"Public display name of the channel.\"},\"isVerified\":{\"type\":\"boolean\",\"description\":\"Whether the channel is marked as verified.\"},\"isVerifiedArtist\":{\"type\":\"boolean\",\"description\":\"Whether the channel is marked as a verified artist.\"},\"avatar\":{\"type\":\"array\",\"description\":\"Avatar images for the channel.\",\"items\":{\"type\":\"object\",\"description\":\"One channel avatar image.\",\"properties\":{\"url\":{\"type\":\"string\",\"description\":\"URL of the channel avatar image.\"},\"width\":{\"type\":\"integer\",\"description\":\"Image width in pixels.\"},\"height\":{\"type\":\"integer\",\"description\":\"Image height in pixels.\"}}}}}},\"isLiveNow\":{\"type\":\"boolean\",\"description\":\"Whether the video is marked as currently live.\"},\"lengthText\":{\"type\":\"string\",\"description\":\"Video duration as display text.\"},\"viewCountText\":{\"type\":\"string\",\"description\":\"View count as display text.\"},\"publishedTimeText\":{\"type\":\"string\",\"description\":\"Publication time as display text.\"},\"thumbnails\":{\"type\":\"array\",\"description\":\"Thumbnails returned for the video.\",\"items\":{\"type\":\"object\",\"description\":\"One video thumbnail.\",\"properties\":{\"url\":{\"type\":\"string\",\"description\":\"URL of the video thumbnail image.\"},\"width\":{\"type\":\"integer\",\"description\":\"Image width in pixels.\"},\"height\":{\"type\":\"integer\",\"description\":\"Image height in pixels.\"},\"moving\":{\"type\":\"boolean\",\"description\":\"Whether the thumbnail is marked as animated.\"}}}}}}}}}}},\"allOf\":[{\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"integer\",\"format\":\"int32\",\"enum\":[0,100,101,202,300,301,302,303,400,404,500,503,600,601,602]},\"message\":{\"type\":[\"string\",\"null\"]},\"data\":{},\"recordTime\":{\"type\":[\"string\",\"null\"]},\"requestId\":{\"type\":\"string\"},\"reason\":{\"type\":\"string\"},\"requestParams\":{\"type\":\"object\",\"properties\":{\"query\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"object\"}},\"body\":{\"type\":\"object\",\"properties\":{\"empty\":{\"type\":\"boolean\"},\"array\":{\"type\":\"boolean\"},\"null\":{\"type\":\"boolean\"},\"object\":{\"type\":\"boolean\"},\"float\":{\"type\":\"boolean\"},\"integralNumber\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"bigDecimal\":{\"type\":\"boolean\"},\"bigInteger\":{\"type\":\"boolean\"},\"textual\":{\"type\":\"boolean\",\"deprecated\":true},\"boolean\":{\"type\":\"boolean\"},\"binary\":{\"type\":\"boolean\"},\"number\":{\"type\":\"boolean\"},\"embeddedValue\":{\"type\":\"boolean\"}}}}}},\"required\":[\"code\",\"data\",\"message\",\"recordTime\"]}]}}}},\"400\":{\"description\":\"Invalid request parameters or body\",\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"integer\",\"format\":\"int32\",\"enum\":[0,100,101,202,300,301,302,303,400,404,500,503,600,601,602]},\"message\":{\"type\":[\"string\",\"null\"]},\"data\":{},\"recordTime\":{\"type\":[\"string\",\"null\"]},\"requestId\":{\"type\":\"string\"},\"reason\":{\"type\":\"string\"},\"requestParams\":{\"type\":\"object\",\"properties\":{\"query\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"object\"}},\"body\":{\"type\":\"object\",\"properties\":{\"empty\":{\"type\":\"boolean\"},\"array\":{\"type\":\"boolean\"},\"null\":{\"type\":\"boolean\"},\"object\":{\"type\":\"boolean\"},\"float\":{\"type\":\"boolean\"},\"integralNumber\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"bigDecimal\":{\"type\":\"boolean\"},\"bigInteger\":{\"type\":\"boolean\"},\"textual\":{\"type\":\"boolean\",\"deprecated\":true},\"boolean\":{\"type\":\"boolean\"},\"binary\":{\"type\":\"boolean\"},\"number\":{\"type\":\"boolean\"},\"embeddedValue\":{\"type\":\"boolean\"}}}}}},\"required\":[\"code\",\"data\",\"message\",\"recordTime\"]}}}},\"401\":{\"description\":\"Invalid or inactive access token\",\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"integer\",\"format\":\"int32\",\"enum\":[0,100,101,202,300,301,302,303,400,404,500,503,600,601,602]},\"message\":{\"type\":[\"string\",\"null\"]},\"data\":{},\"recordTime\":{\"type\":[\"string\",\"null\"]},\"requestId\":{\"type\":\"string\"},\"reason\":{\"type\":\"string\"},\"requestParams\":{\"type\":\"object\",\"properties\":{\"query\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"object\"}},\"body\":{\"type\":\"object\",\"properties\":{\"empty\":{\"type\":\"boolean\"},\"array\":{\"type\":\"boolean\"},\"null\":{\"type\":\"boolean\"},\"object\":{\"type\":\"boolean\"},\"float\":{\"type\":\"boolean\"},\"integralNumber\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"bigDecimal\":{\"type\":\"boolean\"},\"bigInteger\":{\"type\":\"boolean\"},\"textual\":{\"type\":\"boolean\",\"deprecated\":true},\"boolean\":{\"type\":\"boolean\"},\"binary\":{\"type\":\"boolean\"},\"number\":{\"type\":\"boolean\"},\"embeddedValue\":{\"type\":\"boolean\"}}}}}},\"required\":[\"code\",\"data\",\"message\",\"recordTime\"]}}}},\"403\":{\"description\":\"Permission denied\",\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"integer\",\"format\":\"int32\",\"enum\":[0,100,101,202,300,301,302,303,400,404,500,503,600,601,602]},\"message\":{\"type\":[\"string\",\"null\"]},\"data\":{},\"recordTime\":{\"type\":[\"string\",\"null\"]},\"requestId\":{\"type\":\"string\"},\"reason\":{\"type\":\"string\"},\"requestParams\":{\"type\":\"object\",\"properties\":{\"query\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"object\"}},\"body\":{\"type\":\"object\",\"properties\":{\"empty\":{\"type\":\"boolean\"},\"array\":{\"type\":\"boolean\"},\"null\":{\"type\":\"boolean\"},\"object\":{\"type\":\"boolean\"},\"float\":{\"type\":\"boolean\"},\"integralNumber\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"bigDecimal\":{\"type\":\"boolean\"},\"bigInteger\":{\"type\":\"boolean\"},\"textual\":{\"type\":\"boolean\",\"deprecated\":true},\"boolean\":{\"type\":\"boolean\"},\"binary\":{\"type\":\"boolean\"},\"number\":{\"type\":\"boolean\"},\"embeddedValue\":{\"type\":\"boolean\"}}}}}},\"required\":[\"code\",\"data\",\"message\",\"recordTime\"]}}}},\"429\":{\"description\":\"Request rate or daily quota limit exceeded\",\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"integer\",\"format\":\"int32\",\"enum\":[0,100,101,202,300,301,302,303,400,404,500,503,600,601,602]},\"message\":{\"type\":[\"string\",\"null\"]},\"data\":{},\"recordTime\":{\"type\":[\"string\",\"null\"]},\"requestId\":{\"type\":\"string\"},\"reason\":{\"type\":\"string\"},\"requestParams\":{\"type\":\"object\",\"properties\":{\"query\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"object\"}},\"body\":{\"type\":\"object\",\"properties\":{\"empty\":{\"type\":\"boolean\"},\"array\":{\"type\":\"boolean\"},\"null\":{\"type\":\"boolean\"},\"object\":{\"type\":\"boolean\"},\"float\":{\"type\":\"boolean\"},\"integralNumber\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"bigDecimal\":{\"type\":\"boolean\"},\"bigInteger\":{\"type\":\"boolean\"},\"textual\":{\"type\":\"boolean\",\"deprecated\":true},\"boolean\":{\"type\":\"boolean\"},\"binary\":{\"type\":\"boolean\"},\"number\":{\"type\":\"boolean\"},\"embeddedValue\":{\"type\":\"boolean\"}}}}}},\"required\":[\"code\",\"data\",\"message\",\"recordTime\"]}}}},\"500\":{\"description\":\"Internal server error\",\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"integer\",\"format\":\"int32\",\"enum\":[0,100,101,202,300,301,302,303,400,404,500,503,600,601,602]},\"message\":{\"type\":[\"string\",\"null\"]},\"data\":{},\"recordTime\":{\"type\":[\"string\",\"null\"]},\"requestId\":{\"type\":\"string\"},\"reason\":{\"type\":\"string\"},\"requestParams\":{\"type\":\"object\",\"properties\":{\"query\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"object\"}},\"body\":{\"type\":\"object\",\"properties\":{\"empty\":{\"type\":\"boolean\"},\"array\":{\"type\":\"boolean\"},\"null\":{\"type\":\"boolean\"},\"object\":{\"type\":\"boolean\"},\"float\":{\"type\":\"boolean\"},\"integralNumber\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"bigDecimal\":{\"type\":\"boolean\"},\"bigInteger\":{\"type\":\"boolean\"},\"textual\":{\"type\":\"boolean\",\"deprecated\":true},\"boolean\":{\"type\":\"boolean\"},\"binary\":{\"type\":\"boolean\"},\"number\":{\"type\":\"boolean\"},\"embeddedValue\":{\"type\":\"boolean\"}}}}}},\"required\":[\"code\",\"data\",\"message\",\"recordTime\"]}}}},\"503\":{\"description\":\"Service temporarily unavailable\",\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"integer\",\"format\":\"int32\",\"enum\":[0,100,101,202,300,301,302,303,400,404,500,503,600,601,602]},\"message\":{\"type\":[\"string\",\"null\"]},\"data\":{},\"recordTime\":{\"type\":[\"string\",\"null\"]},\"requestId\":{\"type\":\"string\"},\"reason\":{\"type\":\"string\"},\"requestParams\":{\"type\":\"object\",\"properties\":{\"query\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"object\"}},\"body\":{\"type\":\"object\",\"properties\":{\"empty\":{\"type\":\"boolean\"},\"array\":{\"type\":\"boolean\"},\"null\":{\"type\":\"boolean\"},\"object\":{\"type\":\"boolean\"},\"float\":{\"type\":\"boolean\"},\"integralNumber\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"bigDecimal\":{\"type\":\"boolean\"},\"bigInteger\":{\"type\":\"boolean\"},\"textual\":{\"type\":\"boolean\",\"deprecated\":true},\"boolean\":{\"type\":\"boolean\"},\"binary\":{\"type\":\"boolean\"},\"number\":{\"type\":\"boolean\"},\"embeddedValue\":{\"type\":\"boolean\"}}}}}},\"required\":[\"code\",\"data\",\"message\",\"recordTime\"]}}}}}")'
  :servers='JSON.parse("[{\"url\":\"https://api.justoneapi.com\",\"description\":\"Global production API (default)\"}]")'
  :security='JSON.parse("[]")'
  :securitySchemes='JSON.parse("{}")'
  :schemas='JSON.parse("{}")'
/>

<ApiHealthSection :api='JSON.parse("\"/api/youtube/search/v1\"")' />

<p>Search YouTube videos by keyword with optional language, upload-date, duration, and sort filters, or continue with a pagination token. Use it to discover public videos or browse additional result pages.</p>

## Parameters

<div class="api-doc-table api-doc-table--params">

| Name | In | Type | Required | Default | Description |
| --- | --- | --- | --- | --- | --- |
| <code>token</code> | query | <code>string</code> | Yes | - | Access token for this API service. |
| <code>keyword</code> | query | <code>string</code> | No | <code></code> | Search term. Required for the first page; leave empty when using nextToken. |
| <code>lang</code> | query | <code>string</code> | No | - | Optional IETF language tag for localized results, such as en-US. Leave empty to use the default language. |
| <code>uploadDate</code> | query | <code>string</code> | No | <code>all</code> | Upload-date filter.<br /><br><br>Available Values:<br /><br>- <code>all</code>: No upload-date limit<br /><br>- <code>lastHour</code>: Uploaded within the last hour<br /><br>- <code>today</code>: Uploaded today<br /><br>- <code>thisWeek</code>: Uploaded this week<br /><br>- <code>thisMonth</code>: Uploaded this month<br /><br>- <code>thisYear</code>: Uploaded this year |
| <code>duration</code> | query | <code>string</code> | No | <code>all</code> | Video-duration filter.<br /><br><br>Available Values:<br /><br>- <code>all</code>: No duration limit<br /><br>- <code>short</code>: Short videos under 4 minutes<br /><br>- <code>medium</code>: Medium videos from 4 to 20 minutes<br /><br>- <code>long</code>: Long videos over 20 minutes |
| <code>sortBy</code> | query | <code>string</code> | No | <code>relevance</code> | Sort order for search results.<br /><br><br>Available Values:<br /><br>- <code>relevance</code>: Sort by relevance<br /><br>- <code>uploadDate</code>: Sort by upload date<br /><br>- <code>viewCount</code>: Sort by view count<br /><br>- <code>rating</code>: Sort by rating |
| <code>nextToken</code> | query | <code>string</code> | No | - | Pagination token returned by the previous response. When provided, the keyword and filter parameters are ignored; very long tokens may exceed GET URL limits. |

</div>

## Code Samples

::: code-group

```bash [🐚 cURL]
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/youtube/search/v1?token=YOUR_API_KEY'
```

```text [🤖 AI Prompt]
I want to use the "General Search (V1)" API from JustOneAPI.
Base URL: https://api.justoneapi.com.
API Path: /api/youtube/search/v1?token=YOUR_API_KEY
API Endpoint: BASE_URL + /api/youtube/search/v1?token=YOUR_API_KEY
HTTP Method: GET
Authentication: Append the "token" query parameter to the URL.
OpenAPI Definition: https://docs.justoneapi.com/openapi/youtube/general-search-v1-en.json

Parameters:
- token (query): Access token for this API service. (Required)
- keyword (query): Search term. Required for the first page; leave empty when using nextToken.
- lang (query): Optional IETF language tag for localized results, such as en-US. Leave empty to use the default language.
- uploadDate (query): Upload-date filter.

Available Values:
- `all`: No upload-date limit
- `lastHour`: Uploaded within the last hour
- `today`: Uploaded today
- `thisWeek`: Uploaded this week
- `thisMonth`: Uploaded this month
- `thisYear`: Uploaded this year
- duration (query): Video-duration filter.

Available Values:
- `all`: No duration limit
- `short`: Short videos under 4 minutes
- `medium`: Medium videos from 4 to 20 minutes
- `long`: Long videos over 20 minutes
- sortBy (query): Sort order for search results.

Available Values:
- `relevance`: Sort by relevance
- `uploadDate`: Sort by upload date
- `viewCount`: Sort by view count
- `rating`: Sort by rating
- nextToken (query): Pagination token returned by the previous response. When provided, the keyword and filter parameters are ignored; very long tokens may exceed GET URL limits.

Return format: safely handle JSON or text according to the actual Content-Type.

Response Handling & Error Codes:
1. Business results should be determined by the "code" field in the response body (code 0 means success).
2. Timeout Recommendation: Set the request timeout to 120 seconds. If 120 seconds is too long for your use case, use at least 60 seconds, but a small number of requests may time out before receiving a result.
3. Business Code Reference:
   - 0: Success
   - 100: Invalid or Inactive Token
   - 301: Collection Failed. Please Retry.
   - 302: Rate Limit Exceeded
   - 303: Daily Quota Exceeded
   - 400: Invalid Parameters
   - 500: Internal Server Error
   - 600: Permission Denied
   - 601: Insufficient Balance
   - 602: Token Budget Exceeded
4. Code 601 means the shared account balance is insufficient. Code 602 means the current API token's own cumulative budget limit has been reached. Token budget limits do not transfer funds out of the shared account balance.

Please help me write a script in my preferred programming language to call this API and handle the response.
```

```python [🐍 Python]
import requests

BASE_URL = "https://api.justoneapi.com"  # Provided by OpenAPI servers

url = BASE_URL + "/api/youtube/search/v1?token=YOUR_API_KEY"
response = requests.get(url, timeout=120)
print(response.status_code)
if response.content:
    content_type = response.headers.get("content-type", "").lower()
    if "json" in content_type:
        try:
            print(response.json())
        except ValueError:
            print(response.text)
    elif content_type.startswith("text/") or "xml" in content_type or content_type.split(";", 1)[0].strip() in {"application/javascript", "application/x-www-form-urlencoded", "application/graphql"}:
        print(response.text)
    else:
        with open("response.bin", "wb") as output:
            output.write(response.content)
        print(f"Saved {len(response.content)} bytes to response.bin")
```

```js [🌐 JavaScript]
const BASE_URL = "https://api.justoneapi.com"; // Provided by OpenAPI servers
const url = BASE_URL + "/api/youtube/search/v1?token=YOUR_API_KEY";

const response = await fetch(url, {
  method: "GET",
  signal: AbortSignal.timeout(120000)
});
console.log(response.status);
const responseBytes = await response.arrayBuffer();
if (responseBytes.byteLength) {
  const contentType = (response.headers.get("content-type") || "").toLowerCase();
  const mediaType = contentType.split(";", 1)[0].trim();
  const textual = contentType.startsWith("text/") || contentType.includes("json") || contentType.includes("xml") || ["application/javascript", "application/x-www-form-urlencoded", "application/graphql"].includes(mediaType);
  if (textual) {
    const responseText = new TextDecoder().decode(responseBytes);
    let data = responseText;
    if (contentType.includes("json")) {
      try { data = JSON.parse(responseText); } catch { /* Keep the raw body. */ }
    }
    console.log(data);
  } else {
    console.log(`Received ${responseBytes.byteLength} binary bytes`);
  }
}
```

```java [☕ Java]
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;

public class Main {
    public static void main(String[] args) throws Exception {
        final String BASE_URL = "https://api.justoneapi.com"; // Provided by OpenAPI servers
        final String url = BASE_URL + "/api/youtube/search/v1?token=YOUR_API_KEY";

        HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(120)).build();
        HttpRequest.Builder builder = HttpRequest.newBuilder()
            .uri(URI.create(url))
            .timeout(Duration.ofSeconds(120))
            .method("GET", HttpRequest.BodyPublishers.noBody());

        HttpRequest request = builder.build();

        HttpResponse<byte[]> response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
        System.out.println(response.statusCode());
        String contentType = response.headers().firstValue("content-type").orElse("").toLowerCase();
        String mediaType = contentType.split(";", 2)[0].trim();
        if (contentType.startsWith("text/") || contentType.contains("json") || contentType.contains("xml") || mediaType.equals("application/javascript") || mediaType.equals("application/x-www-form-urlencoded") || mediaType.equals("application/graphql")) {
            System.out.println(new String(response.body(), StandardCharsets.UTF_8));
        } else {
            Files.write(Path.of("response.bin"), response.body());
            System.out.println("Saved " + response.body().length + " bytes to response.bin");
        }
    }
}
```

```go [🐹 Go]
package main

import (
	"fmt"
	"io"
	"os"
	"strings"
	"net/http"
	"time"
)

const BASE_URL = "https://api.justoneapi.com" // Provided by OpenAPI servers

func main() {
	client := &http.Client{Timeout: 120 * time.Second}
	url := BASE_URL + "/api/youtube/search/v1?token=YOUR_API_KEY"
	req, _ := http.NewRequest("GET", url, nil)
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	fmt.Println(resp.StatusCode)
	bodyBytes, _ := io.ReadAll(resp.Body)
	contentType := strings.ToLower(resp.Header.Get("Content-Type"))
	mediaType := strings.TrimSpace(strings.SplitN(contentType, ";", 2)[0])
	if strings.HasPrefix(contentType, "text/") || strings.Contains(contentType, "json") || strings.Contains(contentType, "xml") || mediaType == "application/javascript" || mediaType == "application/x-www-form-urlencoded" || mediaType == "application/graphql" {
		fmt.Println(string(bodyBytes))
	} else {
		os.WriteFile("response.bin", bodyBytes, 0600)
		fmt.Printf("Saved %d bytes to response.bin\n", len(bodyBytes))
	}
}
```

```php [🐘 PHP]
<?php
$BASE_URL = 'https://api.justoneapi.com'; // Provided by OpenAPI servers
$url = $BASE_URL . '/api/youtube/search/v1?token=YOUR_API_KEY';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$contentType = strtolower((string) curl_getinfo($ch, CURLINFO_CONTENT_TYPE));
curl_close($ch);
echo $status . PHP_EOL;
$mediaType = trim(explode(';', $contentType, 2)[0]);
if (str_starts_with($contentType, 'text/') || str_contains($contentType, 'json') || str_contains($contentType, 'xml') || in_array($mediaType, ['application/javascript', 'application/x-www-form-urlencoded', 'application/graphql'], true)) {
    echo $response;
} else {
    file_put_contents('response.bin', $response);
    echo 'Saved ' . strlen($response) . ' bytes to response.bin' . PHP_EOL;
}
```

:::

<div style="text-align: right; margin-top: -20px; margin-bottom: 20px;">
<a href="/openapi/youtube/general-search-v1-en.json" target="_blank" style="font-size: 12px; color: var(--vp-c-text-3); text-decoration: none; opacity: 0.8;">[OpenAPI Definition (JSON)]</a>
</div>

## Response Fields

Key fields in a successful response (`code = 0`).

<div class="api-doc-table api-doc-table--response">

| Field path | Type | Description |
| --- | --- | --- |
| <code>data</code> | <code>object</code> | YouTube video search results and continuation information. |
| <code>data.errorId</code> | <code>string</code> | Search status text. Successful searches in the verified samples report Success. |
| <code>data.nextToken</code> | <code>string</code> | Pass this value unchanged as the nextToken query parameter to continue. An empty string indicates that no continuation was returned. |
| <code>data.items</code> | <code>array</code> | YouTube videos returned on this page. The list can be empty. |
| <code>data.items[]</code> | <code>object</code> | A YouTube video search result. |
| <code>data.items[].type</code> | <code>string</code> | Type of the search result. The verified results use video. |
| <code>data.items[].id</code> | <code>string</code> | YouTube video identifier. |
| <code>data.items[].title</code> | <code>string</code> | Title of the video. |
| <code>data.items[].description</code> | <code>string</code> | Video description text shown in the search result. |
| <code>data.items[].channel</code> | <code>object</code> | Public channel associated with this video. |
| <code>data.items[].channel.type</code> | <code>string</code> | Type of the associated result entity. The verified results use channel. |
| <code>data.items[].channel.id</code> | <code>string</code> | YouTube channel identifier. |
| <code>data.items[].channel.name</code> | <code>string</code> | Public display name of the channel. |
| <code>data.items[].channel.isVerified</code> | <code>boolean</code> | Whether the channel is marked as verified. |
| <code>data.items[].channel.isVerifiedArtist</code> | <code>boolean</code> | Whether the channel is marked as a verified artist. |
| <code>data.items[].channel.avatar</code> | <code>array</code> | Avatar images for the channel. |
| <code>data.items[].channel.avatar[]</code> | <code>object</code> | One channel avatar image. |
| <code>data.items[].channel.avatar[].url</code> | <code>string</code> | URL of the channel avatar image. |
| <code>data.items[].channel.avatar[].width</code> | <code>integer</code> | Image width in pixels. |
| <code>data.items[].channel.avatar[].height</code> | <code>integer</code> | Image height in pixels. |
| <code>data.items[].isLiveNow</code> | <code>boolean</code> | Whether the video is marked as currently live. |
| <code>data.items[].lengthText</code> | <code>string</code> | Video duration as display text. |
| <code>data.items[].viewCountText</code> | <code>string</code> | View count as display text. |
| <code>data.items[].publishedTimeText</code> | <code>string</code> | Publication time as display text. |
| <code>data.items[].thumbnails</code> | <code>array</code> | Thumbnails returned for the video. |
| <code>data.items[].thumbnails[]</code> | <code>object</code> | One video thumbnail. |
| <code>data.items[].thumbnails[].url</code> | <code>string</code> | URL of the video thumbnail image. |
| <code>data.items[].thumbnails[].width</code> | <code>integer</code> | Image width in pixels. |
| <code>data.items[].thumbnails[].height</code> | <code>integer</code> | Image height in pixels. |
| <code>data.items[].thumbnails[].moving</code> | <code>boolean</code> | Whether the thumbnail is marked as animated. |

</div>

## Response Example

<ApiExampleSection :api='JSON.parse("\"/api/youtube/search/v1\"")' />

