Skip to content
This repository was archived by the owner on Jun 24, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ notebooks/.ipynb_checkpoints
.venv/
.python-version
__pycache__/
.DS_Store
4 changes: 2 additions & 2 deletions notebooks/Applications API.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"source": [
"application_route = \"/applications\"\n",
"\n",
"# Source must be \"internal\" or \"vendor\"\n",
"# Type must be \"other\", \"genai\", \"classifier\", \"recommender\", \"regression\", or \"unsupervised\"\n",
"# Please see https://api.fairnow.dev/v2/docs for enumerated values for ApplicationSource and ApplicationType\n",
"\n",
"request_body = {\n",
" \"name\": \"Your Application Name\",\n",
" \"source\": \"internal\",\n",
Expand Down
21 changes: 9 additions & 12 deletions notebooks/Export Reports.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@
"outputs": [],
"source": [
"# Add imports\n",
"from utils.dataframe_helpers import create_compliance_df\n",
"from utils.dataframe_helpers import create_application_compliance_df\n",
"from utils.fairnow import export_to_tsv\n",
"\n",
"# Create Compliance DataFrames for Application\n",
"# Note: DataFrames can be used for graphing or further analysis\n",
"application_compliance_df = create_compliance_df(client_id='client_id', control_type=\"application\") # Replace with your Client Id\n",
"# # Create Compliance DataFrames for Application\n",
"# # Note: DataFrames can be used for graphing or further analysis\n",
"application_compliance_df = create_application_compliance_df(client_id='client_id') # Replace with your Client Id\n",
"\n",
"# Export to TSV\n",
"export_to_tsv(application_compliance_df, 'application_compliance_export.tsv')"
]
},
Expand All @@ -60,17 +59,15 @@
{
"cell_type": "code",
"execution_count": null,
"id": "6d64b2ac",
"id": "1a09ad93",
"metadata": {},
"outputs": [],
"source": [
"# Add imports\n",
"from utils.dataframe_helpers import create_compliance_df\n",
"# # Add imports\n",
"from utils.dataframe_helpers import create_company_compliance_df\n",
"from utils.fairnow import export_to_tsv\n",
"\n",
"# Create Compliance DataFrames for Company\n",
"# Note: DataFrames can be used for graphing or further analysis\n",
"company_compliance_df = create_compliance_df(client_id='client_id', control_type=\"company\") # Replace with your Client Id\n",
"company_compliance_df = create_company_compliance_df(client_id='client_id') # Replace with your Client Id\n",
"\n",
"# Export to TSV\n",
"export_to_tsv(company_compliance_df, 'company_compliance_export.tsv')"
Expand Down Expand Up @@ -147,7 +144,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.3"
"version": "3.13.7"
}
},
"nbformat": 4,
Expand Down
88 changes: 26 additions & 62 deletions notebooks/utils/api_helpers.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# utils/api_helpers.py
import pandas as pd

def get_application_data(client):
def get_applications(client):
"""
Get application data from the FairNow API.
Get applications data from the FairNow API.
"""
application_route = "/applications"
route = "/applications"

response = None
try:
response = client.get(application_route, timeout=None)
response = client.get(route, timeout=None)
if response.status_code == 200:
response = response.json()
return response
Expand All @@ -20,65 +17,34 @@ def get_application_data(client):
print(e)


def get_application_controls(client, application_id, application_version, control_type):
def get_application_by_id(client, application_id: str):
"""
Get framework controls by framework ID from the FairNow API.
Returns a DataFrame directly with essential fields.
Get individual application data from the FairNow API.
"""
application_route = f"/controls/application/"
query_parameters = {
"application_id": application_id,
"application_version": application_version,
"control_type": control_type # application or company
}
route = f"/applications/{application_id}"

response = None
try:
response = client.get(application_route, params=query_parameters, timeout=None)
response = client.get(route, timeout=None)
if response.status_code == 200:
full_response = response.json()

# Create flattened data for DataFrame
flattened_data = []
for control in full_response.get('controls', []):
# For controls with frameworks, create a row for each framework
frameworks = control.get('frameworks_in_scope', [])
if frameworks:
for framework in frameworks:
flattened_data.append({
'control_id': control.get('control_id'),
'ready': control.get('ready'),
'framework': framework,
'application_id': application_id,
'application_version': application_version
})
else:
# For controls without frameworks, create a single row
flattened_data.append({
'control_id': control.get('control_id'),
'ready': control.get('ready'),
'framework': '',
'application_id': application_id,
'application_version': application_version
})

# Create DataFrame directly
return pd.DataFrame(flattened_data)
response = response.json()
return response
else:
print(f"Error: {response.status_code} - {response.text}")
return None
except Exception as e:
print(e)
return None


def get_frameworks(client):
"""
Get framework data from the FairNow API.
"""
application_route = "/frameworks"
route = "/frameworks"

response = None
try:
response = client.get(application_route, timeout=None)
response = client.get(route, timeout=None)
if response.status_code == 200:
response = response.json()
return response
Expand All @@ -89,36 +55,34 @@ def get_frameworks(client):
print(e)


def get_framework_controls(client, framework_id):
def get_controls(client):
"""
Get framework controls by framework ID from the FairNow API.
Get controls data from the FairNow API.
"""
application_route = f"/controls/framework/"
query_parameters = {"framework_id": framework_id}
framework_response = None

route = "/controls"

response = None
try:
response = client.get(application_route, params=query_parameters, timeout=None)
response = client.get(route, timeout=None)
if response.status_code == 200:
framework_response = response.json()
return framework_response
response = response.json()
return response
else:
print(f"Error: {response.status_code} - {response.text}")
return None
except Exception as e:
print(e)
return None


def get_vendor_data(client):

def get_vendors(client):
"""
Get vendor data from the FairNow API.
"""
application_route = "/vendors/"
route = "/vendors"

response = None
try:
response = client.get(application_route, timeout=None)
response = client.get(route, timeout=None)
if response.status_code == 200:
response = response.json()
return response
Expand Down
Loading
Loading