Python Examples for FinAutCRM API¶
This section provides Python code examples for interacting with the FinAutCRM API.
Prerequisites¶
Install the requests library:
pip install requests
Credentials Setup¶
Create a client-data.json file in the userdocs/examples/ directory with your credentials:
{
"client_id": "your_client_id_here",
"client_secret": "your_client_secret_here"
}
Warning
Never commit your client-data.json file to version control!
Examples¶
1. Get Access Token¶
01_get_access_token.py - Authenticate and obtain an access token using OAuth2 client credentials flow.
--8<-- "userdocs/examples/python/01_get_access_token.py"
2. List Ordninger (Verify Token)¶
02_list_ordninger.py - Fetch ordninger (schemes) to verify your token works. Demonstrates authenticated API requests with pagination.
--8<-- "userdocs/examples/python/02_list_ordninger.py"
3. List Organization Units¶
03_list_orgunits.py - Fetch a paginated list of organization units with optional filtering by kind, active status, or search term.
--8<-- "userdocs/examples/python/03_list_orgunits.py"
4. Get Organization Unit Tree¶
04_get_orgunit_tree.py - Fetch a single organization unit with its full tree of descendants. Demonstrates hierarchical data traversal.
--8<-- "userdocs/examples/python/04_get_orgunit_tree.py"
5. Get Innmeldte (Enrolled Members)¶
05_get_innmeldte.py - Fetch enrollment counts per company from a January invoice report. Demonstrates listing available JAN invoices and querying enrollment data broken down by ordning.
--8<-- "userdocs/examples/python/05_get_innmeldte.py"