0

I have a WordPress site and I should read data from an external source to populate parts of the various pages. I can choose whether to have the external data in an xml or via rest api. The xml will have is around 150k. I believe that the best practice in this type of situation is to use the rest api to receive the data because an xml is heavier to read than an api.

Does my reasoning seem correct to you? Is it always better to use an API than an xml to read data from an external source? Or is it still a better solution to read the data from an xml every 12 hours and update the WordPress pages so that they are available as a normal page call without resorting to external calls?

Thank you

4
  • To pick up Michael's question: by REST API do you mean returning JSON?
    – Rup
    Dec 21, 2023 at 15:29
  • And do you mean fetching from the API for every page load? You'd want to cache that, depending on load.
    – Rup
    Dec 21, 2023 at 15:30
  • Honestly I wouldn't worry about the effort of parsing the XML though. The question is really if you want to want to use the 12-hour data feed or not.
    – Rup
    Dec 21, 2023 at 15:31
  • I meant a static xml file compared to a json response from a rest-api. sorry for the inaccuracy Dec 21, 2023 at 18:24

1 Answer 1

0

Your question seems like a false dichotomy. If you use a REST API to access the data, it has to be returned in some format, and that format will often be XML.

1
  • I meant a static xml file compared to a json response from a rest-api. sorry for the inaccuracy Dec 21, 2023 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.