# kortical.api
# init
Note
When called, this will login to Kortical:
- If you have passed in a URL and email/password credentials, these are used for the current session.
- If no arguments are passed in, these details are read from file; see the CLI Setup section below. If no details are saved to file, you will be prompted for them.
We strongly recommend that you set up your login details through the CLI, and only use this function if you need to access a different Kortical system temporarily.
Inputs
system_url
(= None
) - The URL of your Kortical system; see format in the output window below.credentials
(= None
) - either a dictionary with the structure{'email': '<email>', 'password': '<password>'}
, or an encrypted string (obtained using the CLI commandkortical config credentials to_string
). We recommend using the encrypted string, especially during setup for continuous integration (CI).
Returns
None
from kortical import api
# Uses the URL/credentials saved to file. Run [kortical config get] to view this.
api.init()
# Uses the specified URL/credentials for the current session as a one-time thing
api.init(system_url='platform.kortical.com/<company-name>/<system-name>',
credentials={'email': 'bob.marley@kortical.com', 'password': 'jammin2'})
# CLI setup
We recommend initialising config locally for each app folder you create with Kortical, and saving your login details globally in your home directory.
To initialise global config, follow these steps:
# Navigate to your home directory
# Remove .kortical folder if it already exists
> kortical config init
New config folder created at [/Users/owen-saldanha/.kortical].
Please enter your system URL here:
platform.kortical.com/<company>/<system>
Config set at [/Users/owen-saldanha/.kortical/config.yml]:
system_url: https://platform.kortical.com/<company>/<system>
Please enter kortical login email:
owen.saldanha@kortical.com
Password:
**********
Config set at [/Users/owen-saldanha/git/kortical/.kortical/config.yml]:
credentials: gAAAAABj70Ss4eJmfmZhOkaA5-w-h00tkEzOOLG9JZenVBVPdUDYFu-V1LLXINq9RNlTNeyfPYJt3q7iZYDIFSCnkefuvhr90vv09bHFf6tSvHHiWyPS7r8Uw9BunGGDeIMuoThHEbKnXdM9o2r8Ftx9NoPQUqPH6z6dyS_6bEbRmsg=
To initialise local config for your app:
# Navigate to your app folder
> kortical config init
New config folder created at [/Users/owen-saldanha/git/apps/document_tagger/.kortical].
# Select a project + environment
> kortical project select document_tagging
> kortical environment select Integration-Owen
Now we can view the config:
> kortical config get
Config found at: ['/Users/owen-saldanha/.kortical', '/Users/owen-saldanha/git/apps/document_tagger/.kortical']
Kortical Config:
credentials: gAAAAABj70ctYWiaksfheaourvhq084h034E2h_VMfx693780o5b035vbbJh0q384h0q24bv_ujUplNDnjoRHl-jGokeH7id1NAMbaLj6z9KIHqSxxGIbwqirfu1g94742LgGFy4tOIYo4XPso=
system_url: https://platform.kortical.com/<company>/<system>
selected_environment_id: 77
selected_project_id: 24
As a result of this setup, you can quickly switch between app folders that have different project/environment IDs while being able to use your global credentials. For further guidance using the CLI, run kortical --help
.