{"id":22821826,"url":"https://github.com/rly0nheart/searchcode-sdk","last_synced_at":"2025-04-11T11:32:46.651Z","repository":{"id":63905324,"uuid":"569473200","full_name":"rly0nheart/searchcode-sdk","owner":"rly0nheart","description":"An unofficial Python SDK for Searchcode.","archived":false,"fork":false,"pushed_at":"2024-11-20T17:40:13.000Z","size":165,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-20T18:27:29.275Z","etag":null,"topics":["codesearch","searchcode"],"latest_commit_sha":null,"homepage":"https://searchcode.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rly0nheart.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"buy_me_a_coffee":"rly0nheart"}},"created_at":"2022-11-22T22:51:26.000Z","updated_at":"2024-11-20T17:39:12.000Z","dependencies_parsed_at":"2023-11-23T12:29:21.106Z","dependency_job_id":"10526fff-ed9f-415c-9568-bee9463a9482","html_url":"https://github.com/rly0nheart/searchcode-sdk","commit_stats":{"total_commits":51,"total_committers":1,"mean_commits":51.0,"dds":0.0,"last_synced_commit":"16f5e54c2f68924e9d1193decb87ee3e929b275d"},"previous_names":["rly0nheart/searchcode-sdk"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rly0nheart%2Fsearchcode-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rly0nheart%2Fsearchcode-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rly0nheart%2Fsearchcode-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rly0nheart%2Fsearchcode-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rly0nheart","download_url":"https://codeload.github.com/rly0nheart/searchcode-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248384148,"owners_count":21094678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codesearch","searchcode"],"created_at":"2024-12-12T16:05:16.028Z","updated_at":"2025-04-11T11:32:46.642Z","avatar_url":"https://github.com/rly0nheart.png","language":"Python","funding_links":["https://buymeacoffee.com/rly0nheart"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"https://github.com/user-attachments/assets/d28934e1-a1ab-4b6e-9d12-d64067a65a60\"\u003e\u003cbr\u003ePython SDK for \u003ca href=\"https://searchcode.com\"\u003eSearchcode\u003c/a\u003e.\u003cbr\u003e\u003ci\u003eSearch 75 billion lines of code from 40 million projects\u003c/i\u003e\u003c/p\u003e\r\n\u003cp align=\"center\"\u003e\u003c/p\u003e\r\n\r\n## Installation\r\n\r\n```bash\r\n\r\npip install searchcode\r\n\r\n```\r\n\r\n## Documentation\r\n\r\n### Code Search\r\n\r\nQueries the code index and returns at most 100 results.\r\n\r\n#### Params\r\n\r\n- `query`: Search term (required).\r\n    - The following filters are textual and can be added into query directly\r\n        - Filter by file extention **ext:EXTENTION** e.g., _\"gsub ext:erb\"_\r\n        - Filter by language **lang:LANGUAGE** e.g., _\"import lang:python\"_\r\n        - Filter by repository **repo:REPONAME** e.g., _\"float Q_rsqrt repo:quake\"_\r\n        - Filter by user/repository **repo:USERNAME/REPONAME** e.g., _\"batf repo:boyter/batf\"_\r\n- `page`: Result page starting at 0 through to 49\r\n- `per_page`: Number of results wanted per page (max 100).\r\n- `languages`: List of programming languages to filter by.\r\n- `sources`: List of code sources (e.g., GitHub, BitBucket).\r\n- `lines_of_code_gt`: Filter to sources with greater lines of code than supplied int. Valid values 0 to 10000.\r\n- `lines_of_code_lt`: Filter to sources with less lines of code than supplied int. Valid values 0 to 10000.\r\n- `callback`: Callback function (JSONP only)\r\n\r\n\u003e If the results list is empty, then this indicates that you have reached the end of the available results.\r\n\r\n\u003e To fetch all results for a given query, keep incrementing `page` parameter until you get a page with an empty results\r\n\u003e list.\r\n\r\n#### Code Search Without Filters\r\n\r\n```python\r\n\r\nimport searchcode as sc\r\n\r\nsearch = sc.code_search(query=\"test\")\r\n\r\nfor result in search.results:\r\n    print(result)\r\n```\r\n\r\n#### Filter by Language (Java and JavaScript)\r\n\r\n```python\r\n\r\nimport searchcode as sc\r\n\r\nsearch = sc.code_search(query=\"test\", languages=[\"Java\", \"JavaScript\"])\r\n\r\nfor result in search.results:\r\n    print(result.language)\r\n```\r\n\r\n#### Filter by Source (BitBucket and CodePlex)\r\n\r\n```python\r\n\r\nimport searchcode as sc\r\n\r\nsearch = sc.code_search(query=\"test\", sources=[\"BitBucket\", \"CodePlex\"])\r\n\r\nfor result in search.results:\r\n    print(result.filename)\r\n```\r\n\r\n#### Filter by Lines of Code (Between 500 and 1000)\r\n\r\n```python\r\n\r\nimport searchcode as sc\r\n\r\nsearch = sc.code_search(query=\"test\", lines_of_code_gt=500, lines_of_code_lt=1000)\r\n\r\nfor result in search.results:\r\n    print(result)\r\n```\r\n\r\n#### With Callback Function (JSONP only)\r\n\r\n```python\r\nimport searchcode as sc\r\n\r\nsearch = sc.code_search(query=\"test\", callback=\"myCallback\")\r\nprint(search)\r\n```\r\n\r\n#### Response Attribute Definitions\r\n\r\n| Attribute            | Description                                                                                                                                                                                               |\r\n|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\r\n| **searchterm**       | Search term supplied to the API through the use of the `q` parameter.                                                                                                                                     |\r\n| **query**            | Identical to `searchterm` and included for historical reasons to maintain backward compatibility.                                                                                                         |\r\n| **matchterm**        | Identical to `searchterm` and included for historical reasons to maintain backward compatibility.                                                                                                         |\r\n| **page**             | ID of the current page that the query has returned. This is a zero-based index.                                                                                                                           |\r\n| **nextpage**         | ID of the offset of the next page. Always set to the current page + 1, even if you have reached the end of the results. This is a zero-based index.                                                       |\r\n| **previouspage**     | ID of the offset of the previous page. If no previous page is available, it will be set to `null`. This is a zero-based index.                                                                            |\r\n| **total**            | The total number of results that match the `searchterm` in the index. Note that this value is approximate. It becomes more accurate as you go deeper into the results or use more filters.                |\r\n| **language_filters** | Returns an array containing languages that exist in the result set.                                                                                                                                       |\r\n| **id**               | Unique ID for this language used by searchcode, which can be used in other API calls.                                                                                                                     |\r\n| **count**            | Total number of results that are written in this language.                                                                                                                                                |\r\n| **language**         | The name of this language.                                                                                                                                                                                |\r\n| **source_filters**   | Returns an array containing sources that exist in the result set.                                                                                                                                         |\r\n| **id**               | Unique ID for this source used by searchcode, which can be used in other API calls.                                                                                                                       |\r\n| **count**            | Total number of results that belong to this source.                                                                                                                                                       |\r\n| **source**           | The name of this source.                                                                                                                                                                                  |\r\n| **results**          | Returns an array containing the matching code results.                                                                                                                                                    |\r\n| **id**               | Unique ID for this code result used by searchcode, which can be used in other API calls.                                                                                                                  |\r\n| **filename**         | The filename for this file.                                                                                                                                                                               |\r\n| **repo**             | HTML link to the location of the repository where this code was found.                                                                                                                                    |\r\n| **linescount**       | Total number of lines in the matching file.                                                                                                                                                               |\r\n| **location**         | Location inside the repository where this file exists.                                                                                                                                                    |\r\n| **name**             | Name of the repository that this file belongs to.                                                                                                                                                         |\r\n| **language**         | The identified language of this result.                                                                                                                                                                   |\r\n| **url**              | URL to searchcode's location of the file.                                                                                                                                                                 |\r\n| **md5hash**          | Calculated MD5 hash of the file's contents.                                                                                                                                                               |\r\n| **lines**            | Contains line numbers and lines which match the `searchterm`. Lines immediately before and after the match are included. If only the filename matches, up to the first 15 lines of the file are returned. |\r\n\r\n### Code Result\r\n\r\nReturns the raw data from a code file given the code id which can be found as the `id` in a code search result.\r\n\r\n#### Params\r\n\r\n- `_id`: Unique identifier for the code file (required).\r\n\r\n```python\r\n\r\nimport searchcode as sc\r\n\r\ncode = sc.code_result(4061576)\r\nprint(code)\r\n```\r\n\r\n## About Searchcode\r\n\r\nSearchcode is a simple, comprehensive source code search engine that indexes billions of lines of code from open-source\r\nprojects,\r\nhelping you find real world examples of functions, API's and libraries in 243 languages across 10+ public code sources.\r\n\r\n[Learn more](https://searchcode.com/about)\r\n\r\n## Acknowledgements\r\n\r\nThis SDK is developed and maintained by [Ritchie Mwewa](https://gravatar.com/rly0nheart), in collaboration\r\nwith [Ben Boyter](https://boyter.org/about/), the creator of [Searchcode.com](https://searchcode.com).\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frly0nheart%2Fsearchcode-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frly0nheart%2Fsearchcode-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frly0nheart%2Fsearchcode-sdk/lists"}