Custom Post Type an Real Time External API Data


I’m wondering how should I proceed with this request I just had.

My client want to have real-time data from an in house API on their website.

What I would usually do, is to set up a cron to sync the content each 5 minutes. They do NOT want to have duplicate content on the website. There’s thousand of entries.


I know I can create custom WordPress route with this hook : rewrite\_rules\_array. On those page, I can fetch and display the data, but it will be slower. I would also have to hook on WordPress sitemap to include those “fake post”.

Another solution would be to import minimal content, and fetch real time data when the page load (with ajax for example).


Anybody had to do something similar? What did you choose?



1 Comment
  1. I work with many APIs all the time in WordPress. You best bet is to ingest the API’s content and store it in a transient. That will help with the slowness, as you can then hit the cache (transient) instead of the API endpoint. This will also help with rate-limiting as the transient will be ‘hit’ before the the API endpoint is. My go to time limit is 24 hours, but you can set the transient time out to be less than that (it’s in seconds). I don’t know how time sensitive this data needs to be. (Refreshed ever hour? minute? day?).


This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer