---
title: "YouTube Tìm Kiếm Chung API (V1)"
description: "Tìm kiếm video trên YouTube bằng từ khóa với tùy chọn ngôn ngữ, ngày tải lên, thời lượng và lọc sắp xếp, hoặc tiếp tục với token phân trang. Sử dụng để khám phá các video công cộng hoặc xem thêm các trang kết quả."
lastUpdated: false
aiUsagePrompt: true
---

# YouTube Tìm Kiếm Chung API \(V1\)

<ApiTester
  method="GET"
  :path='JSON.parse("\"/api/youtube/search/v1\"")'
  :summary='JSON.parse("\"Tìm Kiếm Chung (V1)\"")'
  openapiDefinitionUrl="https://docs.justoneapi.com/openapi/youtube/general-search-v1-vi.json"
  openapiVersion="3.1.0"
  :parameters='JSON.parse("[{\"name\":\"token\",\"in\":\"query\",\"description\":\"Token truy cập cho dịch vụ API này.\",\"required\":true,\"schema\":{\"type\":\"string\"}},{\"name\":\"keyword\",\"in\":\"query\",\"description\":\"Từ khóa tìm kiếm. Bắt buộc đối với trang đầu tiên; để trống khi sử dụng nextToken.\",\"required\":false,\"schema\":{\"type\":\"string\",\"default\":\"\"}},{\"name\":\"lang\",\"in\":\"query\",\"description\":\"Thẻ ngôn ngữ IETF tùy chọn để kết quả được hiển thị bằng ngôn ngữ địa phương, như en-US. Để trống để sử dụng ngôn ngữ mặc định.\",\"required\":false,\"schema\":{\"type\":\"string\"}},{\"name\":\"uploadDate\",\"in\":\"query\",\"description\":\"Tham số lọc ngày tải lên.\\n\\nCác giá trị có sẵn:\\n- `all`: Không có giới hạn về ngày tải lên\\n- `lastHour`: Được tải lên trong giờ qua\\n- `today`: Được tải lên hôm nay\\n- `thisWeek`: Được tải lên trong tuần này\\n- `thisMonth`: Được tải lên trong tháng này\\n- `thisYear`: Được tải lên trong năm này\",\"required\":false,\"schema\":{\"type\":\"string\",\"default\":\"all\",\"description\":\"Bộ lọc ngày đăng khi tìm kiếm trên YouTube\",\"enum\":[\"all\",\"lastHour\",\"today\",\"thisWeek\",\"thisMonth\",\"thisYear\"]}},{\"name\":\"duration\",\"in\":\"query\",\"description\":\"Tham số lọc độ dài video.\\n\\nCác giá trị có sẵn:\\n- `all`: Không có giới hạn về độ dài\\n- `short`: Video ngắn dưới 4 phút\\n- `medium`: Video trung bình từ 4 đến 20 phút\\n- `long`: Video dài hơn 20 phút\",\"required\":false,\"schema\":{\"type\":\"string\",\"default\":\"all\",\"description\":\"Bộ lọc thời lượng video khi tìm kiếm trên YouTube\",\"enum\":[\"all\",\"short\",\"medium\",\"long\"]}},{\"name\":\"sortBy\",\"in\":\"query\",\"description\":\"Thứ tự sắp xếp kết quả tìm kiếm.\\n\\nCác giá trị có sẵn:\\n- `relevance`: Sắp xếp theo mức độ liên quan\\n- `uploadDate`: Sắp xếp theo ngày tải lên\\n- `viewCount`: Sắp xếp theo số lượt xem\\n- `rating`: Sắp xếp theo điểm đánh giá\",\"required\":false,\"schema\":{\"type\":\"string\",\"default\":\"relevance\",\"description\":\"Thứ tự sắp xếp kết quả tìm kiếm YouTube\",\"enum\":[\"relevance\",\"uploadDate\",\"viewCount\",\"rating\"]}},{\"name\":\"nextToken\",\"in\":\"query\",\"description\":\"Token phân trang do phản hồi trước đó trả về. Khi truyền token, API bỏ qua các tham số từ khóa và bộ lọc. Token quá dài có thể vượt quá giới hạn URL của yêu cầu GET.\",\"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\":\"Kết quả tìm kiếm video YouTube và thông tin tiếp tục.\",\"properties\":{\"errorId\":{\"type\":\"string\",\"description\":\"Văn bản trạng thái tìm kiếm. Các tìm kiếm thành công trong các mẫu được xác thực báo cáo “Thành công”.\"},\"nextToken\":{\"type\":\"string\",\"description\":\"Chuyển giá trị này không thay đổi làm tham số truy vấn nextToken để tiếp tục. Chuỗi rỗng chỉ ra rằng không có kết quả tiếp tục được trả về.\"},\"items\":{\"type\":\"array\",\"description\":\"Video YouTube được trả về trên trang này. Danh sách có thể trống.\",\"items\":{\"type\":\"object\",\"description\":\"Kết quả tìm kiếm video YouTube.\",\"properties\":{\"type\":{\"type\":\"string\",\"description\":\"Loại kết quả tìm kiếm. Các kết quả được xác thực sử dụng từ “video”.\"},\"id\":{\"type\":\"string\",\"description\":\"Thanh toán video YouTube.\"},\"title\":{\"type\":\"string\",\"description\":\"Tiêu đề của video.\"},\"description\":{\"type\":\"string\",\"description\":\"Văn bản mô tả video được hiển thị trong kết quả tìm kiếm.\"},\"channel\":{\"type\":\"object\",\"description\":\"Kênh công cộng liên quan đến video này.\",\"properties\":{\"type\":{\"type\":\"string\",\"description\":\"Loại đối tượng kết quả liên quan. Các kết quả được xác thực sử dụng từ “kênh”.\"},\"id\":{\"type\":\"string\",\"description\":\"Thanh toán kênh YouTube.\"},\"name\":{\"type\":\"string\",\"description\":\"Tên hiển thị công khai của kênh.\"},\"isVerified\":{\"type\":\"boolean\",\"description\":\"Kênh có được đánh dấu là đã được xác thực hay không.\"},\"isVerifiedArtist\":{\"type\":\"boolean\",\"description\":\"Kênh có được đánh dấu là nghệ sĩ đã được xác thực hay không.\"},\"avatar\":{\"type\":\"array\",\"description\":\"Hình ảnh avatar của kênh.\",\"items\":{\"type\":\"object\",\"description\":\"Một hình ảnh avatar của kênh.\",\"properties\":{\"url\":{\"type\":\"string\",\"description\":\"URL của hình ảnh avatar kênh.\"},\"width\":{\"type\":\"integer\",\"description\":\"Chiều rộng của hình ảnh trong pixel.\"},\"height\":{\"type\":\"integer\",\"description\":\"Chiều cao của hình ảnh trong pixel.\"}}}}}},\"isLiveNow\":{\"type\":\"boolean\",\"description\":\"Video có được đánh dấu là đang phát trực tiếp hay không.\"},\"lengthText\":{\"type\":\"string\",\"description\":\"Thời lượng video như văn bản hiển thị.\"},\"viewCountText\":{\"type\":\"string\",\"description\":\"Số lượt xem được hiển thị dưới dạng văn bản.\"},\"publishedTimeText\":{\"type\":\"string\",\"description\":\"Thời gian xuất bản dưới dạng văn bản hiển thị.\"},\"thumbnails\":{\"type\":\"array\",\"description\":\"Thứ hạng hình ảnh được trả về cho video.\",\"items\":{\"type\":\"object\",\"description\":\"Một thứ hạng hình ảnh video.\",\"properties\":{\"url\":{\"type\":\"string\",\"description\":\"URL của hình nền video.\"},\"width\":{\"type\":\"integer\",\"description\":\"Chiều rộng của hình ảnh trong pixel.\"},\"height\":{\"type\":\"integer\",\"description\":\"Chiều cao của hình ảnh trong pixel.\"},\"moving\":{\"type\":\"boolean\",\"description\":\"Liệu hình nền có được đánh dấu là hình động hay không.\"}}}}}}}}}}},\"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\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"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\":\"Các tham số hoặc nội dung yêu cầu không hợp lệ.\",\"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\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"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\":\"Tài khoản truy cập không hợp lệ hoặc không hoạt động.\",\"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\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"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\":\"Quyền truy cập bị từ chối.\",\"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\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"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\":\"Tốc độ yêu cầu hoặc giới hạn hàng ngày đã vượt quá.\",\"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\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"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\":\"Lỗi máy chủ nội bộ.\",\"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\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"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\":\"Dịch vụ tạm thời không khả dụng.\",\"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\"},\"floatingPointNumber\":{\"type\":\"boolean\"},\"valueNode\":{\"type\":\"boolean\"},\"nodeType\":{\"type\":\"string\",\"enum\":[\"ARRAY\",\"BINARY\",\"BOOLEAN\",\"MISSING\",\"NULL\",\"NUMBER\",\"OBJECT\",\"POJO\",\"STRING\"]},\"string\":{\"type\":\"boolean\"},\"missingNode\":{\"type\":\"boolean\"},\"container\":{\"type\":\"boolean\"},\"pojo\":{\"type\":\"boolean\"},\"short\":{\"type\":\"boolean\"},\"int\":{\"type\":\"boolean\"},\"long\":{\"type\":\"boolean\"},\"double\":{\"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\":\"API sản xuất toàn cục (mặc định)\"}]")'
  :security='JSON.parse("[]")'
  :securitySchemes='JSON.parse("{}")'
  :schemas='JSON.parse("{}")'
/>

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

<p>Tìm kiếm video trên YouTube bằng từ khóa với tùy chọn ngôn ngữ, ngày tải lên, thời lượng và lọc sắp xếp, hoặc tiếp tục với token phân trang. Sử dụng để khám phá các video công cộng hoặc xem thêm các trang kết quả.</p>

## Tham số

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

| Tên | Vị trí | Kiểu dữ liệu | Bắt buộc | Mặc định | Mô tả |
| --- | --- | --- | --- | --- | --- |
| <code>token</code> | query | <code>string</code> | Đúng | - | Token truy cập cho dịch vụ API này. |
| <code>keyword</code> | query | <code>string</code> | Không | <code></code> | Từ khóa tìm kiếm. Bắt buộc đối với trang đầu tiên; để trống khi sử dụng nextToken. |
| <code>lang</code> | query | <code>string</code> | Không | - | Thẻ ngôn ngữ IETF tùy chọn để kết quả được hiển thị bằng ngôn ngữ địa phương, như en-US. Để trống để sử dụng ngôn ngữ mặc định. |
| <code>uploadDate</code> | query | <code>string</code> | Không | <code>all</code> | Tham số lọc ngày tải lên.<br /><br><br>Các giá trị có sẵn:<br /><br>- <code>all</code>: Không có giới hạn về ngày tải lên<br /><br>- <code>lastHour</code>: Được tải lên trong giờ qua<br /><br>- <code>today</code>: Được tải lên hôm nay<br /><br>- <code>thisWeek</code>: Được tải lên trong tuần này<br /><br>- <code>thisMonth</code>: Được tải lên trong tháng này<br /><br>- <code>thisYear</code>: Được tải lên trong năm này |
| <code>duration</code> | query | <code>string</code> | Không | <code>all</code> | Tham số lọc độ dài video.<br /><br><br>Các giá trị có sẵn:<br /><br>- <code>all</code>: Không có giới hạn về độ dài<br /><br>- <code>short</code>: Video ngắn dưới 4 phút<br /><br>- <code>medium</code>: Video trung bình từ 4 đến 20 phút<br /><br>- <code>long</code>: Video dài hơn 20 phút |
| <code>sortBy</code> | query | <code>string</code> | Không | <code>relevance</code> | Thứ tự sắp xếp kết quả tìm kiếm.<br /><br><br>Các giá trị có sẵn:<br /><br>- <code>relevance</code>: Sắp xếp theo mức độ liên quan<br /><br>- <code>uploadDate</code>: Sắp xếp theo ngày tải lên<br /><br>- <code>viewCount</code>: Sắp xếp theo số lượt xem<br /><br>- <code>rating</code>: Sắp xếp theo điểm đánh giá |
| <code>nextToken</code> | query | <code>string</code> | Không | - | Token phân trang do phản hồi trước đó trả về. Khi truyền token, API bỏ qua các tham số từ khóa và bộ lọc. Token quá dài có thể vượt quá giới hạn URL của yêu cầu GET. |

</div>

## Ví dụ mã hóa

::: code-group

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

```text [🤖 Lời hướng dẫn AI]
Tôi muốn sử dụng API "Tìm Kiếm Chung (V1)" từ JustOneAPI.
URL cơ sở: https://api.justoneapi.com.
Đường dẫn API: /api/youtube/search/v1?token=YOUR_API_KEY
Điểm cuối API: BASE_URL + /api/youtube/search/v1?token=YOUR_API_KEY
Phương thức HTTP: GET
Xác thực: Thêm tham số "token" vào URL.
Định nghĩa OpenAPI: https://docs.justoneapi.com/openapi/youtube/general-search-v1-vi.json

Tham số:
- token (query): Token truy cập cho dịch vụ API này. (Bắt buộc)
- keyword (query): Từ khóa tìm kiếm. Bắt buộc đối với trang đầu tiên; để trống khi sử dụng nextToken.
- lang (query): Thẻ ngôn ngữ IETF tùy chọn để kết quả được hiển thị bằng ngôn ngữ địa phương, như en-US. Để trống để sử dụng ngôn ngữ mặc định.
- uploadDate (query): Tham số lọc ngày tải lên.

Các giá trị có sẵn:
- `all`: Không có giới hạn về ngày tải lên
- `lastHour`: Được tải lên trong giờ qua
- `today`: Được tải lên hôm nay
- `thisWeek`: Được tải lên trong tuần này
- `thisMonth`: Được tải lên trong tháng này
- `thisYear`: Được tải lên trong năm này
- duration (query): Tham số lọc độ dài video.

Các giá trị có sẵn:
- `all`: Không có giới hạn về độ dài
- `short`: Video ngắn dưới 4 phút
- `medium`: Video trung bình từ 4 đến 20 phút
- `long`: Video dài hơn 20 phút
- sortBy (query): Thứ tự sắp xếp kết quả tìm kiếm.

Các giá trị có sẵn:
- `relevance`: Sắp xếp theo mức độ liên quan
- `uploadDate`: Sắp xếp theo ngày tải lên
- `viewCount`: Sắp xếp theo số lượt xem
- `rating`: Sắp xếp theo điểm đánh giá
- nextToken (query): Token phân trang do phản hồi trước đó trả về. Khi truyền token, API bỏ qua các tham số từ khóa và bộ lọc. Token quá dài có thể vượt quá giới hạn URL của yêu cầu GET.

Định dạng trả về: Xử lý an toàn phản hồi JSON hoặc văn bản dựa trên Content-Type thực tế.

Xử lý phản hồi và mã lỗi:
1. Đọc kết quả xử lý từ trường "code" trong nội dung phản hồi (mã 0 là thành công).
2. Thời gian chờ đề xuất: 120 giây. Nếu 120 giây quá dài, hãy dành ít nhất 60 giây. Một số yêu cầu có thể hết thời gian chờ trước khi có kết quả.
3. Mã kết quả:
   - 0: Thành công
   - 100: Token không hợp lệ hoặc đã bị vô hiệu hóa
   - 301: Không lấy được dữ liệu. Hãy thử lại.
   - 302: Vượt giới hạn tần suất gọi
   - 303: Vượt hạn mức trong ngày
   - 400: Tham số không hợp lệ
   - 500: Lỗi nội bộ máy chủ
   - 600: Không có quyền truy cập
   - 601: Không đủ số dư
   - 602: Đã chạm giới hạn ngân sách token
4. Mã 601 nghĩa là số dư dùng chung của tài khoản không đủ. Mã 602 nghĩa là token API đã chạm giới hạn ngân sách tích lũy riêng. Việc đặt ngân sách cho token không chuyển tiền khỏi số dư dùng chung.

Xin hãy giúp tôi viết một script bằng ngôn ngữ lập trình yêu thích để gọi API này và xử lý phản hồi.
```

```python [🐍 Python]
import requests

BASE_URL = "https://api.justoneapi.com"  # Được cung cấp bởi các server OpenAPI

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"; // Được cung cấp bởi các server OpenAPI
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"; // Được cung cấp bởi các server OpenAPI
        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" // Được cung cấp bởi các server OpenAPI

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'; // Được cung cấp bởi các server OpenAPI
$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-vi.json" target="_blank" style="font-size: 12px; color: var(--vp-c-text-3); text-decoration: none; opacity: 0.8;">[Định nghĩa OpenAPI (JSON)]</a>
</div>

## Các trường trong phản hồi

Các trường chính trong phản hồi thành công (`code = 0`).

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

| Đường dẫn trường | Kiểu dữ liệu | Mô tả |
| --- | --- | --- |
| <code>data</code> | <code>object</code> | Kết quả tìm kiếm video YouTube và thông tin tiếp tục. |
| <code>data.errorId</code> | <code>string</code> | Văn bản trạng thái tìm kiếm. Các tìm kiếm thành công trong các mẫu được xác thực báo cáo “Thành công”. |
| <code>data.nextToken</code> | <code>string</code> | Chuyển giá trị này không thay đổi làm tham số truy vấn nextToken để tiếp tục. Chuỗi rỗng chỉ ra rằng không có kết quả tiếp tục được trả về. |
| <code>data.items</code> | <code>array</code> | Video YouTube được trả về trên trang này. Danh sách có thể trống. |
| <code>data.items[]</code> | <code>object</code> | Kết quả tìm kiếm video YouTube. |
| <code>data.items[].type</code> | <code>string</code> | Loại kết quả tìm kiếm. Các kết quả được xác thực sử dụng từ “video”. |
| <code>data.items[].id</code> | <code>string</code> | Thanh toán video YouTube. |
| <code>data.items[].title</code> | <code>string</code> | Tiêu đề của video. |
| <code>data.items[].description</code> | <code>string</code> | Văn bản mô tả video được hiển thị trong kết quả tìm kiếm. |
| <code>data.items[].channel</code> | <code>object</code> | Kênh công cộng liên quan đến video này. |
| <code>data.items[].channel.type</code> | <code>string</code> | Loại đối tượng kết quả liên quan. Các kết quả được xác thực sử dụng từ “kênh”. |
| <code>data.items[].channel.id</code> | <code>string</code> | Thanh toán kênh YouTube. |
| <code>data.items[].channel.name</code> | <code>string</code> | Tên hiển thị công khai của kênh. |
| <code>data.items[].channel.isVerified</code> | <code>boolean</code> | Kênh có được đánh dấu là đã được xác thực hay không. |
| <code>data.items[].channel.isVerifiedArtist</code> | <code>boolean</code> | Kênh có được đánh dấu là nghệ sĩ đã được xác thực hay không. |
| <code>data.items[].channel.avatar</code> | <code>array</code> | Hình ảnh avatar của kênh. |
| <code>data.items[].channel.avatar[]</code> | <code>object</code> | Một hình ảnh avatar của kênh. |
| <code>data.items[].channel.avatar[].url</code> | <code>string</code> | URL của hình ảnh avatar kênh. |
| <code>data.items[].channel.avatar[].width</code> | <code>integer</code> | Chiều rộng của hình ảnh trong pixel. |
| <code>data.items[].channel.avatar[].height</code> | <code>integer</code> | Chiều cao của hình ảnh trong pixel. |
| <code>data.items[].isLiveNow</code> | <code>boolean</code> | Video có được đánh dấu là đang phát trực tiếp hay không. |
| <code>data.items[].lengthText</code> | <code>string</code> | Thời lượng video như văn bản hiển thị. |
| <code>data.items[].viewCountText</code> | <code>string</code> | Số lượt xem được hiển thị dưới dạng văn bản. |
| <code>data.items[].publishedTimeText</code> | <code>string</code> | Thời gian xuất bản dưới dạng văn bản hiển thị. |
| <code>data.items[].thumbnails</code> | <code>array</code> | Thứ hạng hình ảnh được trả về cho video. |
| <code>data.items[].thumbnails[]</code> | <code>object</code> | Một thứ hạng hình ảnh video. |
| <code>data.items[].thumbnails[].url</code> | <code>string</code> | URL của hình nền video. |
| <code>data.items[].thumbnails[].width</code> | <code>integer</code> | Chiều rộng của hình ảnh trong pixel. |
| <code>data.items[].thumbnails[].height</code> | <code>integer</code> | Chiều cao của hình ảnh trong pixel. |
| <code>data.items[].thumbnails[].moving</code> | <code>boolean</code> | Liệu hình nền có được đánh dấu là hình động hay không. |

</div>

## Ví dụ phản hồi

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

