Software Development, Web Design, Training

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
externally
mobile app
web hooks,
etc

Features you may not know —

CBHelper
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
somePage.json
- renders as json

any rendered data format that ContentBox supports will work this way.

labs.play-with-docker.com
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.

API Tokens
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)

Caching -
chose the cache provider via a setting:
cb_api_cacheName
real simple, flexible caching

API stats
hit count, plus
granular stats
searchable
reportable
configurable
extendable

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
ElasticSearch Adapter
and Kibana for Rendering


GranularStats -
basic info - created/updated date
routed URL
API token and client name
IP address, user agent, etc.
and other things

GlobalStats
- aggregate it daily

lots more.

Comments

Post a Comment