Trax Platform APIv1

Website content

Organizations write their website's own content in the organization site: the profile, locations, services, weekly schedules, organization content (impact numbers, outcomes, quotes, values, age pathways), sponsorship options, staff, blog and news posts, announcements and alerts. These endpoints serve it to the website, Duda or nFocus site. They are public, like the catalog. The publishable site key is optional.

Only what is live now is returned:

Drafts, scheduled items and ended items never appear.

Capabilities. An organization (or nFocus) can turn a kind of content off. Its reads then answer 404 capability-off with capability (for example website.staffDirectory on /staff), answers that mix kinds leave it out, and the Duda collection feeds answer an empty list. GET P/config lists what is on (capabilities).

Caching

Every answer here carries Cache-Control: public, max-age=60, stale-while-revalidate=300 and a strong ETag. Send the ETag back in If-None-Match and an unchanged answer is 304 Not Modified with no body. A change shows within about a minute. Preview answers (?preview=) are no-store.

The site

The profile merges Trax and the organization site. Each field shows what the organization set in the organization site, and otherwise its Trax record (name, address, phone, email). Hours, social links, tagline, About text and images come from the organization site only.

The website profile

GET https://api.nfocus.solutions/v1/portals/riverbend/north/site → 200 OK, JSON

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/north/site'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/site');
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.nfocus.solutions/v1/portals/riverbend/north/site");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

logo is the site's own logo, if it has one. traxLogoUrl is the portal's logo from Trax, for sites that don't set their own.

Posts

Blog and news posts, newest first. Filter with kind=blog or kind=news, and with a tag.

Latest news

GET https://api.nfocus.solutions/v1/portals/riverbend/north/posts?kind=news&pageSize=5 → 200 OK, JSON

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/north/posts?kind=news&pageSize=5'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/posts?kind=news&pageSize=5');
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.nfocus.solutions/v1/portals/riverbend/north/posts?kind=news&pageSize=5");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

Open one post by its slug. bodyHtml is safe to insert as HTML: it was cleaned when it was saved. Every other text field is plain text, so encode it when you display it.

One post

GET https://api.nfocus.solutions/v1/portals/riverbend/north/posts/welcome-to-our-new-website → 200 OK, JSON

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/north/posts/welcome-to-our-new-website'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/posts/welcome-to-our-new-website');
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.nfocus.solutions/v1/portals/riverbend/north/posts/welcome-to-our-new-website");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

Videos in a post: <figure data-trax-video="{id}"></figure> places a video. The post's videos lists the published ones it places, in that order: draw each in place (see "Videos").

Staff can share a preview link from the organization site. It opens a draft through this endpoint for one hour. The response then has preview: true, Cache-Control: no-store and X-Robots-Tag: noindex.

Staff

The staff directory follows the site's own order. Email addresses and phone numbers appear only when the site chose to show them.

Locations

GET …/locations lists the site's locations in its order (GET …/site has them too, with each one's slug).

A site's locations

GET https://api.nfocus.solutions/v1/portals/riverbend/central/locations → 200 OK, JSON

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/central/locations'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/central/locations');
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.nfocus.solutions/v1/portals/riverbend/central/locations");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

GET …/locations/{slug} is one location's page: the location, its weekly schedule, its own content (and sponsorships) and jsonLd, a schema.org Place with its address, map position, opening hours and special hours. Insert the JSON-LD unchanged in a <script type="application/ld+json"> element, escaping < as \u003c (it holds text staff typed).

One location's page

GET https://api.nfocus.solutions/v1/portals/riverbend/central/locations/riverbend-teen-center → 200 OK, JSON

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/central/locations/riverbend-teen-center'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/central/locations/riverbend-teen-center');
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.nfocus.solutions/v1/portals/riverbend/central/locations/riverbend-teen-center");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

Services

GET …/services lists the published service categories, each with its published services, in the site's order. Each service names the locations that offer it (locationSlugs, for a filter by service) and where it leads (link: catalog activities, a program, or a url). Services without a published category are in uncategorized.

Services by category

GET https://api.nfocus.solutions/v1/portals/riverbend/central/services → 200 OK, JSON

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/central/services'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/central/services');
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.nfocus.solutions/v1/portals/riverbend/central/services");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

Weekly schedules

GET …/schedules is the site's own weekly schedule (a youth center's typical week), and ?location={slug} a location's (its worship times, say). Entries come Monday to Sunday, by start time. One entry is one occurrence: a class at 5:30 PM and 7:00 PM is two entries, so group them by title and day. An entry linked to an outcome area carries its accent (a colour name), for a calendar's colour key.

A location's weekly schedule

GET https://api.nfocus.solutions/v1/portals/riverbend/central/schedules?location=riverbend-teen-center → 200 OK, JSON

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/central/schedules?location=riverbend-teen-center'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/central/schedules?location=riverbend-teen-center');
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.nfocus.solutions/v1/portals/riverbend/central/schedules?location=riverbend-teen-center");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

Organization content

GET …/content returns the site's impact numbers, outcomes, quotes, values, age pathways and sponsorship options, each in the site's order; ?kind= one kind (impact-numbers, outcomes, quotes, values, pathways, sponsorships); ?location={slug} a location's own instead of the site's.

Outcome statements

GET https://api.nfocus.solutions/v1/portals/riverbend/central/content?kind=outcomes → 200 OK, JSON

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/central/content?kind=outcomes'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/central/content?kind=outcomes');
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.nfocus.solutions/v1/portals/riverbend/central/content?kind=outcomes");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

An outcome may list what is measured (measures), the programs that build it (programs) and an accent; an impact number its sourceTitle and sourceNote. Accents are names (teal, amber, green, red, blue, purple, pink, slate): the template chooses the shades.

Videos

GET …/videos lists the site's published YouTube and Vimeo videos in its order (?location={slug} a location's own); GET …/videos/{id} one of them.

The site's published videos

GET https://api.nfocus.solutions/v1/portals/riverbend/central/videos → 200 OK, JSON

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/central/videos'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/central/videos');
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.nfocus.solutions/v1/portals/riverbend/central/videos");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

Contacts

GET …/contacts lists who to contact, in the site's order: name, role, phone and email (?location={slug} a location's own). Only published contacts the organization marked public are listed.

Who to contact

GET https://api.nfocus.solutions/v1/portals/riverbend/central/contacts → 200 OK, JSON

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/central/contacts'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/central/contacts');
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.nfocus.solutions/v1/portals/riverbend/central/contacts");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

Sitemap

An nFocus site's GET …/site/sitemap lists every public path (its template's pages and each location's page) with when it last changed and its full address at the primary domain. Write sitemap.xml from it at the site's own domain. A Duda site answers 404 website-not-found.

An nFocus site's sitemap

GET https://api.nfocus.solutions/v1/portals/riverbend/central/site/sitemap → 200 OK, JSON

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/central/site/sitemap'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/central/site/sitemap');
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.nfocus.solutions/v1/portals/riverbend/central/site/sitemap");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

Announcements and alerts

Announcements are a dated list, with pinned items first. Alerts are for a site-wide banner, most severe first: urgent, then warning, then info. Show the dismiss control only when dismissible is true.

Alerts showing now

GET https://api.nfocus.solutions/v1/portals/riverbend/north/alerts → 200 OK, JSON

curl
curl -s 'https://api.nfocus.solutions/v1/portals/riverbend/north/alerts'
JavaScript
const response = await fetch('https://api.nfocus.solutions/v1/portals/riverbend/north/alerts');
const data = await response.json();
C#
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.nfocus.solutions/v1/portals/riverbend/north/alerts");
using var response = await http.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();

Images

Images are served from GET …/media/{id}. They are re-encoded when uploaded (no camera or location data) and never change, so they can be cached for a year. Every image has altText: use it.