python-api.md (738B)
1 --- 2 label: Python API 3 icon: code 4 order: 660 5 --- 6 7 # Python API Usage 8 9 Githrun can be used inside your own Python scripts. 10 11 ```python 12 import githrun 13 14 # 1. Search a repository 15 results = githrun.search_repository("https://github.com/user/repo", "test") 16 for item in results: 17 print(item['path'], item['raw_url']) 18 19 # 2. Download a file 20 githrun.download_file("https://github.com/user/repo/blob/main/script.py", output_path="script.py") 21 22 # 3. Download a full folder 23 githrun.download_folder("https://github.com/user/repo/tree/main/src") 24 25 # 4. Execute code programmatically 26 exit_code = githrun.execute_remote_code("https://github.com/user/repo/blob/main/script.py", args=["--verbose"]) 27 ``` 28 29 Continue to [VS Code Extension](vscode-extension.md).