API call to get access token
(api_key)
| 3 | |
| 4 | |
| 5 | def get_access_token(api_key) -> str: |
| 6 | """ |
| 7 | API call to get access token |
| 8 | """ |
| 9 | response = requests.post( |
| 10 | "https://api.virtuals.io/api/accesses/tokens", |
| 11 | json={"data": {}}, |
| 12 | headers={"x-api-key": api_key} |
| 13 | ) |
| 14 | |
| 15 | response_json = response.json() |
| 16 | if response.status_code != 200: |
| 17 | raise ValueError(f"Failed to get token: {response_json}") |
| 18 | |
| 19 | return response_json["data"]["accessToken"] |
| 20 | |
| 21 | |
| 22 | def post(base_url: str, api_key: str, endpoint: str, data: dict) -> dict: |