Hello, in Python API, you can create new endpoints. Is there a way to remove endpoints? Also, I can't find a way to get a list of templates programmatically. Thanks!
Solution
or, if you just want a python function:
import requestsimport runpod import osdef get_templates(): # The API endpoint url = "https://api.runpod.io/graphql" # Your API key api_key = os.getenv("RUNPOD_API_KEY") # You can replace this with your api key # The GraphQL query query = """ query { myself { podTemplates { id } } } """ # Headers headers = { "Content-Type": "application/json", } # The request payload payload = { "query": query } # Send the POST request response = requests.post(url, json=payload, headers=headers, params={"api_key": api_key}) if response.status_code == 200: data = response.json() pod_templates = data.get('data', {}).get('myself', {}).get('podTemplates', []) template_ids = [template['id'] for template in pod_templates] else: print(f"Error: {response.status_code}") print(response.text) return template_idstemplates = get_templates()print(templates)
import requestsimport runpod import osdef get_templates(): # The API endpoint url = "https://api.runpod.io/graphql" # Your API key api_key = os.getenv("RUNPOD_API_KEY") # You can replace this with your api key # The GraphQL query query = """ query { myself { podTemplates { id } } } """ # Headers headers = { "Content-Type": "application/json", } # The request payload payload = { "query": query } # Send the POST request response = requests.post(url, json=payload, headers=headers, params={"api_key": api_key}) if response.status_code == 200: data = response.json() pod_templates = data.get('data', {}).get('myself', {}).get('podTemplates', []) template_ids = [template['id'] for template in pod_templates] else: print(f"Error: {response.status_code}") print(response.text) return template_idstemplates = get_templates()print(templates)