Probably to increase $max_rank
$max_rank = ? ;
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi to all!
I get results from an API but they have a limit of 100 results for each request. How can i take more than that?
This is my code (from a video of @bobbybouwmann)
class TrialsApiService
{
public function fullStudies(): Collection
{
$client = new Client();
$min_rank = 1;
$max_rank = 100;
$response = $client->get("https://clinicaltrials.gov/api/query/full_studies?min_rnk=$min_rank&max_rnk=$max_rank&fmt=json");
$body = json_decode((string)$response->getBody(), true);
$collection = collect($body['FullStudiesResponse']['FullStudies'])->map(function ($fullStudies) {
return [
'Rank' => $fullStudies['Rank'],
'Status' => $fullStudies['Study']['ProtocolSection']['StatusModule']['OverallStatus'],
'Condition' => $fullStudies['Study']['ProtocolSection']['ConditionsModule']['ConditionList']['Condition'][0],
'NCTId' => $fullStudies['Study']['ProtocolSection']['IdentificationModule']['NCTId'],
'Organization' => $fullStudies['Study']['ProtocolSection']['IdentificationModule']['Organization']['OrgFullName'],
'Title' => $fullStudies['Study']['ProtocolSection']['IdentificationModule']['BriefTitle'],
'Sponsor' => $fullStudies['Study']['ProtocolSection']['SponsorCollaboratorsModule']['LeadSponsor']['LeadSponsorName']
];
});
return $collection;
}
}
No problem @maracaibo
Sorry, there was an error on the line that merges de collections.
Instead of: $studies->merge($collection);
It should be: $studies = $studies->merge($collection);
I've updated the original answer.
All the best.
Please or to participate in this conversation.