API Reference¶
Client¶
Synchronous client for the Habitify API v2.
The client can be used as a context manager so the underlying HTTP session is closed automatically::
with HabitipyClient(api_key="...") as client:
page = client.habits.list()
You may also bring your own :class:httpx.Client and manage its lifecycle
yourself::
http = httpx.Client()
client = HabitipyClient(api_key="...", client=http)
# ... use client ...
http.close()
Attributes:
| Name | Type | Description |
|---|---|---|
habits |
Namespace for habit-related endpoints. |
|
areas |
Namespace for area-related endpoints. |
Source code in habitipie/client.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
__init__(api_key: str | None = None, *, client: httpx.Client | None = None, base_url: str = DEFAULT_BASE_URL, timeout: float = DEFAULT_TIMEOUT) -> None
¶
Create a new Habitipy client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str | None
|
Habitify API key. Required when client is not provided and must be a non-empty string. |
None
|
client
|
Client | None
|
An existing :class: |
None
|
base_url
|
str
|
Base URL for the Habitify API. Defaults to the production v2 endpoint. |
DEFAULT_BASE_URL
|
timeout
|
float
|
Default timeout in seconds for HTTP requests. Ignored when client is injected. |
DEFAULT_TIMEOUT
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If api_key is missing, empty, or the injected client
lacks the |
Source code in habitipie/client.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
Resources¶
Resource namespace for Habitify habits.
Source code in habitipie/habits.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | |
get(habit_id: str) -> Habit
¶
Get a single habit by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
habit_id
|
str
|
Unique identifier of the habit. |
required |
Returns:
| Type | Description |
|---|---|
Habit
|
The requested :class: |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If the habit does not exist. |
Source code in habitipie/habits.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
list(*, archived: bool | None = None, area_id: str | None = None, habit_type: HabitType | None = None, time_of_day: str | None = None, limit: int | None = None, offset: int | None = None) -> HabitListPage
¶
List habits with optional filtering and pagination.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
archived
|
bool | None
|
Filter by archived status. |
None
|
area_id
|
str | None
|
Filter by area ID. |
None
|
habit_type
|
HabitType | None
|
Filter by habit type ( |
None
|
time_of_day
|
str | None
|
Filter by time-of-day ID. |
None
|
limit
|
int | None
|
Maximum number of items to return (1–100). |
None
|
offset
|
int | None
|
Number of items to skip. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
HabitListPage
|
class: |
Source code in habitipie/habits.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
create(request: HabitCreateRequest) -> Habit
¶
Create a new habit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
HabitCreateRequest
|
Habit creation payload. |
required |
Returns:
| Type | Description |
|---|---|
Habit
|
The newly created :class: |
Source code in habitipie/habits.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
archive(habit_id: str) -> None
¶
Archive a habit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
habit_id
|
str
|
Unique identifier of the habit to archive. |
required |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If the habit does not exist. |
ApiError
|
If the habit is already archived. |
Source code in habitipie/habits.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
delete(habit_id: str) -> None
¶
Delete a habit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
habit_id
|
str
|
Unique identifier of the habit to delete. |
required |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If the habit does not exist. |
Source code in habitipie/habits.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
create_log(habit_id: str, request: HabitLogRequest) -> HabitLogResponse
¶
Create a log entry for a habit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
habit_id
|
str
|
Unique identifier of the habit. |
required |
request
|
HabitLogRequest
|
Log creation payload. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
A |
HabitLogResponse
|
class: |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If the habit does not exist. |
ApiError
|
If the request payload is invalid. |
Source code in habitipie/habits.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
delete_log(habit_id: str, log_id: str) -> SuccessMessageResponse
¶
Delete a log entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
habit_id
|
str
|
Unique identifier of the habit. |
required |
log_id
|
str
|
Unique identifier of the log entry. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
A |
SuccessMessageResponse
|
class: |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If the habit or log entry does not exist. |
Source code in habitipie/habits.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
complete_log(habit_id: str, request: HabitLogActionRequest | None = None) -> SuccessMessageResponse
¶
Mark a habit as completed for a given date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
habit_id
|
str
|
Unique identifier of the habit. |
required |
request
|
HabitLogActionRequest | None
|
Optional payload with the target date. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
SuccessMessageResponse
|
class: |
Source code in habitipie/habits.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
fail_log(habit_id: str, request: HabitLogActionRequest | None = None) -> SuccessMessageResponse
¶
Mark a habit as failed for a given date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
habit_id
|
str
|
Unique identifier of the habit. |
required |
request
|
HabitLogActionRequest | None
|
Optional payload with the target date. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
SuccessMessageResponse
|
class: |
Source code in habitipie/habits.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
skip_log(habit_id: str, request: HabitLogActionRequest | None = None) -> SuccessMessageResponse
¶
Mark a habit as skipped for a given date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
habit_id
|
str
|
Unique identifier of the habit. |
required |
request
|
HabitLogActionRequest | None
|
Optional payload with the target date. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
SuccessMessageResponse
|
class: |
Source code in habitipie/habits.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
undo_log(habit_id: str, request: HabitLogActionRequest | None = None) -> SuccessMessageResponse
¶
Undo the most recent log action for a habit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
habit_id
|
str
|
Unique identifier of the habit. |
required |
request
|
HabitLogActionRequest | None
|
Optional payload with the target date. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
SuccessMessageResponse
|
class: |
Source code in habitipie/habits.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
list_notes(habit_id: str) -> builtins.list[HabitNote]
¶
List all notes for a habit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
habit_id
|
str
|
Unique identifier of the habit. |
required |
Returns:
| Type | Description |
|---|---|
list[HabitNote]
|
List of :class: |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If the habit does not exist. |
Source code in habitipie/habits.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
create_note(habit_id: str, request: HabitNoteCreateRequest) -> HabitNote
¶
Create a note for a habit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
habit_id
|
str
|
Unique identifier of the habit. |
required |
request
|
HabitNoteCreateRequest
|
Note creation payload. |
required |
Returns:
| Type | Description |
|---|---|
HabitNote
|
The newly created :class: |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If the habit does not exist. |
Source code in habitipie/habits.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
update_note(habit_id: str, note_id: str, request: HabitNoteUpdateRequest) -> HabitNote
¶
Update an existing note.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
habit_id
|
str
|
Unique identifier of the habit. |
required |
note_id
|
str
|
Unique identifier of the note. |
required |
request
|
HabitNoteUpdateRequest
|
Note update payload. |
required |
Returns:
| Type | Description |
|---|---|
HabitNote
|
The updated :class: |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If the habit or note does not exist. |
Source code in habitipie/habits.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
delete_note(habit_id: str, note_id: str) -> None
¶
Delete a note.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
habit_id
|
str
|
Unique identifier of the habit. |
required |
note_id
|
str
|
Unique identifier of the note. |
required |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If the habit or note does not exist. |
Source code in habitipie/habits.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | |
update(habit_id: str, request: HabitUpdateRequest) -> Habit
¶
Update an existing habit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
habit_id
|
str
|
Unique identifier of the habit to update. |
required |
request
|
HabitUpdateRequest
|
Habit update payload. |
required |
Returns:
| Type | Description |
|---|---|
Habit
|
The updated :class: |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If the habit does not exist. |
ApiError
|
If the request payload is invalid. |
Source code in habitipie/habits.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | |
journal(*, journal_date: date | None = None) -> builtins.list[HabitJournalEntry]
¶
Fetch the habit journal for a specific date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
journal_date
|
date | None
|
Date to fetch the journal for. Defaults to today. |
None
|
Returns:
| Type | Description |
|---|---|
list[HabitJournalEntry]
|
List of :class: |
Source code in habitipie/habits.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
statistics(habit_id: str, *, start_date: date | None = None, end_date: date | None = None) -> HabitStatistics
¶
Fetch statistics for a habit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
habit_id
|
str
|
Unique identifier of the habit. |
required |
start_date
|
date | None
|
Start of the date range (inclusive). |
None
|
end_date
|
date | None
|
End of the date range (inclusive). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
HabitStatistics
|
class: |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If the habit does not exist. |
ApiError
|
If the date range is invalid. |
Source code in habitipie/habits.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |
Resource namespace for Habitify areas.
Source code in habitipie/areas.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
list() -> list[Area]
¶
List all areas.
Returns:
| Type | Description |
|---|---|
list[Area]
|
List of :class: |
Source code in habitipie/areas.py
21 22 23 24 25 26 27 | |
get(area_id: str) -> Area
¶
Get a single area by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area_id
|
str
|
Unique identifier of the area. |
required |
Returns:
| Type | Description |
|---|---|
Area
|
The requested :class: |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If the area does not exist. |
Source code in habitipie/areas.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
create(request: AreaCreateRequest) -> Area
¶
Create a new area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
AreaCreateRequest
|
Area creation payload. |
required |
Returns:
| Type | Description |
|---|---|
Area
|
The newly created :class: |
Source code in habitipie/areas.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
update(area_id: str, request: AreaUpdateRequest) -> Area
¶
Update an existing area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area_id
|
str
|
Unique identifier of the area to update. |
required |
request
|
AreaUpdateRequest
|
Area update payload. |
required |
Returns:
| Type | Description |
|---|---|
Area
|
The updated :class: |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If the area does not exist. |
Source code in habitipie/areas.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
delete(area_id: str) -> None
¶
Delete an area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area_id
|
str
|
Unique identifier of the area to delete. |
required |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
If the area does not exist. |
Source code in habitipie/areas.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
Models¶
HabitipyBaseModel
¶
Bases: BaseModel
Base model for all Habitify API data structures.
Uses extra="ignore" so unknown fields in server responses are silently
discarded rather than causing validation errors.
Source code in habitipie/models/habits.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
HabitipyRequestModel
¶
Bases: HabitipyBaseModel
Base for request payloads sent to the Habitify API.
Uses extra="forbid" so typos in field names or unexpected keys raise
a validation error at model construction time rather than being silently
dropped by the server.
Source code in habitipie/models/habits.py
37 38 39 40 41 42 43 44 45 | |
HabitType
¶
Bases: str, Enum
Classification of a habit's moral direction.
Source code in habitipie/models/habits.py
65 66 67 68 69 | |
LogMethod
¶
Bases: str, Enum
How a habit log entry was recorded.
Source code in habitipie/models/habits.py
72 73 74 75 76 | |
GoalPeriodicity
¶
Bases: str, Enum
Time window for evaluating a habit's goal.
Source code in habitipie/models/habits.py
79 80 81 82 83 84 85 | |
HabitStackTriggerType
¶
Bases: str, Enum
Event that triggers a habit stack action.
Source code in habitipie/models/habits.py
117 118 119 120 121 122 123 | |
HabitStackTimerType
¶
Bases: str, Enum
Timing mode for a habit stack trigger.
Source code in habitipie/models/habits.py
126 127 128 129 130 | |
ReminderTime
¶
Bases: HabitipyBaseModel
Clock time for a reminder notification.
Source code in habitipie/models/habits.py
133 134 135 136 137 | |
ReminderOccurrenceFilter
¶
Bases: HabitipyBaseModel
Optional filter limiting which days a reminder fires.
Source code in habitipie/models/habits.py
140 141 142 143 | |
TimeTrigger
¶
Bases: HabitipyBaseModel
A single reminder tied to a specific clock time.
Source code in habitipie/models/habits.py
146 147 148 149 150 151 152 153 154 | |
HabitStack
¶
Bases: HabitipyBaseModel
Chain reaction triggered by another habit's state change.
Source code in habitipie/models/habits.py
157 158 159 160 161 162 163 164 | |
DailyOccurrence
¶
Bases: HabitipyBaseModel
Occurs every day.
Source code in habitipie/models/habits.py
188 189 190 191 | |
WeekDaysOccurrence
¶
Bases: HabitipyBaseModel
Occurs on specific days of the week (0=Sunday).
Source code in habitipie/models/habits.py
194 195 196 197 198 | |
MonthDaysOccurrence
¶
Bases: HabitipyBaseModel
Occurs on specific days of the month.
Source code in habitipie/models/habits.py
201 202 203 204 205 | |
IntervalDaysOccurrence
¶
Bases: HabitipyBaseModel
Occurs every N days.
Source code in habitipie/models/habits.py
208 209 210 211 212 | |
DateEndCondition
¶
Bases: HabitipyBaseModel
End condition satisfied on a specific calendar date.
Source code in habitipie/models/habits.py
233 234 235 236 237 238 239 240 | |
StreakEndCondition
¶
Bases: HabitipyBaseModel
End condition satisfied after maintaining a streak for a given length.
Source code in habitipie/models/habits.py
243 244 245 246 247 248 249 250 251 | |
SuccessPeriodsEndCondition
¶
Bases: HabitipyBaseModel
End condition satisfied after completing a number of goal periods.
Source code in habitipie/models/habits.py
254 255 256 257 258 259 260 261 262 | |
TotalLogValueEndCondition
¶
Bases: HabitipyBaseModel
End condition satisfied after accumulating a total log value.
Source code in habitipie/models/habits.py
265 266 267 268 269 270 271 272 | |
HabitCreateDateEndCondition
¶
Bases: HabitipyBaseModel
Request payload for a date-based end condition.
Source code in habitipie/models/habits.py
275 276 277 278 279 | |
HabitCreateStreakEndCondition
¶
Bases: HabitipyBaseModel
Request payload for a streak-based end condition.
Source code in habitipie/models/habits.py
282 283 284 285 286 | |
HabitCreateSuccessPeriodsEndCondition
¶
Bases: HabitipyBaseModel
Request payload for a success-periods end condition.
Source code in habitipie/models/habits.py
289 290 291 292 293 | |
HabitCreateTotalLogValueEndCondition
¶
Bases: HabitipyBaseModel
Request payload for a total-log-value end condition.
Source code in habitipie/models/habits.py
296 297 298 299 300 | |
HabitCreateGoal
¶
Bases: HabitipyRequestModel
Goal definition used when creating a new habit.
Source code in habitipie/models/habits.py
318 319 320 321 322 323 | |
Goal
¶
Bases: HabitipyBaseModel
Goal returned by the API, including server-generated metadata.
Source code in habitipie/models/habits.py
326 327 328 329 330 331 332 333 334 | |
Area
¶
Bases: HabitipyBaseModel
A named area (category) that habits can belong to.
Source code in habitipie/models/habits.py
337 338 339 340 341 342 343 344 345 | |
AreaResponse
¶
Bases: HabitipyBaseModel
Single-area response envelope.
Source code in habitipie/models/habits.py
348 349 350 351 | |
AreaListResponse
¶
Bases: HabitipyBaseModel
Multi-area response envelope.
Source code in habitipie/models/habits.py
354 355 356 357 | |
AreaCreateRequest
¶
Bases: HabitipyRequestModel
Payload for creating a new area.
Source code in habitipie/models/habits.py
360 361 362 363 364 365 | |
AreaUpdateRequest
¶
Bases: HabitipyRequestModel
Payload for updating an existing area.
Source code in habitipie/models/habits.py
368 369 370 371 372 373 | |
TimeOfDay
¶
Bases: HabitipyBaseModel
A time-of-day block (e.g. Morning, Evening).
Source code in habitipie/models/habits.py
376 377 378 379 380 381 382 383 384 | |
Habit
¶
Bases: HabitipyBaseModel
A habit resource returned by the Habitify API.
Source code in habitipie/models/habits.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |
HabitListPage
¶
Bases: HabitipyBaseModel
Paginated list of habits returned by the API.
Source code in habitipie/models/habits.py
410 411 412 413 414 | |
HabitJournalStatus
¶
Bases: str, Enum
Completion state of a habit on a given day.
Source code in habitipie/models/habits.py
417 418 419 420 421 422 423 | |
HabitJournalStreakUnit
¶
Bases: str, Enum
Unit used to measure a streak length.
Source code in habitipie/models/habits.py
426 427 428 429 | |
HabitJournalCurrentStreak
¶
Bases: HabitipyBaseModel
Current streak metadata for a journal entry.
Source code in habitipie/models/habits.py
432 433 434 435 436 | |
HabitJournalProgress
¶
Bases: HabitipyBaseModel
Progress toward the habit's goal for the journal day.
Source code in habitipie/models/habits.py
439 440 441 442 443 444 445 | |
HabitJournalLogInfo
¶
Bases: HabitipyBaseModel
How the journal entry was logged.
Source code in habitipie/models/habits.py
448 449 450 451 | |
HabitJournalEntry
¶
Bases: HabitipyBaseModel
A single habit entry in the daily journal.
Source code in habitipie/models/habits.py
454 455 456 457 458 459 460 461 462 463 464 465 466 | |
HabitJournalPage
¶
Bases: HabitipyBaseModel
Response envelope for the habit journal endpoint.
Source code in habitipie/models/habits.py
469 470 471 472 | |
HabitStatisticsUnit
¶
Bases: HabitipyBaseModel
Unit information included in habit statistics.
Source code in habitipie/models/habits.py
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 | |
HabitStatisticsDailyProgress
¶
Bases: HabitipyBaseModel
Per-day progress snapshot within habit statistics.
Source code in habitipie/models/habits.py
493 494 495 496 497 498 | |
HabitStatistics
¶
Bases: HabitipyBaseModel
Aggregated statistics for a single habit.
Source code in habitipie/models/habits.py
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 | |
HabitStatisticsResponse
¶
Bases: HabitipyBaseModel
Response envelope for the habit statistics endpoint.
Source code in habitipie/models/habits.py
519 520 521 522 | |
HabitResponse
¶
Bases: HabitipyBaseModel
Single-habit response envelope.
Source code in habitipie/models/habits.py
525 526 527 528 | |
SuccessMessageResponse
¶
Bases: HabitipyBaseModel
Generic success message returned by mutation endpoints.
Source code in habitipie/models/habits.py
531 532 533 534 | |
HabitLogRequest
¶
Bases: HabitipyRequestModel
Payload for logging a numeric value against a habit.
Source code in habitipie/models/habits.py
537 538 539 540 541 542 | |
HabitLogResponse
¶
Bases: SuccessMessageResponse
Response from a habit log action.
Source code in habitipie/models/habits.py
545 546 547 548 | |
HabitLogActionRequest
¶
Bases: HabitipyRequestModel
Payload for simple log actions (complete/skip/fail).
Source code in habitipie/models/habits.py
551 552 553 554 | |
MoodLevel
¶
Bases: str, Enum
Subjective mood scale for a journal note.
Source code in habitipie/models/habits.py
557 558 559 560 561 562 563 564 | |
HabitNote
¶
Bases: HabitipyBaseModel
A note attached to a habit log entry.
Source code in habitipie/models/habits.py
567 568 569 570 571 572 573 574 | |
HabitNoteListResponse
¶
Bases: HabitipyBaseModel
Response envelope for listing habit notes.
Source code in habitipie/models/habits.py
577 578 579 580 | |
HabitNoteWriteRequest
¶
Bases: HabitipyRequestModel
Base payload for creating or updating a habit note.
Source code in habitipie/models/habits.py
583 584 585 586 587 588 589 590 591 592 593 594 | |
HabitNoteCreateRequest
¶
Bases: HabitNoteWriteRequest
Payload for creating a new habit note.
Source code in habitipie/models/habits.py
597 598 599 600 | |
HabitNoteUpdateRequest
¶
Bases: HabitNoteWriteRequest
Payload for updating an existing habit note.
Uses exclude_unset=True so that None can be sent explicitly to
clear a field.
Source code in habitipie/models/habits.py
603 604 605 606 607 608 609 610 611 612 613 614 | |
HabitCreateRequest
¶
Bases: HabitipyRequestModel
Payload for creating a new habit.
Source code in habitipie/models/habits.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 | |
HabitUpdateRequest
¶
Bases: HabitipyRequestModel
Payload for updating an existing habit.
Empty nested objects (e.g. {"goal": {}}) are pruned so the server
does not receive ambiguous partial updates.
Source code in habitipie/models/habits.py
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 | |
Pagination¶
Bases: BaseModel
Pagination metadata returned by list endpoints.
Attributes:
| Name | Type | Description |
|---|---|---|
total |
int
|
Total number of items available across all pages. |
limit |
int
|
Maximum number of items returned in the current page. |
offset |
int
|
Number of items skipped before the current page. |
Source code in habitipie/pagination.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
Errors¶
ResponseDecodeError
¶
Bases: DecodingError
Raised when a response body cannot be decoded as JSON.
Source code in habitipie/errors.py
8 9 | |
UnexpectedResponseShapeError
¶
Bases: ResponseDecodeError
Raised when a response JSON payload does not match the expected top-level shape.
Source code in habitipie/errors.py
12 13 | |
ApiError
¶
Bases: HTTPStatusError
Base exception for Habitify API error responses.
Attributes:
| Name | Type | Description |
|---|---|---|
payload |
The decoded response body, if available. May be a dict, str,
or |
Source code in habitipie/errors.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
AuthenticationError
¶
Bases: ApiError
Raised when authentication is missing or invalid (HTTP 401).
Source code in habitipie/errors.py
36 37 | |
NotFoundError
¶
Bases: ApiError
Raised when the requested resource is missing (HTTP 404).
Source code in habitipie/errors.py
40 41 | |
RateLimitError
¶
Bases: ApiError
Raised when the Habitify API rate limit is exceeded (HTTP 429).
Source code in habitipie/errors.py
44 45 | |
ServerError
¶
Bases: ApiError
Raised when the Habitify API returns a server-side error (HTTP 5xx).
Source code in habitipie/errors.py
48 49 | |
raise_for_api_status(response: httpx.Response) -> None
¶
Raise a Habitify-specific exception for non-2xx responses.
Maps common HTTP status codes to typed subclasses:
- 401 → :class:
AuthenticationError - 404 → :class:
NotFoundError - 429 → :class:
RateLimitError - 5xx → :class:
ServerError - others → :class:
ApiError
The response body is parsed as JSON when possible and attached to the
exception via .payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
Response
|
The HTTP response to inspect. |
required |
Raises:
| Type | Description |
|---|---|
ApiError
|
If the response status is not successful. |
Source code in habitipie/errors.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |