API Source
An API Source pulls from a third-party REST API and feeds the responses onto your surface like any other connection - no custom code. It polls on a schedule, or only when you press Pull Now.
Add one
Drag an API Source node onto the canvas (or ask Thinky: "poll the GitHub stars API every minute") and open the Inspector. Wire the node to a connection: a poll's response is forwarded to the connection that points at the source.
Configure
The Inspector has three tabs.
Settings
| Setting | What it does |
|---|---|
| Name | A label for the source |
| Endpoint | The URL to poll |
| Method | GET (default) or POST |
Polling
| Setting | What it does |
|---|---|
| Polling Interval (ms) | How often to poll, in milliseconds. The field's minimum is 1000. Leave it empty for manual only |
| Pause Polling | Shown only when an interval is set. See Pausing |
| Pull Now | Shown only when no interval is set. See Pull Now |
| Response Mapping | A path into the response, such as $.data.items, to pull the data out |
| Custom Headers | Any request headers, as name and value pairs (+ Add Header) |
Response Mapping follows dots only: $.data.items, or data.items without the $.. A number in the path picks
an item of a list ($.results.0). Filters, wildcards and other JSONPath operators are not supported. With no
mapping, the whole response is forwarded.
Auth
| Authentication type | Fields you fill in |
|---|---|
| None | Nothing; the endpoint is called without credentials |
| Bearer Token | Token |
| API Key | Key Name (the header it is sent in) and Key Value |
| Basic Auth | Username and Password |
A public API needs no auth. An API key is sent in a header; there is no option to send it in the query string.
What the endpoint must be
A poll fetches only an address OpenX can treat as public:
- The address uses
https, has no user name or password in it, and names a public host.localhost, private or internal addresses and single-word host names are refused. - The answer is JSON. A reply that is not JSON is a failure; nothing from it is shown.
- A redirect is not followed; a
3xxanswer is a failure. - A poll makes one request. If the API pages its results, only the first page is read.
- A pull by hand that takes longer than 15 seconds is a failure.
A refused address shows up like any other failed poll, with a code that starts OUTBOUND_ (for example
OUTBOUND_HOST_NOT_PUBLIC).
Scheduled or manual
| Mode | When to use it | How it works |
|---|---|---|
| Scheduled | Ongoing feeds | Set an interval, Save, then Deploy. Deploy creates an Azure Function that polls on that schedule |
| Manual | Testing, one-off pulls | Leave the interval empty. A source with no interval makes no Azure Function; press Pull Now when you want data |
Scheduled polling starts only after a Deploy has finished. Until then nothing polls.
Pull Now
With no interval set, Pull Now is on the Polling tab and on the expanded node. One press runs one poll: it calls the endpoint with your method, headers and auth, applies the Response Mapping, and forwards the result to the connection that points at the source. The button reads Pulling... while it runs, then Pull Succeeded or Pull Failed for a few seconds, and the node's numbers refresh either way.
The answer to a pull is success, data (the mapped result), rawResponse, latencyMs, error and
forwarded (whether a connection received it). A pull counts as failed when the source answers with an error
status, or when the source answers but its data does not reach the connection:
The source answered, but its data did not reach data connection 'line-3-sensors': ...
For an IoT Hub connection whose device is not on the hub yet, the reason reads that the connection has no device on its IoT hub yet, and to deploy the workspace and pull again.
A source with an interval has no Pull Now button. The pull is also a route you can call yourself, from code: see API Sources: Pull Now in the REST API reference. In the API Manager, the API Sources tab shows each source's route with a cURL and a TypeScript snippet.
When a poll fails
When a poll fails, by hand or on the schedule, the node and the Live Stream both show it.
The node turns red when:
- the latest failed poll is newer than the latest successful one, or
- a failure entry has just arrived in the Live Stream. The node flashes red for a few seconds, even before the node's numbers refresh.
It returns to normal when a poll succeeds. A success entry in the Live Stream clears the red at once; it does not wait for the numbers to refresh. For a scheduled source, that means within one interval of the API recovering.
A failure is a red entry in the Live Stream, headed by the source's name, with the context line API Source error: <name> · forwards to <connection> and a payload of:
| Field | What it holds |
|---|---|
Error | The reason, such as HTTP 503: Service Unavailable or an OUTBOUND_ code |
Endpoint | The address that was polled, without any user name, query string or fragment |
StatusCode | The HTTP status, when the API answered |
LatencyMs | How long the poll took |
The node also shows a count of errors, such as 3 errors.
Pausing polling
Pause a source to stop its Live Stream entries and take its Azure Function down at the next Deploy, without losing the interval, headers, auth or anything else. Resuming brings the schedule back unchanged.
- Open the Inspector and the Polling tab.
- Press Pause Polling. It is shown only when an interval is set; a manual-only source has nothing to pause.
| Part | While paused |
|---|---|
| Live Stream | Entries from before the pause stay. Entries that arrive after it are hidden |
| Node color | New live failure and success signals are ignored, so the node does not flash. A node that was red when you paused stays red: its color still follows the last recorded poll |
| Azure Function | Still running until you Save and Deploy. Then it is deleted |
To resume, press Resume Polling in the same place, then Save and Deploy. The function is created again with the saved interval.
The enable switch in the Inspector header does the same: turning the node off pauses it, and turning it back on resumes it. The button still works between switches.
Paused is not manual. A manual source has no interval and is pulled by hand; a paused one keeps its interval so a resume and Deploy restore the schedule.
Reading the Live Stream
Each poll that fails is one red entry. A poll that succeeds does not add an entry from the source itself: the data it forwarded shows as an entry of the connection that received it.
| Outcome | Entry from | Color | Holds |
|---|---|---|---|
| Success | The connection | Normal | The polled data |
| Failure | The API Source | Red | Error, Endpoint, StatusCode, LatencyMs |
The Live Stream's Clear button empties it. The clear is remembered in your browser for that workspace, so refreshing the page keeps it empty until new entries arrive. It applies to your browser only: another person, or the same person in another browser, still sees the older entries.
Verify
After the first poll, open the Live Stream: a red entry means the poll failed, and the connection's entry holds the data when it worked. Wire the connection to a Surface, and the responses flow through like any feed.
Then
Crystallize a Warm Query over it. Want to feed data from your own service or a database instead of polling? That push-ingest path is on the roadmap - for now, expose it as an API the source can poll. If a poll does not behave, see API Sources troubleshooting.
On fathym.com: OpenX →