Tracking Licenses & Licensed Providers

Overview

There are multiple ways to track licenses. This guide explains how to get

  1. Providers with active Licenses in a given state
  2. Providers with active Licenses in a given certificate type
  3. States that a specific Provider has active Licenses in
  4. All expired licenses
  5. All licenses that will expire in T days
  6. All expired licenses for a given Provider

For tracking licenses, you can visit the Medallion API Platform GET Licenses endpoint and fill the Query Params as your need. This guide will explain which Query Params to fill along with example Python code.

Preparation

Start by setting your API key. If you will track licenses for specific Providers, please gather Providers' unique IDs.

📘

Save your IDs!

If at any point you lost track of your Provider IDs, you can use the GET Providers endpoint with a search to find them again, e.g. with requests.get(providers_url, params={"search": "[email protected]"}, headers=headers).

Get Providers with active Licenses in a given state

  1. Fill Query Parameter 'state'
    e.g. CA

Note: you can search for multiple states. If you are using the Medallion Platform UI, you can click Add String multiple times.

  1. Set Query Parameter 'status' to active
import requests

status = "active"
state1 = "CA"
state2 = "CO" #you can add many more states to filter this way

url = f"https://api.medallion.co/api/v1/org/licenses/?state={state1}&state={state2}&status={status}"

headers = {
    "accept": "application/json",
    "x-api-key": "<YOUR_API_KEY>"
}

response = requests.get(url, headers=headers)
response_json = response.json()
results = response_json['results']

#to get the list of unique providers
providers = set()
for license in results:
  providers.add(license["provider"])

print(providers)

Providers with active Licenses in a given certificate type

  1. Fill Query Parameter 'certificate_type'
    e.g. DO
  2. Set Query Parameter 'status' to active
import requests

status = "active"
certificate_type = "DO"

url = f"https://app.medallion.co/api/v1/org/licenses/?certificate_type={certificate_type}&status={status}"

headers = {
    "accept": "application/json",
    "x-api-key": "<YOUR_API_KEY>"
}

response = requests.get(url, headers=headers)
response_json = response.json()
results = response_json['results']

#to get the list of unique providers
providers = set()
for license in results:
  providers.add(license["provider"])

print(providers)

States that a specific Provider has active Licenses in

  1. Fill Query Parameter provider__id to your Provider's unique UUID
  2. Set Query Parameter 'status' to active
import requests

status = "active"
provider__id = "<PROVIDER_ID>"

url = f"https://app.medallion.co/api/v1/org/licenses/?provider__id={provider__id}&status={status}"

headers = {
    "accept": "application/json",
    "x-api-key": "<YOUR_API_KEY>"
}

response = requests.get(url, headers=headers)
response_json = response.json()
results = response_json['results']

#to get the list of unique states
states = set()
for license in results:
  states.add(license["state"])

print(states)

All expired licenses

  1. Set expiration_date_before to today's date (in YYYY-MM-DD format) and expiration_date_after to some old date (e.g. 1990-01-01)
import requests
from datetime import datetime, timedelta

today = datetime.today().strftime('%Y-%m-%d')
start_date = "1990-01-01"
expiration_date = today

headers = {
    "accept": "application/json",
    "x-api-key": "<YOUR_API_KEY>"
}

url = f"https://app.medallion.co/api/v1/org/licenses/?expiration_date_after={start_date}&expiration_date_before={expiration_date"


response = requests.get(url, headers=headers)
response_json = response.json()
results = response_json['results']

print(results)

All licenses that will expire in T days

  1. Set Query Parameter 'status' to active
  2. Set expiration_date_before to the date you want to set the range (e.g. if you want to see the licenses that will expire in 10 days set this date to 10 days from today) and expiration_date_after to today's date (in YYYY-MM-DD format)
import requests
from datetime import datetime, timedelta

status = "active"
num_days = 25 #number of days it will expire in 
today = datetime.today()
expiration_date = (today + timedelta(days = num_days)).strftime('%Y-%m-%d')
today = today.strftime('%Y-%m-%d')

headers = {
    "accept": "application/json",
    "x-api-key": "<YOUR_API_KEY>"
}

url = f"https://app.medallion.co/api/v1/org/licenses/?expiration_date_after={today}&expiration_date_before={expiration_date}&status={status}"


response = requests.get(url, headers=headers)
response_json = response.json()
results = response_json['results']

print(results)


All expired licenses for a given Provider

  1. Set expiration_date_before to today's date (in YYYY-MM-DD format) and expiration_date_after to some old date (e.g. 1990-01-01)
  2. Set provider__id to your Provider's unique UUID
import requests
from datetime import datetime, timedelta

provider__id = "<PROVIDER_ID>"
today = datetime.today().strftime('%Y-%m-%d')
start_date = "1990-01-01"
expiration_date = today

headers = {
    "accept": "application/json",
    "x-api-key": "<YOUR_API_KEY>"
}

url = f"https://app.medallion.co/api/v1/org/licenses/?expiration_date_after={start_date}&expiration_date_before={expiration_date}&provider__id={provider__id}"


response = requests.get(url, headers=headers)
response_json = response.json()
results = response_json['results']

print(results)