Home
avatar

如果不存在过

日期黄历查询

查询当天公历日期和农历日期,以及节气黄历等信息

接口信息

项目内容
接口地址https://api.code410.com/api/time/almanac
返回格式application/json
请求方式HTTP GET POST/JSON
更新日期2023-04-21
调用权限免费开放
每日限制无限制
请求频率限制1秒5次

请求示例

https://api.code410.com/api/time/almanac

请求 HEADER

名称
Content-Typeapplication/x-www-form-urlencoded;charset;

请求参数说明

名称必填类型示例值说明
ystring2023需要查询的年份,为空则查询当前年份
mstring06需要查询的月份,为空则查询当前月份
dstring20需要查询的日期,为空则查询当前日期

返回参数说明

名称类型说明
codeint状态码
msgstring状态信息
datastring请求结果数据集
debugstring/array调试数据
exec_timefloat执行耗时
user_ipstring客户端IP

错误码参照

错误码类型说明
403int没有权限
400int参数传递不正确
500int服务器内部错误

在线调试 / 完整文档

本接口为 信息查找 分类下的开放接口。完整文档、在线调试与示例代码请前往 https://api.code410.com/doc/177

返回示例

{
  "code": 200,
  "msg": "请求成功",
  "data": {
    "公历": "2026年06月07日 星期日",
    "节日": "",
    "农历": {
      "日期": "农历 四月 廿二",
      "天干地支": "丙午年 (马年) 甲午月 壬子日",
      "宜": "破屋,坏垣,余事勿取",
      "忌": "诸事不宜"
    },
    "黄历": {
      "生肖": "马",
      "相冲": "冲马 (丙午)煞南",
      "年五行": "天河水",
      "月五行": "沙中金",
      "日五行": "桑松木",
      "星宿": "室宿(室火猪)",
      "六曜": "先胜",
      "十二神位": "危执位",
      "季节": "夏季",
      "星座": "室宿(室火猪)",
      "彭祖百忌": "壬不汲水更难提防,子不问卜自惹祸殃。",
      "胎神占方": "仓库碓外东北",
      "24节气": "芒种 第3天 (距下一个节气“夏至”,还有14天)",
      "儒略日": "2461204.5",
      "伊斯兰历": "1447年12月22日"
    }
  },
  "exec_time": 1.233,
  "ip": "197.149.235.178"
}

示例代码

// jQuery-Ajax
$.ajax({
	url: 'https://api.code410.com/api/time/almanac',
	data: {
		y: "2023",
		m: "06",
		d: "20",
	},
	type: 'GET',
	dataType: 'json',
	success: function (data) {
		console.log(data); // 请求成功,输出结果
	},
	error: function () {
		console.log('请求失败');
	}
});
import requests

url = "https://api.code410.com/api/time/almanac"
params = {
    "y": "2023",
    "m": "06",
    "d": "20",
}
res = requests.get(url, params=params)
print(res.json())
const https = require('https');
const url = 'https://api.code410.com/api/time/almanac?y=2023&m=06&d=20';

https.get(url, res => {
  let data = '';
  res.on('data', chunk => data += chunk);
  res.on('end', () => console.log(JSON.parse(data)));
}).on('error', err => console.error(err));
package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	resp, err := http.Get("https://api.code410.com/api/time/almanac?y=2023&m=06&d=20")
	if err != nil {
		fmt.Println("http get error", err)
		return
	}
	defer resp.Body.Close()

	result, _ := ioutil.ReadAll(resp.Body)
	fmt.Println(string(result))
}
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Test {
    public static void main(String[] args) {
        try {
            URL url = new URL("https://api.code410.com/api/time/almanac?y=2023&m=06&d=20");
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");
            conn.connect();

            BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
            String line;
            StringBuilder sb = new StringBuilder();
            while ((line = reader.readLine()) != null) sb.append(line);
            reader.close();
            System.out.println(sb.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program {
    static async Task Main() {
        HttpClient client = new HttpClient();
        string url = "https://api.code410.com/api/time/almanac?y=2023&m=06&d=20";
        HttpResponseMessage response = await client.GetAsync(url);
        string body = await response.Content.ReadAsStringAsync();
        Console.WriteLine(body);
    }
}
<?php
$url = "https://api.code410.com/api/time/almanac?y=2023&m=06&d=20";
$response = file_get_contents($url);
$data = json_decode($response, true);
print_r($data);
curl "https://api.code410.com/api/time/almanac?y=2023&m=06&d=20"

在线调试

填写参数后点击「发起请求」查看实时返回结果。

免费