RIS JSON API内容压缩
我正在尝试使用德国铁路的RIS API。我设法在似乎是JSON的时间表上使用了一个。 https://developers.deutschebahn.com/db-api-marketplace/apis/product/fahrplan/api/9213#/Fahrplan_101/operation/%2Flocation%2F{name}/get
GET https://apis.deutschebahn.com/db-api-marketplace/apis/fahrplan/v1/location/Berlin
Header:
Accept: application/json
DB-Client-Id: 36fd91806420e2e937a599478a557e06
DB-Api-Key: d8a52f0f66184d80bdbd3a4a30c0cc33
Which using httr
我可以复制:
url_location<-"https://apis.deutschebahn.com/db-api-marketplace/apis/fahrplan/v1/location/Bonn"
r<-GET(url_location,
add_headers(Accept="application/json",
`DB-Client-Id` = client_id,
`DB-Api-Key` = api_key))
content(r)
GET https://apis.deutschebahn.com/db-api-marketplace/apis/ris-stations/v1/stations?onlyActive=true&limit=100
Header:
Accept: application/vnd.de.db.ris+json
DB-Client-Id: 36fd91806420e2e937a599478a557e06
DB-Api-Key: d8a52f0f66184d80bdbd3a4a30c0cc33
我希望我希望这样做只需调整接受
:
url_station<-"https://apis.deutschebahn.com/db-api-marketplace/apis/ris-stations/v1/stations?onlyActive=true&limit=100"
r_stations<-GET(url_station,
add_headers(Accept="application/vnd.de.db.ris+json",
`DB-Client-Id` = client_id,
`DB-Api-Key` = api_key))
我收到一些数据,状态代码为200
。 content
函数或没有它,我得到以下内容
> head(content(r_stations), 30)
[1] 7b 22 6f 66 66 73 65 74 22 3a 30 2c 22 6c 69 6d 69 74 22 3a 31 30 30 2c 22 74 6f 74 61 6c
r_stations$status_code
[1] 200
,我应该得到更多这样的东西:
{
"offset": 0,
"limit": 100,
"total": 5691,
"stations": [
{
"stationID": "1",
"names": {
"DE": {
"name": "Aachen Hbf"
}
},
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我只需要添加
type ='application/json'
I just need to add
type='application/json'