About us Bulletin Data Query API
Comments Research Blog Sign in 中文

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 codestoChineseEnglish
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 codestoChineseEnglish
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")