Api请求JSON性能缓慢


Api request JSON slow preformance

嗨,我正在为一个名为"生命百科全书"的物种数据库调用api。我最初调用了一个名为search的方法,它可以呈现30个结果(我像下面这样调用该方法),但对于30个结果,我调用了这个方法,它会为每个结果提供信息,所以我基本上对30个结果调用这个方法,而且速度非常慢。你有什么建议可以让这些api调用更快?谢谢

$jsonurls = 'http://eol.org/api/pages/1.0/'.$id.'.json?images=2&videos=0&sounds=0&maps=0&text=2&iucn=false&subjects=overview&licenses=all&details=true&common_names=true&synonyms=true&references=true';
$jsons = file_get_contents($jsonurls,0,null,null);
$responsetaxObjects = json_decode($jsons);
//then I run through the object array like this
foreach($responsetaxObjects->taxonConcepts as $sources){
}

您是否尝试指定标头

Accept-Encoding: gzip

这将以压缩形式返回结果,这可能会为您节省一些连线时间。不幸的是,他们的API似乎没有提供获取所有搜索结果的全部详细信息的方法,所以在减少往返次数方面,你看起来运气不佳。它们还有一个缓存设置,如果你最终要多次访问相同的页面,你可以使用它。