# /gitee/repos/search

`POST /api/gitee/repos/search`

Price: 5 credits

Search public Gitee repositories by text, with language, licence and sort filters

## How to use it

Returns at most 200 repositories per query, so narrow with `language` or `license` or a more specific `query` to reach the long tail. `language` matches any language the repository contains, not only its main one. Pass the returned `alias` to gitee/repos for the full record.

## Parameters

- `access-token` (string, required)

## Request body

- `timeout` (integer) — Max scrapping execution timeout (in seconds) (default: 300; min: 20; max: 1500)
- `query` (string, required) — Search text (examples: "spring boot", "数据库", "hutool"; minLength: 1)
- `sort` (string) — Result order (default: "relevance"; one of: "relevance", "stars", "last_push")
- `language` (string, nullable) — Programming language the repository uses (one of: "ABAP", "ActionScript", "Ada", "Android", "AngelScript", "ANTLR", "Apex", "Arduino", "ASL", "ASP.NET", "AspectJ", "Assembly", "Astro", "AutoHotkey", "AutoIt", "Awk", "Batchfile", "BibTeX", "Bicep", "Blade", "C", "c-cpp", "C++", "C#", "Clojure", "CMake", "COBOL", "CodeQL", "CoffeeScript", "Common Lisp", "Common Workflow Language", "Coq", "cpp", "Crystal", "csharp", "CSS", "Cuda", "Cython", "D", "Dart", "Delphi", "Docker", "Dockerfile", "EJS", "Elixir", "Emacs Lisp", "EmberScript", "epl", "Erlang", "F#", "fish", "Fluent", "Forth", "FORTRAN", "Fortran", "Fortran Free Form", "FreeMarker", "GAP", "GDScript", "Gherkin", "Gleam", "GLSL", "Go", "Groovy", "Hack", "Haml", "Handlebars", "Haskell", "HCL", "HiveQL", "HLSL", "HTML", "Html", "HTML+EEX", "HTML+ERB", "HTML+PHP", "HTML+Razor", "IDL", "Inno Setup", "Isabelle", "Isabelle ROOT", "Java", "Java Server Pages", "JavaScript", "JCL", "Jinja", "Jsonnet", "Julia", "Jupyter Notebook", "Just", "Kotlin", "Less", "Lex", "Lisp", "Literate Haskell", "LLVM", "Logtalk", "Lua", "M", "M4", "M4Sugar", "Makefile", "MATLAB", "Matlab", "MDX", "Meson", "Motorola 68K Assembly", "Mustache", "NewLisp", "Nim", "Nix", "NodeJS", "NSIS", "Objective-C", "Objective-C++", "OCaml", "OpenCL", "Other", "others", "Pascal", "PDDL", "Perl", "PHP", "PLpgSQL", "PLSQL", "PostScript", "POV-Ray SDL", "PowerShell", "Processing", "Prolog", "Pug", "Puppet", "Python", "q", "QMake", "QML", "R", "Racket", "Ragel", "Raku", "Reason", "Rich Text Format", "Roff", "Roff Manpage", "Ruby", "Rust", "SAS", "Sass", "Scala", "Scheme", "SCSS", "ShaderLab", "Shell", "Slim", "Smalltalk", "Smarty", "Solidity", "sql", "SQLPL", "Standard ML", "Starlark", "Stata", "Stylus", "Svelte", "Swift", "SWIG", "SystemVerilog", "Tcl", "TeX", "tex-latex", "Thrift", "TSQL", "TSX", "Twig", "TXL", "TypeScript", "Typst", "Unix Assembly", "V", "Vala", "Verilog", "VHDL", "Vim Script", "Vim script", "Vim Snippet", "VimL", "Visual Basic", "Visual Basic .NET", "Vue", "WebAssembly", "weixin", "Wren", "XSLT", "Xtend", "Yacc", "YASnippet", "Zig"; examples: "Java", "Go", "Python")
- `license` (string, nullable) — Repository licence (one of: "AFL-3.0", "AGPL-3.0", "Apache-2.0", "Artistic-2.0", "BSD-2-Clause", "BSD-3-Clause", "BSD-3-Clause-Clear", "BSD-4-Clause", "BSL-1.0", "CC0-1.0", "CC-BY-4.0", "CC-BY-SA-4.0", "EPL-1.0", "EPL-2.0", "EUPL-1.1", "EUPL-1.2", "GFDL-1.3", "GPL-2.0", "GPL-3.0", "ISC", "LGPL-2.1", "LGPL-3.0", "LPPL-1.3c", "MIT", "MIT-0", "MPL-2.0", "MS-PL", "MulanPSL-1.0", "MulanPSL-2.0", "MulanPubL-1.0", "MulanPubL-2.0", "NCSA", "OFL-1.1", "OSL-3.0", "PostgreSQL", "Unlicense", "0BSD", "Vim", "WTFPL", "Zlib"; examples: "MIT", "Apache-2.0")
- `count` (integer, required) — Max number of results (min: 1; max: 200)

## Response

### 200 — Successful Response

- `@type` (string) (default: "GiteeRepoSearchResult")
- `id` (integer, required)
- `alias` (string, required)
- `path` (string, nullable)
- `display_name` (string, nullable)
- `description` (string, nullable)
- `license` (string, nullable)
- `languages` (array) (default: [])
- `star_count` (integer, nullable)
- `fork_count` (integer, nullable)
- `is_fork` (boolean, nullable)
- `recommend_level` (integer, nullable)
- `relevance_score` (number, nullable)
- `url` (string, nullable)
- `pushed_at` (integer, nullable)

## Errors

### 422 — Validation Error

The request body did not validate

What to do: Check the fields against this schema. A URN with the wrong prefix is the most common cause.

- `detail` (array)
  - `loc` (array, required)
  - `msg` (string, required)
  - `type` (string, required)
  - `input` (any)
  - `ctx` (object)

### 408

The request ran past its time limit

What to do: Raise `timeout` in the request body, up to the maximum this endpoint documents. Lowering `count` or turning off the `with_*` flags also helps, because less work finishes sooner.

### 412

The entity was not found, or a precondition failed

What to do: Retrying will not help: either the entity does not exist, or the input points at a different one.

### 429

Too many requests: a rate limit or a usage window is exhausted

What to do: When the response carries an X-Retry-After header, wait that many seconds and retry: the same number is in the body as `detail.retry_after`, and the limit clears once that window passes. The message in the body names the limit that was hit.

### 500

Something broke on our side

What to do: Retrying will not help. If it keeps happening, send us the X-Request-ID from the response headers.

### 529

Rate limit reached, or the endpoint is overloaded

What to do: Wait at least 30 seconds, then retry.

## Response envelope

Success: Array of objects (may be empty if no results)

Error: Error may coexist with partial results if it occurs mid-execution. Check X-Error header and status code.

Every response carries these headers:

- `X-Error` — Error message text (present only on error)
- `X-Request-ID` — Unique request identifier
- `X-Execution-Time` — Execution time in seconds
- `X-Result-Count` — How many records the body carries. 0 means an empty result, which is a normal answer and not by itself an error. A non-zero count can come back together with X-Error when the failure happened partway through — read this header and X-Error independently.
- `X-Total-Available-Results` — How many records exist for this query, when the endpoint can say. On a `dry_run` request this is the answer and the body is empty. It saturates: the endpoint's documented maximum means 'at least that many', any smaller number is exact.
- `X-Warning` — Present when the request body carried keys this endpoint does not document. They were ignored, so any filter you meant to apply through them did not apply. Check the spelling against this schema and retry.
- `X-Retry-After` — Seconds to wait before retrying. Present only on 429.

