Into The Box Notes: ContentBox API Unleashed, Gavin Pickin
API is the big buzzword these days
can use ContentBox API to get data in/out of your site
internally in your content box app
Features you may not know —
not a rest API but is accessible from layouts and views
if you want to get a ContentStore item to display on a page:
cb.ContentStore( slug=“”, defaultValue=“” );
theme settings: cb.themeSetting( key, value ) & cb.themeRoot()
— maybe building a custom module but want to grab the site logo, site branded colors, etc.
module settings: cb.getModuleSettings( module ) & getmoduleConfig()
— cb settings can all be env based, different for staging and dev tiers
- can use this to grab those.
kind of a “god object” to get to most everything in the site
see also: siteRoot(), siteBaseURL() getHomepage() get SiteName() getSiteTagine(), etc
File extensions automatically render your data
if you put http://sitename/somePage.xml
- renders as xml
- renders as json
any rendered data format that ContentBox supports will work this way.
can use it to run Docker sites to try out different Docker images and play w/ them.
Interesting! — Don’t even need the /admin on the prod server. Can just have it on a dev laptop and it will update the changes on the prod server as needed.
CORS - Extended API Feature
to get around the ajax/origin security issues.
if you have an API and want to lock it down, you need some sort of token system
“API Token” - extended API feature
will generate tokens for developers.
can be used for granular security
users in the site will get tokens too
every user can reset their api token as well
user sw/ the right permissions can reset other tokens (managers can reset for their employees, etc)
chose the cache provider via a setting:
real simple, flexible caching
hit count, plus
how to extend the stats/
build an interface and allow for providers
can code your own stat collection (for your own modules, for example) and stat rendering
and Kibana for Rendering
basic info - created/updated date
API token and client name
IP address, user agent, etc.
and other things
- aggregate it daily