# Church of Jesus Christ API

This Python package implements an unofficial API for accessing data from churchofjesuschrist.org. The endpoints are the same ones used by the Church’s website and mobile app, and are therefore subject to change in the future.

By default, most methods can be called with default parameters and will return information for the user’s unit. In the case where a method is to request information for a member, the default is to return information about the current user.

In order to get unit numbers for other units that the user has access to, use user_details to find different unit numbers available to the user.

# Examples

    from church_of_jesus_christ_api import ChurchOfJesusChristAPI
    from os import environ
    import datetime

    username = environ["CHURCH_USERNAME"]
    password = environ["CHURCH_PASSWORD"]

    api = ChurchOfJesusChristAPI(username, password)

    today = datetime.date.today()
    yesterday = today - datetime.timedelta(days=1)

    # Same as api.get_birthdays(unit=api.user_details['homeUnits'][0])
    birthday_list = api.get_birthdays()

    for month in birthday_list:
        for member in month["birthdays"]:
            birthdate = datetime.datetime.strptime(
                member["birthDayFormatted"], "%d %b"
            ).date()
            if birthdate.month == today.month and birthdate.day == today.day:
                print(f"It's {member['spokenName']}'s birthday today!")

                # Use email or phone to automate sending a birthday message here if desired...

    # Same as api.get_moved_in(unit=api.user_details['homeUnits'][0])
    moved_in_list = api.get_moved_in()

    for record in moved_in_list:
        move_date = birthdate = datetime.datetime.strptime(
            record["moveDate"], "%d %b %Y"
        ).date()
        if move_date == yesterday:
            print(f"Records for {record['name']} arrived to the unit yesterday")

            # Use email or phone to automate sending a message to welcome them to the unit...

    # Same as api.get_missionary_progress_record(unit=api.user_details['homeUnits'][0])
    for record in api.get_missionary_progress_record():
        last_vist_timestamp = (
            int(record["lastVisit"]) / 1000.0
        )  # Convert milliseconds to seconds

        if last_vist_timestamp == 0:
            print(f"No last visit recorded for {record['fullName']}")
            # Tell missionaries to update info for this person...
        else:
            visit_date = datetime.datetime.fromtimestamp(last_vist_timestamp).date()
            if visit_date == yesterday:
                print(f"Missionaries visited {record['fullName']} yesterday")
                # Ask the missionaries how the visit went...

# Modules

- church_of_jesus_christ_api package
  - Submodules
  - church_of_jesus_christ_api.church_of_jesus_christ_api module
    - `ChurchOfJesusChristAPI`
      - `ChurchOfJesusChristAPI.convert_date_to_string_using_default_date_if_none()`
      - `ChurchOfJesusChristAPI.download_member_photo()`
      - `ChurchOfJesusChristAPI.get_action_and_interviews()`
      - `ChurchOfJesusChristAPI.get_assigned_missionaries()`
      - `ChurchOfJesusChristAPI.get_attendance()`
      - `ChurchOfJesusChristAPI.get_attendance_date_range()`
      - `ChurchOfJesusChristAPI.get_birthdays()`
      - `ChurchOfJesusChristAPI.get_covenant_path_progress()`
      - `ChurchOfJesusChristAPI.get_directory()`
      - `ChurchOfJesusChristAPI.get_family_history_report()`
      - `ChurchOfJesusChristAPI.get_full_time_missionaries()`
      - `ChurchOfJesusChristAPI.get_group_members()`
      - `ChurchOfJesusChristAPI.get_key_indicators()`
      - `ChurchOfJesusChristAPI.get_member_callings_and_classes()`
      - `ChurchOfJesusChristAPI.get_member_list()`
      - `ChurchOfJesusChristAPI.get_member_service()`
      - `ChurchOfJesusChristAPI.get_members_with_callings()`
      - `ChurchOfJesusChristAPI.get_members_without_callings()`
      - `ChurchOfJesusChristAPI.get_ministering()`
      - `ChurchOfJesusChristAPI.get_ministering_full()`
      - `ChurchOfJesusChristAPI.get_moved_in()`
      - `ChurchOfJesusChristAPI.get_moved_out()`
      - `ChurchOfJesusChristAPI.get_out_of_unit_callings()`
      - `ChurchOfJesusChristAPI.get_quarterly_reports()`
      - `ChurchOfJesusChristAPI.get_seminary_and_institute_quarterly_attendance()`
      - `ChurchOfJesusChristAPI.get_suborganization()`
      - `ChurchOfJesusChristAPI.get_temple_recommend_status()`
      - `ChurchOfJesusChristAPI.get_unit_groups()`
      - `ChurchOfJesusChristAPI.get_unit_organizations()`
      - `ChurchOfJesusChristAPI.get_unit_statistics()`
      - `ChurchOfJesusChristAPI.get_units()`
      - `ChurchOfJesusChristAPI.org_id`
      - `ChurchOfJesusChristAPI.session`
      - `ChurchOfJesusChristAPI.user_details`
  - Module contents

# Indices and tables

- Index

- Module Index