Python SDK quickstart
5 min read Updated February 10, 2026
Installation
bash
pip install compliancegrid
Configuration
python
from compliancegrid import ComplianceGrid
cg = ComplianceGrid(
api_key=os.environ['CG_API_KEY'],
environment='sandbox'
)Screening Example
python
result = cg.compliance.screen_parties(
parties=[{
'name': 'Huawei Technologies',
'country': 'CN',
'type': 'CONSIGNEE'
}]
)
print(result.overall_result) # 'MATCH'
print(result.total_matches) # 1
for match in result.matches:
print(f'{match.matched_list}: {match.match_score}')Async Support
python
import asyncio
from compliancegrid import AsyncComplianceGrid
async def main():
cg = AsyncComplianceGrid(api_key=os.environ['CG_API_KEY'])
result = await cg.hs.search(query='cotton fabric')
print(result)
asyncio.run(main())Error Handling
The Python SDK raises typed exceptions:
RateLimitError— 429 responses (auto-retried up to 3 times)AuthenticationError— Invalid or expired credentialsValidationError— Invalid request parametersAPIError— General server errors
Was this article helpful?