Authentication¶
pyJiraV3 uses Jira Cloud’s Basic auth with API tokens.
Generate an API Token¶
Click Create API token
Give it a label and click Create
Copy the token value
Connect by Domain¶
If your Jira instance is at https://mycompany.atlassian.net:
from pyjira import JiraClient
client = JiraClient(
domain='mycompany',
email='you@example.com',
api_token='your-api-token',
)
Connect by Base URL¶
For custom domains or on-premise proxies:
client = JiraClient(
base_url='https://jira.internal.company.com',
email='you@example.com',
api_token='your-api-token',
)
You must provide either domain or base_url, not both.
Client Options¶
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Atlassian domain (e.g. |
|
|
|
Full base URL (alternative to |
|
|
– |
Atlassian account email |
|
|
– |
API token from Atlassian account settings |
|
|
|
Request timeout in seconds |
|
|
|
Additional HTTP headers to merge in |
Environment Variables¶
A common pattern is to load credentials from environment variables:
import os
from pyjira import JiraClient
client = JiraClient(
domain=os.environ['JIRA_DOMAIN'],
email=os.environ['JIRA_EMAIL'],
api_token=os.environ['JIRA_API_TOKEN'],
)
Connection Lifecycle¶
Always close the client when done to release the HTTP connection pool:
# Option 1: Context manager (recommended)
with JiraClient(domain='mycompany', email='...', api_token='...') as client:
...
# Option 2: Explicit close
client = JiraClient(domain='mycompany', email='...', api_token='...')
try:
...
finally:
client.close()
The same applies to AsyncJiraClient:
async with AsyncJiraClient(domain='mycompany', email='...', api_token='...') as client:
...