Trello API: receive participants, attachments and card information in one call?

I can get data from the Trello API using this:

private function get_card_info($card_id) { $client = new \GuzzleHttp\Client(); $base = $this->endpoint . $card_id; $params = "?key=" . $this->api_key . "&token=" . $this->token; $cardURL = $base . $params; $membersURL = $base . "/members" . $params; $attachmentsURL = $base . "/attachments" . $params; $response = $client->get($cardURL); $this->card_info['card'] = json_decode($response->getBody()->getContents()); $response = $client->get($membersURL); $this->card_info['members'] = json_decode($response->getBody()->getContents()); $response = $client->get($attachmentsURL); $this->card_info['attachments'] = json_decode($response->getBody()->getContents()); } 

However, this is broken into three challenges. Is there a way to get card information, member information and investment information in just one call? The docs mention the use of &fields=name,id , but this only limits what returns from the base call to the cards endpoint.

It is absurd that every time I need information about a card, I have to apply the API 3 times, but I can not find examples that collect everything that is needed.

+6
source share
2 answers

Trello answered me and said that they would answer in the same way as Vladimir. However, the only answer I received from this was the original map data, without attachments and members. However, they also directed me to this blog post , which covers batch processing requests. Apparently, they removed it from the documents due to the confusion that he created.

To summarize the changes, you essentially make a /batch call and add the urls GET option using a list of endpoints separated by commas. The working final version looked like this:

 private function get_card_info($card_id) { $client = new \GuzzleHttp\Client(); $params = "&key=" . $this->api_key . "&token=" . $this->token; $cardURL = "/cards/" . $card_id; $members = "/cards/" . $card_id . "/members"; $attachmentsURL = "/cards/" . $card_id . "/attachments"; $urls = $this->endpoint . implode(',', [$cardURL, $members, $attachmentsURL]) . $params; $response = $client->get($urls); $this->card = json_decode($response->getBody()->getContents(), true); } 
+4
source

Try using the API with the following parameters:

/cards/[id]?fields=name,idList&members=true&member_fields=all&& attachments=true&&attachment_fields=all

+5
source

All Articles