饥人谷开放 API

所有接口如想使用 https 协议,可把对于后缀是.php 的接口可把 http://api.jirengu.com 替换成 https://jirenguapi.applinzi.com

GitHub API

使用说明

作用: 拉取github项目地址中的readme.md,解析成html

  • 接口: http://api.jirengu.com/readme2html.php
  • 请求类型: GET
  • 请求参数:
    • urlgithub项目地址
  • 支持跨域

使用范例:

范例1

http://api.jirengu.com/readme2html.php?url=https://github.com/jirengu/server-mock

范例2

  $.get('http://api.jirengu.com/readme2html.php',{
        url:'https://github.com/jirengu/server-mock'
    }).done(function(tpl){

    $('body').append(tpl)

    //$('pre code').each(function(i, block) {
    //  hljs.highlightBlock(block);
    //});
  });

markdown API

使用说明

作用: 传入markdown文件的线上地址,解析成html

  • 接口: http://api.jirengu.com/md2html.php
  • 请求类型: GET
  • 请求参数:
    • urlmarkdwon文件线上地址
  • 支持跨域

使用范例:

范例1

http://api.jirengu.com/md2html.php?url=https://raw.githubusercontent.com/jirengu/server-mock/master/README.md

范例2

  $.get('http://api.jirengu.com/md2html.php',{
        url:'https://raw.githubusercontent.com/jirengu/server-mock/master/README.md'
    }).done(function(tpl){

    $('body').append(tpl)

    $('pre code').each(function(i, block) {
      hljs.highlightBlock(block);
    });
  });

markdown page API

使用说明

作用: 传入markdown文件的线上地址,解析并展示成页面,添加样式

  • 接口: http://api.jirengu.com/md2page.php
  • 请求类型: GET
  • 请求参数:
    • urlmarkdwon文件线上地址
  • 支持跨域

使用范例:

范例1

http://api.jirengu.com/md2page.php?url=https://raw.githubusercontent.com/jirengu/server-mock/master/README.md

FM API

FM API数据源来自百度 FM,仅供前端爱好者学习交流使用。如冒昧侵权,请联系我们删除 邮箱

获取专辑分类

  • 接口: http://api.jirengu.com/fm/getChannels.php
  • 请求类型: GET
  • 请求参数:
  • 支持cors, 支持jsonp

使用范例:

范例1

http://api.jirengu.com/fm/getChannels.php

http://api.jirengu.com/fm/getChannels.php?callback=getChannel

范例2

  $.get('http://api.jirengu.com/fm/getChannels.php')
   .done(function(channelInfo){
    console.log(channelInfo)
  });

获取随机歌曲

  • 接口: http://api.jirengu.com/fm/getSong.php
  • 请求类型: GET
  • 请求参数:
    • channel: channel的ID(不填为默认)
  • 支持cors, 支持jsonp

使用范例:

范例1

http://api.jirengu.com/fm/getSong.php?channel=4

http://api.jirengu.com/fm/getSong.php?channel=4&callback=getSong

//https协议,可以在 github pages 上使用
https://jirenguapi.applinzi.com/fm/getSong.php?channel=4

范例2

  $.get('http://api.jirengu.com/fm/getSong.php',{channel: 'public_aaa_bbb'})
   .done(function(song){
    console.log(song)
  });

获取歌词

  • 接口: http://api.jirengu.com/fm/getLyric.php或者 https://jirenguapi.applinzi.com/fm/getLyric.php
  • 请求类型: POST,GET均可
  • 请求参数:
    • sid: 歌曲id
  • 支持cors,jsonp

使用范例:

范例

http://jirenguapi.applinzi.com/fm/getLyric.php?&sid=1451876

https://jirenguapi.applinzi.com/fm/getLyric.php?&sid=1451876

http://jirenguapi.applinzi.com/fm/getLyric.php?sid=1451876&callback=getLyric

  $.post('http://api.jirengu.com/fm/getLyric.php',{sid:"758918"})
   .done(function(lyric){
    console.log(lyric)
  });

查看测试页面

天气 API (新接口)

需要 key 的同学请联系班主任 hungervalley ,该接口仅限饥人谷学员使用。非谷里的学员使用后面的老接口

获取天气

  • 接口: http(s)://weixin.jirengu.com/weather
  • 请求类型: GET
  • 请求参数:
    • key: 加 hungervalley 咨询
    • location: 可选参数,如果没有设置则获取当前用户所在城市的天气。如果设置了则是设置城市的天气,如 beijing杭州南京市
    • 范例1:http://weixin.jirengu.com/weather?key=你的key
    • 范例2:http://weixin.jirengu.com/weather?location=杭州&key=你的key
  • 支持 cors
  • 返回数据
    {
    "status": "OK",
    "weather": [{
        "city_name": "杭州",
        "city_id": "CHZJ000000",
        "last_update": "2017-07-31T16:20:00+08:00",
        "now": {
            "text": "多云",
            "code": "4",
            "temperature": "35",
            "feels_like": "35",
            "wind_direction": "东南",
            "wind_speed": "27.36",
            "wind_scale": "4",
            "humidity": "52",
            "visibility": "25.50",
            "pressure": "993",
            "pressure_rising": "未知",
            "air_quality": {
                "city": {
                    "aqi": "28",
                    "pm25": "12",
                    "pm10": "28",
                    "so2": "8",
                    "no2": "13",
                    "co": "0.682",
                    "o3": "89",
                    "last_update": "2017-07-31T15:00:00+08:00",
                    "quality": "优"
                },
                "stations": null
            },
            "alarms": []
        },
        "today": {
            "sunrise": "05:17 AM",
            "sunset": "06:56 PM",
            "suggestion": {
                "dressing": {
                    "brief": "炎热",
                    "details": "天气炎热,建议着短衫、短裙、短裤、薄型T恤衫等清凉夏季服装。"
                },
                "uv": {
                    "brief": "中等",
                    "details": "属中等强度紫外线辐射天气,外出时建议涂擦SPF高于15、PA+的防晒护肤品,戴帽子、太阳镜。"
                },
                "car_washing": {
                    "brief": "不宜",
                    "details": "不宜洗车,未来24小时内有雨,如果在此期间洗车,雨水和路上的泥水可能会再次弄脏您的爱车。"
                },
                "travel": {
                    "brief": "一般",
                    "details": "有降水,气温也较高,风稍大,能缓解湿热的感觉。外出旅游请注意防暑降温,并记得出门要携带雨具。"
                },
                "flu": {
                    "brief": "少发",
                    "details": "各项气象条件适宜,发生感冒机率较低。但请避免长期处于空调房间中,以防感冒。"
                },
                "sport": {
                    "brief": "较不宜",
                    "details": "有降水,且风力较强,气压较低,推荐您在室内进行低强度运动;若坚持户外运动,须注意避雨防风。"
                },
                "restriction": {
                    "brief": "尾号限行",
                    "details": "3,7"
                }
            }
        },
        "future": [{
            "date": "2017-07-31",
            "high": "35",
            "low": "29",
            "day": "周一",
            "text": "阵雨/阵雨",
            "code1": "10",
            "code2": "10",
            "cop": "",
            "wind": "风力3级"
        }, {
            "date": "2017-08-01",
            "high": "35",
            "low": "28",
            "day": "周二",
            "text": "阵雨/多云",
            "code1": "10",
            "code2": "4",
            "cop": "",
            "wind": "风力4级"
        }, {
            "date": "2017-08-02",
            "high": "36",
            "low": "29",
            "day": "周三",
            "text": "阵雨/多云",
            "code1": "10",
            "code2": "4",
            "cop": "",
            "wind": "风力2级"
        }, {
            "date": "2017-08-03",
            "high": "35",
            "low": "28",
            "day": "周四",
            "text": "阵雨/晴",
            "code1": "10",
            "code2": "1",
            "cop": "",
            "wind": "风力2级"
        }, {
            "date": "2017-08-04",
            "high": "35",
            "low": "28",
            "day": "周五",
            "text": "阵雨/多云",
            "code1": "10",
            "code2": "4",
            "cop": "",
            "wind": "风力2级"
        }, {
            "date": "2017-08-05",
            "high": "36",
            "low": "28",
            "day": "周六",
            "text": "阵雨/多云",
            "code1": "10",
            "code2": "4",
            "cop": "",
            "wind": "风力2级"
        }, {
            "date": "2017-08-06",
            "high": "36",
            "low": "30",
            "day": "周日",
            "text": "阵雨/阵雨",
            "code1": "10",
            "code2": "10",
            "cop": "",
            "wind": "风力2级"
        }, {
            "date": "2017-08-07",
            "high": "35",
            "low": "27",
            "day": "周一",
            "text": "小雨/小雨",
            "code1": "13",
            "code2": "13",
            "cop": "",
            "wind": "风力2级"
        }, {
            "date": "2017-08-08",
            "high": "33",
            "low": "25",
            "day": "周二",
            "text": "小雨/小雨",
            "code1": "13",
            "code2": "13",
            "cop": "",
            "wind": "风力2级"
        }, {
            "date": "2017-08-09",
            "high": "29",
            "low": "23",
            "day": "周三",
            "text": "阴/多云",
            "code1": "9",
            "code2": "4",
            "cop": "",
            "wind": "风力2级"
        }]
    }]
    }

其中 code 代表天气码,对应规则如下

代码 中文 英文 图标
0 Sunny 晴
1 Clear 晴
2 Fair 晴
3 Fair 晴
4 多云 Cloudy 多云
5 晴间多云 Partly Cloudy 晴间多云
6 晴间多云 Partly Cloudy 晴间多云
7 大部多云 Mostly Cloudy 大部多云
8 大部多云 Mostly Cloudy 大部多云
9 Overcast 阴
10 阵雨 Shower 阵雨
11 雷阵雨 Thundershower 雷阵雨
12 雷阵雨伴有冰雹 Thundershower with Hail 雷阵雨伴有冰雹
13 小雨 Light Rain 小雨
14 中雨 Moderate Rain 中雨
15 大雨 Heavy Rain 大雨
16 暴雨 Storm 暴雨
17 大暴雨 Heavy Storm 大暴雨
18 特大暴雨 Severe Storm 特大暴雨
19 冻雨 Ice Rain 冻雨
20 雨夹雪 Sleet 雨夹雪
21 阵雪 Snow Flurry 阵雪
22 小雪 Light Snow 小雪
23 中雪 Moderate Snow 中雪
24 大雪 Heavy Snow 大雪
25 暴雪 Snowstorm 暴雪
26 浮尘 Dust 浮尘
27 扬沙 Sand 扬沙
28 沙尘暴 Duststorm 沙尘暴
29 强沙尘暴 Sandstorm 强沙尘暴
30 Foggy 雾
31 Haze 霾
32 Windy 风
33 大风 Blustery 大风
34 飓风 Hurricane 飓风
35 热带风暴 Tropical Storm 热带风暴
36 龙卷风 Tornado 龙卷风
37 Cold 冷
38 Hot 热
99 未知 Unknown 未知

其中天气码对应的图片和建议图片可用如下规则拼装:

var codeImg = `//weixin.jirengu.com/images/weather/code/${data.weather[0].now.code}.png`
var suggestionImg = `//weixin.jirengu.com/images/weather/suggestion/${data.weather[0].today.suggestion.dressing}.png`

获取当前城市24小时天气

  • 接口: http(s)://weixin.jirengu.com/weather/future24h
  • 请求类型: GET
  • 请求参数:
    • key: 加微信 hungervalley 咨询
    • location: 可选参数,如果没有设置则获取当前用户所在城市24小时的天气。如果设置了则是设置城市的天气,如 beijing杭州南京市
    • 范例1:http://weixin.jirengu.com/weather/future24h?key=你的key
    • 范例2:http://weixin.jirengu.com/weather/future24h?location=hangzhou&key=你的key
  • 支持 cors
  • 返回数据:
{
    "status":"OK",
    "hourly":[
    {
        "text":"阵雨",
        "code":"10",
        "temperature":"27",
        "time":"2018-04-02T17:00:00+08:00"
    },
    {
        "text":"阵雨",
        "code":"10",
        "temperature":"26",
        "time":"2018-04-02T18:00:00+08:00"
    },
    ...
    ]}

天气API(老接口)

老接口不需要 key

获取当前用户城市

  • 接口: http://api.jirengu.com/city.php
  • 请求类型: GET
  • 请求参数:
  • 支持cors, 支持jsonp

使用范例:

范例1

http://api.jirengu.com/city.php

http://api.jirengu.com/city.php?callback=getCity

获取天气简略接口

  • 接口: http://api.jirengu.com/getWeather.php
  • 请求类型: GET
  • 请求参数:
    • city: 城市名; 此参数为空获取的是当前用户所在城市的天气
  • 支持cors, 支持jsonp

使用范例:

范例1

http://api.jirengu.com/getWeather.php

http://api.jirengu.com/getWeather.php?callback=getWeather

范例2

http://api.jirengu.com/getWeather.php?city=北京

文章爬取工具

用于把用markdown编辑器编辑的线上文章转换成 markdown 源码

地址: http://html2md.jscode.me/

把线上 markdown 地址转化成在线 PPT

地址: http://md2ppt.jscode.me/

API版权归饥人谷所有,仅供学习交流使用,转载自http://api.jirengu.com/

猜你喜欢

转载自blog.csdn.net/doecy/article/details/81202042
今日推荐