This document provides detailed reference documentation for the Google Code Search Data API.
This document is intended for programmers who want to write client applications that can interact with Code Search.
It's a reference document; it assumes that you understand the concepts presented in the developer's guide, and the general ideas behind the Google Data APIs protocol.
Use the following URL to retrieve Code Search feeds:
http://www.google.com/codesearch/feeds/search
Add the appropriate query parameters, as described in the following section.
The following query parameters are the only parameters recognized by the Code Search Data API:
| Parameter | Meaning | Notes |
|---|---|---|
q |
Regular expression query. | Similar to the standard Data API q query parameter, but the value you specify is interpreted as a set of POSIX extended regular expressions (separated by spaces) rather than plain text strings. Note that the query parameter is not case-sensitive. |
start-index |
1-based index of the first result to be retrieved. | start-index=n returns results starting after result number n. For example, to skip the first ten results, use &start-index=11. |
max-results |
Maximum number of results to be retrieved. | max-results=n returns no more than n results. For example, to get only 3 results, use &max-results=3. |
Note: The other standard Data API query parameters are not supported in Code Search.
The following table describes the elements in an entry in a Code Search feed, including both the standard Atom and Data API elements that have Code-Search-specific meanings and the Code-Search-specific extension elements.
| Element | Description |
|---|---|
atom:author/atom:name |
A fixed string that makes clear that the matching code is not owned by Google. (If the entry didn't contain an <author> element, then the feed's <author> element would apply to each entry, as described in the Atom specification.) |
atom:rights |
Indicates what license applies to the code, if any. |
atom:title |
Contains the full path to the file as it would be found in the version-control repository or archive. |
gcs:file |
Contains a name attribute specifying the name of the file within the version-control server or compressed archive. |
gcs:match |
Contains the search-results snippet (the code snippet containing the match). The type attribute indicates the format of the text; type="html" indicates that the snippet is in HTML, with angle brackets and ampersands URL-encoded. The matching text within the snippet is tagged with an HTML <b> tag. The lineNumber attribute indicates the line where the match happened. |
gcs:package |
Contains a name attribute and a uri attribute that together specify the location of the package: either a version-control server or a compressed archive. |
Note that all the codesearch elements are in the namespace http://schemas.google.com/codesearch/2006, abbreviated as gcs.
Code Search supports queries that contain regular expressions as defined by the POSIX extended regular expression syntax.