API
- Introduction
Agrisk-tools Data query API
-
We provide API to help you access to data programmatically without visit this website.
The basic structure of an API call is "http://www.agrisk-bigdata.com/product/download?" with SQL string as the parameter. This url return data in CSV format.
Get (CSV):
“http://www.agrisk-bigdata.com/product/download?province=1&nameEn=smallpig&ymStart=2000-01&ymEnd=2012-01&type=csv”
For information on data sets and their meta data. Check our data query table as follows:
| Province codes | to | Chinese | English |
| 1 | => | 北京 | Beijing |
| 2 | => | 天津 | Tianjing |
| 3 | => | 河北 | Hebei |
| 4 | => | 山西 | Shanxi |
| 5 | => | 辽宁 | Liaoning |
| 6 | => | 吉林 | Jiling |
| 7 | => | 上海 | Shanghai |
| 8 | => | 江苏 | Jiangsu |
| 9 | => | 浙江 | Zhejiang |
| 10 | => | 安徽 | Anhui |
| 11 | => | 福建 | Fujian |
| 12 | => | 江西 | Jiangxi |
| 13 | => | 山东 | Shandong |
| 14 | => | 河南 | Henan |
| 15 | => | 内蒙古 | Neimenggu |
| 16 | => | 黑龙江 | Helongjiang |
| 17 | => | 湖北 | Hubei |
| 18 | => | 湖南 | Hunan |
| 19 | => | 广东 | Guangdong |
| 20 | => | 广西 | Guangxi |
| 21 | => | 海南 | Hainan |
| 22 | => | 四川 | Sichuan |
| 23 | => | 重庆 | Chongqing |
| 24 | => | 贵州 | Guizhou |
| 25 | => | 云南 | Yunnan |
| 26 | => | 西藏 | Xizang |
| 27 | => | 陕西 | Shaanxi |
| 28 | => | 甘肃 | Gansu |
| 29 | => | 青海 | Qinghai |
| 30 | => | 宁夏 | Ningxia |
| 31 | => | 新疆 | xinjiang |
| Livestock codes | to | Chinese | English |
| smallpig | => | 仔猪 | Piglet |
| livepig | => | 生猪 | Hog |
| pork | => | 去皮带骨猪肉 | Pork |
| beef | => | 去骨牛肉 | Beef |
| mutton | => | 带骨羊肉 | Mutton |
| smallmeatch | => | 肉用雏鸡 | Meat chicks |
| livech | => | 活鸡 | Live chicken |
| westch | => | 白条鸡 | Chicken |
| smalleggch | => | 蛋用雏鸡 | Egg chicks |
| egg | => | 鸡蛋 | Egg |
| corn | => | 玉米 | Corn |
| bean | => | 豆粕 | Soybean meal |
| whear | => | 小麦麸 | Wheat bran |
| pigfeed | => | 育肥猪配合饲料 | Compound piglet feed |
| meatchfeed | => | 肉鸡配合饲料 | Compound meat chicks feed |
| eggchfeed | => | 蛋鸡配合饲料 | Compound egg chicks feed |
| wool | => | 绵羊毛 | Sheep wool |
| pigfood | => | 猪粮比 | Hog-corn ratio |
| fish | => | 鱼粉 | Fish meal |
Type :
csv return to csv format
json return to json format
R Sample Code
1. With regard to csv format,that is type=csv, you can get the data as this:
> url <- "http://www.agrisk-bigdata.com/product/download?province=1&nameEn=smallpig&ymStart=2000-01&ymEnd=2012-01&type=csv"
> read.csv(url, header = FALSE, sep = ",",quote="\"", dec=".", fill = TRUE, comment.char="")
2. With regard to json format, that is type=json, you can get the data as this:
Install packages "httr"
Install packages "RJSONIO"
> library(httr)
> url <- "http://www.agrisk-bigdata.com/product/download?province=1&nameEn=smallpig&ymStart=2000> 1&ymEnd=2012-01&type=json"
> response <- GET(url)
> content = content(response, "text")
> library(RJSONIO)
> romJSON(content)
Matlab Sample Code
Use Matlab's new webread() function to query Agrisk-tools.
data = webread("http://www.agrisk-bigdata.com/product/download?province=1&nameEn=smallpig&ymStart=2000-01&ymEnd=2012-01&type=csv")