get https://app.medallion.co/p/api/v1/documents//
Fetch a link to a given Document. The link will only be active for 24 hours. Use as, e.g.:
headers = {"Accept": "application/json", "x-api-key": "YOUR-API-KEY"}
providers = requests.get(
"https://api.medallion.co/api/v1/org/providers",
params={"limit": 100, "license_state": "CA"},
headers=headers,
).json()["results"]
provider_id = providers[0]["id"]
licenses = requests.get(
"https://api.medallion.co/api/v1/org/licenses",
params={"limit": 100, "provider__id": provider_id},
headers=headers,
).json()["results"]
license_document_id = licenses[0]["document"]["id"]
response = requests.get(
f"https://api.medallion.co/p/api/v1/doc-files/{license_document_id}",
headers=headers,
)
time_limited_url = response.json().get("time_limited_url")
file_response = requests.get(time_limited_url)
file_ext = urlparse(time_limited_url).path.split(".").pop(1)
with open(f"{license_document_id}.{file_type}", 'wb') as out:
out.write(response.content)