0
Under review

feed API content to a content block?

ksmithyhr 3 months ago in BLOX CMS updated 3 months ago 3

I am working on a data table component first for our Sports section, then hopefully as a reusable Block for the site. With permission I'm going to scrape some data from a regional sports stats/schedules website to feed into this table. I imagine the table needs to be updated once a day or as changes are published. I want to create a public JSON API with the scraped data. Has anyone used BLOX webservices or macros or anything within the BLOX CMS to do something like this? 

+1
Under review

Generally for these types of things you'll need some sort of "middleware" that will do the actual scraping and storage of data. That could be done with an external hosted webserver where you have your own code running that does the scraping and storage that then provides an endpoint that your frontend javascript can use to access the data. An alternative is the /app environment in Blox (https://www.help.bloxdigital.com/developers_corner/app---the-blox-open-development-environment/article_200bdd00-89ab-53f6-b8a5-a8e076441f3a.html)


Your front-end JS would do a fetch to this middleware and either just get all data back, or maybe pass parameters like sport and then get a curated set of data back which would then be used to populate your data tables.


At least that's how I did similar things before I came to work at Blox Digital :)

Joe Hansen
Director of Solutions Support

Blox Digital

hi again Joe! thank you for your answer. I have a good idea on how to set up the middleware - I think I was just confused on where/how BLOX could communicate to the endpoint I set up. If /app is where that will fit best, I will try that first! :-)

and I'll post here as a follow up with how it goes in case this helps anybody else