年龄 / 生肖 / 星座 API

根据公历生日计算周岁、虚岁、已活天数、生肖、星座、农历生日,以及下一个公历/农历生日倒计时

数据来源:本地计算(农历数据复用 /api/lunar)

返回统一的 JSON 格式 { code, message, cached, stale, updatedAt, data },支持跨域,免注册每天可免费调用 100 次,注册后每天 10000 次。

周岁、虚岁、生肖、星座与生日倒计时

GET /api/age

请求参数

  • birthday(必填):公历出生日期 YYYY-MM-DD(1900-01-31 起),示例 1995-08-20
  • date:按哪天计算,YYYY-MM-DD,默认今天(北京时间),示例 2026-09-25

返回字段

  • birthday(string):出生日期 YYYY-MM-DD
  • date(string):计算基准日期 YYYY-MM-DD(默认北京时间今天)
  • weekday(string):出生那天是星期几
  • age(number):周岁:过了今年生日才加 1(2 月 29 日出生的,非闰年在 2 月 28 日算过生日)
  • nominalAge(number):虚岁:出生即 1 岁,每过一个农历新年(正月初一)加 1 岁
  • daysLived(number):从出生到基准日期经过的天数
  • zodiac(string):生肖(按农历正月初一换年,春节前出生属上一年的生肖)
  • ganzhiYear(string):出生农历年的干支纪年,如 乙亥
  • constellation(object):星座(按常用的公历日期划分,交界日期各资料可能差一天)
  • constellation.name(string):星座中文名,如 狮子座
  • constellation.en(string):星座英文名,如 Leo
  • constellation.range(string):该星座的公历日期范围,如 "07-23 ~ 08-22"
  • lunar(object):农历生日
  • lunar.year(number):农历年(数字)
  • lunar.month(number):农历月(1~12)
  • lunar.day(number):农历日(1~30)
  • lunar.isLeap(boolean):是否闰月出生
  • lunar.text(string):农历生日中文,如 乙亥年七月廿五
  • nextBirthday(object):下一个公历生日(基准日期当天就是生日时即为当天)
  • nextBirthday.date(string):日期 YYYY-MM-DD
  • nextBirthday.weekday(string):星期几
  • nextBirthday.daysUntil(number):距离下一个生日还有几天,当天为 0
  • nextBirthday.turning(number):到时满几周岁
  • nextBirthday.isToday(boolean):基准日期是否正好是生日
  • nextLunarBirthday(object|null):下一个农历生日(闰月出生的按同名普通月过,该月没有三十的按廿九过);超出农历表范围时为 null
  • nextLunarBirthday.date(string):对应的公历日期 YYYY-MM-DD
  • nextLunarBirthday.daysUntil(number):距离还有几天,当天为 0
  • nextLunarBirthday.text(string):当年过生日的农历月日,如 七月廿五