Metadata-Version: 2.4
Name: lcr_api_2
Version: 0.10.0
Summary: An API for the LDS churches Leader and Clerk Resources (LCR),
Home-page: https://github.com/SpencerMKSmith/LCR-API-2
Download-URL: https://github.com/SpencerMKSmith/LCR-API-2/archive/0.10.0.zip
Author: Spencer Smith
Author-email: spencermksmith@gmail.com
License: MIT License
Platform: any
Description-Content-Type: text/markdown
Requires-Dist: requests<3,>=2
Requires-Dist: selenium<5,>=4.11
Dynamic: author
Dynamic: author-email
Dynamic: description
Dynamic: description-content-type
Dynamic: download-url
Dynamic: home-page
Dynamic: license
Dynamic: platform
Dynamic: requires-dist
Dynamic: summary

# LCR API

Forked from: https://github.com/philipbl/LCR-API.  Updated in PIP as lcr-api-2 to pull the new version that works.

A Python API for Leader and Clerk Resources for the LDS Church. I've only tested it with Python 3.5+.

## Breaking change in 0.9.0 — `member_list()` now scrapes the new LCR web app

As of mid-2026 the Church rebuilt the Member List report as a Next.js app
served under `lcr.churchofjesuschrist.org/mlt/`. The old REST endpoint
(`/api/umlu/report/member-list`) now returns 404, and there is no JSON
replacement — the data is only delivered to the browser as a React Server
Components (RSC) stream from a server action.

Because of that, `member_list()` no longer replays an HTTP request with the
`requests` session. Instead it drives the already-authenticated Selenium
browser to the report page, captures the server-action response via the Chrome
DevTools Protocol, and parses the member array out of the RSC payload. The
browser fires the request itself, so the build-specific server-action hash is
always current and the call keeps working across Church front-end redeploys.

What this means for callers:
- The Selenium browser is now kept alive after login (the other REST-based
  methods are unchanged). Call `api.close()` when you're done, or use the API
  as a context manager: `with API(user, pw, unit) as api: ...`.
- `member_list()` returns the new member records directly. These are keyed by
  `uuid` (not `legacyCmisId`) and use the new field shape: `nameFormats`
  (with `listPreferredLocal` / `spokenPreferredLocal`), `sex`, `age`,
  `birthDateDisplay`, `birthDateSort`, `address`, `statusFlags`, `householdUuid`,
  `householdRole`.
- All other methods (`birthday_list`, `members_moved_out`, `temple_recommend`,
  etc.) are unchanged and still use the REST endpoints.

The following calls are supported, which correspond to a page in LCR:

- Birthday list (`birthday_list`)
- Members moved out (`members_moved_out`)
- Members moved in (`members_moved_in`)
- Member list (`member_list`)
- Calling list by organization (`callings`)
- Members with callings list (`members_with_callings_list`)
- Recommend Status (`recommend_status`)
- Individual Photo (`individual_photo`)
- Ministering List (`ministering`)
- Access Table (`access_table`)

More calls will be supported as I have time. Pull requests are welcomed!

## Disclaimer

This code is rough around the edges. I don't handle any cases where a person using this code doesn't have permissions to access the reports, so I don't know what will happen.

## Install

To install, run

```
pip3 install lcr-api-2
```

## Usage

```python
from lcr import API as LCR

lcr = LCR("<LDS USERNAME>", "<LDS PASSWORD>", <UNIT NUMBER>)

months = 5
move_ins = lcr.members_moved_in(months)

for member in move_ins:
    print("{}: {}".format(member['spokenName'], member['textAddress']))
```

## Trouble shooting

### selenium.common.exceptions.WebDriverException: Message: 'THIRD_PARTY_NOTICES.chromedriver' executable may have wrong permissions.

Clear the webdriver-manager cache:
```
rm -rf ~/.wdm/drivers/chromedriver
```

### Upgrade webdriver_manager in your environment to a newer version

```
pip3 install --upgrade webdriver_manager
```


## To Do
- Add more tests
- Support more reports and calls

