Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Make multiple API calls and get result to show on a special page WordPress



what I would like to do is this:

With a custom Wordpress plugin, make external API calls to get specific information for a user and show it on a my-account page by using a custom short code.


- First I need to make a GET request to api endpoint 01 to get a list of projects. Each project has an ID.

- With the project ID taken from the first request I can make another GET request to get the campaign ID

- With the last call I will take the campaign ID and do a GET request to get a list of posts. the output is al JSON format.

And I don't know how to get a value of another request the right way... And when making multiple api calls I get the error to many api calls in 1 second.


What I did was save the project ID and campaign ID in every user account on my Wordpress website. So it won't need to make those first extra calls. But I need to add the project ID and Campaign ID manually which should be an automated process? I save this information by using the ACF plugin and go to a specific user profile and save the ID's in it.

Also I can only make 1 api call in 1 second. so every second I can make 1 call.

Hope you understand what I'm trying to do :)


PS: The API can be found here:

So need to use the following endpoints? projects.svc -> publications.svc -> publicationDetail.svc

Answers (3)


Reigel Gallarde answers:

Do you have this API now or do you have a link?

User179949 comments:

The API can be found here:


Arnav Joy answers:

Which API you are using ?

User179949 comments:

The API can be found here:


User179955 answers:

Have a look at this below links..

You've got several ways to do so (from easiest/dirtiest to nicest/more complex):

for every api endpoint make a function (for esthetics and simplicity, I do recommend you to make a second functions file (xxx_api_functions.php) and include it from the header.php of your theme, or from the functions.php itself. Then you can (re-)use these functions on all occasions you need.
If point 1 makes you a too big file, you can extend this solution and make a small framework, a package of classes, to be integrated from within the theme. As a mix between functions and a own plugin, and if the API is complex or you want to write some reusable logic, you can create some php classes (and evtl. an autoloader) to use them in your theme in a separate folder as a package (set of classes related to that API). I made this approach several times to avoid having to deal with all the additional plugin-complexity.
Use the classes from 2 and make a plugin which makes it easier for you to reuse the code. (although method 2 makes reutilization already quite simple), but you get the advantage that you'll have a solution which is theme independent.
PD: Development starts depending on the expected complexity... if you already know, that you'll need several functions and files to do that task, begin by planning alternative two. if you don't know yet, start with 1 but be ready to expand to solution 2 as soon as you notice that the code will be better manageable by using approach 2. I suggest planning the plugin once you already implemented all the code and classes, as an additional step once everything's done.


1) include in the header.php a

2) create the xxx_api_functions.php

3) in the xxx_api_functions.php create a

function getProjects($param1, $param2){

//code to call the api (curl)

//code to parse the json

//code to produce the html output

4) and then, in the place where you want to display the projects:

echo getProjects($param1,$param2);