The Python Skyfield API can do this. What follows is a brief python program that will calculate the fraction of time that has passed between the last and the next New Moon.
import pytz
from bisect import bisect
from datetime import datetime, tzinfo, timedelta
from skyfield import api, almanac
def main():
time_zone = pytz.timezone("UTC")
time = time_zone.localize(datetime.utcnow())
ephemeris = api.load("de421.bsp")
timescale = api.load.timescale()
start_ts, end_ts = timescale.utc((time - timedelta(days=30),
time + timedelta(days=30)))
phase_times, phase_indices = almanac.find_discrete(
start_ts, end_ts, almanac.moon_phases(ephemeris))
new_moons = [phase_time for phase_time, phase_index
in zip(phase_times.astimezone(time_zone), phase_indices)
if phase_index == 0]
index = bisect(new_moons, time)
prev_moon, next_moon = new_moons[index-1: index + 1]
lunation_fraction = (time - prev_moon) / (next_moon - prev_moon)
print(f"Lunation fraction: {lunation_fraction}")
if __name__ == '__main__':
main()