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