MCPcopy
hub / github.com/django/django / get_api_response

Function get_api_response

scripts/manage_translations.py:63–79  ·  view source on GitHub ↗
(endpoint, api_token=None, params=None, verbosity=0)

Source from the content-addressed store, hash-verified

61
62
63def get_api_response(endpoint, api_token=None, params=None, verbosity=0):
64 if api_token is None:
65 api_token = get_api_token()
66 headers = {
67 "Authorization": f"Bearer {api_token}",
68 "Accept": "application/vnd.api+json",
69 "Content-Type": "application/json",
70 }
71 endpoint = endpoint.strip("/")
72 url = f"https://rest.api.transifex.com/{endpoint}"
73 if verbosity > 2:
74 print(f"\n>>> GET {url=} {params=}")
75 response = requests.get(url, headers=headers, params=params)
76 if verbosity > 2:
77 print(f">>>> GET {response=}\n")
78 response.raise_for_status()
79 return response.json()["data"]
80
81
82def list_resources_with_updates(

Callers 1

Calls 3

get_api_tokenFunction · 0.85
getMethod · 0.45
jsonMethod · 0.45

Tested by

no test coverage detected