Wednesday, September 16, 2026

What Should a Website Gadget Display When an External API or Online Service Temporarily Stops Working?

 

A website gadget that depends on an external API or online service is only as reliable as the systems behind it. Exchange rates may come from a financial API. Weather information may come from a weather service. Product prices may come from an affiliate or e-commerce API. Maps may depend on a mapping provider. Payment buttons may depend on a payment gateway.

Most of the time, these services work normally.

But eventually, something will go wrong.

The API may be temporarily unavailable. The provider may be experiencing an outage. A request may take too long. The API may return an error. A rate limit may be reached. An authentication token may expire. Internet connectivity may be poor. Or the provider may return incomplete or outdated information.

The important question is therefore not:

"What happens if the API fails?"

The better question is:

"What should the visitor see when the API fails?"

A professionally designed gadget should already have an answer.

An API Failure Should Not Become a Website Failure

One of the most important principles in gadget development is this:

An external service should be allowed to fail without taking the entire gadget—or website—down with it.

Suppose a website has a currency-conversion gadget.

A visitor enters:

100 USD → KES

The gadget normally contacts a currency API and displays the current conversion.

If the API suddenly becomes unavailable, a poorly designed gadget might show:

Error 500

or:

undefined

or:

NaN

or simply leave the visitor staring at a blank box.

That creates confusion and makes the gadget look broken.

A better gadget might display:

Exchange rates are temporarily unavailable. Please try again in a moment.

The rest of the website continues working normally.

This is the difference between an application that merely works under perfect conditions and one that has been designed for real-world use.

The Gadget Should Know the Difference Between Loading, Failure and Stale Data

One common mistake is treating every situation as either "working" or "not working."

In reality, a gadget can be in several different states.

For example:

  1. Loading

  2. Successfully loaded

  3. Temporarily unavailable

  4. Timed out

  5. Rate limited

  6. Authentication failure

  7. Stale data available

  8. No data available

  9. Service recovered

These states should not necessarily produce the same message.

1. Loading

When the visitor first opens the gadget, the request may simply be in progress.

The gadget could display:

Loading current exchange rates…

A small loading indicator can be useful.

The visitor should not immediately be told that the service is unavailable simply because the response has not arrived yet.

2. Successfully Loaded

When the API responds normally, display the requested information.

For example:

1 USD = 129.40 KES
Updated 2 minutes ago

The exact information depends on the API and the gadget.

3. Temporarily Unavailable

If the service cannot be reached, the gadget should explain the problem in simple language.

For example:

Live data is temporarily unavailable. Please try again shortly.

This is usually much better than displaying technical error codes to ordinary visitors.

What If the Gadget Has Previously Retrieved the Information?

This is where caching becomes extremely valuable.

Suppose a weather gadget retrieves weather information at 10:00 AM.

At 10:03 AM, the weather API stops responding.

Does the gadget necessarily need to show an empty screen?

Not necessarily.

If the gadget has a valid recent copy of the information, it may be able to display the previous data while clearly identifying it as stale.

For example:

24°C — Nairobi
Last updated 3 minutes ago
Live update temporarily unavailable.

This is much more useful than pretending that the 3-minute-old information is current.

The critical rule is:

Never present old information as if it were live information.

The gadget should tell the visitor when the information was last successfully updated whenever freshness matters.

Stale Data Can Be Better Than No Data—But Only for Certain Information

Whether stale information should be displayed depends on the type of data.

Consider weather.

A few minutes of old information might still be useful.

Now consider a payment transaction.

Displaying stale payment status could be dangerous.

Similarly, an old stock price, property availability status, product price, ticket price or exchange rate may become misleading depending on the context.

Therefore, the gadget should have a data freshness policy.

For every external data source, define:

  • How frequently the information normally changes

  • How long cached data remains acceptable

  • When data becomes stale

  • Whether stale data can still be displayed

  • When the gadget must hide the information completely

For example:

Data typePossible stale-data treatment
WeatherShow recent cached data with timestamp
Blog articlesCached data may remain useful for longer
Product descriptionsUsually safe to cache
Product pricesClearly show last update
Exchange ratesShow timestamp and stale warning
Live sports dataStale data should be clearly identified
Property availabilityVerify before presenting as currently available
Payment statusDo not treat old status as current confirmation
MapsMay fall back to a basic location message
Social-media statisticsShow last successful update

The correct policy depends on how quickly the underlying information can change and what harm could result from showing outdated information.

Use a Friendly Error Message

The visitor usually does not need to know the technical details.

Messages such as:

HTTP 503 Service Unavailable

or:

AxiosError: Network Error

may be meaningful to developers but are not useful to most visitors.

Instead, translate technical failures into understandable language.

Better examples

For weather:

Weather information is temporarily unavailable. Please try again shortly.

For exchange rates:

We couldn't retrieve the latest exchange rate. Please try again later.

For product information:

Product information is temporarily unavailable. Please check again in a moment.

For maps:

The map could not be loaded. Please try again or use the location details below.

For music statistics:

Live listening information is temporarily unavailable. Please check again shortly.

The message should be short, honest and actionable.

Give the Visitor a Recovery Option

A good error state should not simply say:

Something went wrong.

Then stop.

If retrying makes sense, provide a Retry button.

For example:

Live information is temporarily unavailable.
Please try again.
[Retry]

When the visitor clicks Retry, the gadget should make another request.

However, the Retry button itself needs protection against abuse.

A visitor should not be able to click it 500 times per second and generate hundreds of API requests.

The gadget can use:

  • Button disabling during the request

  • Debouncing

  • Rate limiting

  • Minimum retry intervals

  • Exponential backoff

  • Server-side request controls

The gadget should make retrying easy without making the external service's problem worse.

Automatic Retry Can Also Be Useful

Some failures are temporary.

Instead of forcing the visitor to refresh the page, the gadget can automatically retry after a short delay.

For example:

Attempt 1: immediately

Attempt 2: after a few seconds

Attempt 3: after a longer delay

If the service recovers, the gadget can silently restore the live information.

This is commonly handled using exponential backoff.

Instead of sending requests continuously, the system gradually increases the waiting period between attempts.

This protects both your gadget and the external service.

Do Not Keep Retrying Forever

Automatic retry sounds useful, but unlimited retrying is a bad design.

Imagine that an API is offline for two hours and your website has 10,000 visitors.

If every visitor's browser continuously retries every second, your gadget could generate an enormous number of unnecessary requests.

A better strategy is:

Attempt → wait → retry → wait longer → retry → stop or enter fallback mode.

The gadget can then display:

Live updates are temporarily unavailable. We'll try again later.

This is much more efficient.

Different API Failures Should Produce Different Behaviour

Not every error means the same thing.

Temporary server outage

The external service is having a problem.

Possible response:

Live data is temporarily unavailable.

Allow retrying and possibly use cached data.

Network timeout

The request took too long.

Possible response:

The connection is taking longer than expected. Please try again.

Rate limit

Too many requests have been made.

The system should usually reduce requests rather than repeatedly retrying.

Possible visitor message:

Live updates are temporarily unavailable. Please check again shortly.

The technical system should log the rate-limit event so the developer can investigate request volume.

Authentication failure

An API key or access token may have expired or become invalid.

This is primarily a developer/system problem.

The visitor generally does not need to see:

Invalid API key.

Instead:

This service is temporarily unavailable. Please try again later.

The developer's monitoring system should record the actual technical error.

Invalid response

The API may technically respond but return malformed or unexpected data.

The gadget should validate the response before displaying it.

If validation fails, show a safe fallback instead of inserting broken data into the page.

Never Expose API Keys or Internal Technical Details

This is especially important for Blogger and other client-side websites.

Suppose the gadget connects to an external API.

It may be tempting to place an API key directly inside JavaScript:

const API_KEY = "YOUR_SECRET_KEY";

That can expose the credential to anyone who examines the page source or browser requests.

A safer architecture is often:

Visitor → Gadget → Your backend/API layer → External API

Your backend can hold sensitive credentials and communicate with the external provider.

The gadget receives only the information it needs.

This also gives you more control over:

  • Authentication

  • Rate limiting

  • Caching

  • Validation

  • Logging

  • Provider changes

  • Error handling

  • Usage monitoring

The Gadget Should Have a Fallback Hierarchy

A useful architecture is to define what happens as each level fails.

For example:

Level 1 — Live API

Try to retrieve current information.

If successful:

Display live information.

If unsuccessful:

Level 2 — Cached information

Check whether a recent successful response exists.

If acceptable:

Display cached information + timestamp.

If not:

Level 3 — Graceful fallback

Display useful static or alternative information.

If no useful fallback exists:

Level 4 — Clear unavailable state

Tell the visitor that the service is temporarily unavailable.

This gives the gadget a predictable failure strategy.

Example: A Property Listing Gadget

Imagine a real-estate gadget displaying available properties.

Normally it retrieves listings from a database or external service.

A property disappears from the external system temporarily.

A weak gadget might show:

No properties found.

That can be misleading.

The problem may not be that there are no properties. The problem may simply be that the service could not be contacted.

Instead, the gadget should distinguish between:

No results

and:

Unable to retrieve results.

For example:

We couldn't load the latest property listings. Please try again.

This distinction is extremely important.

"No properties found" is a data result.

"Unable to load properties" is a system failure.

They are not the same thing.

Example: A Music Gadget

Suppose a website gadget displays:

12 people listening now

The gadget gets its active-listener information from a backend service.

If the service stops responding, the gadget should not continue showing "12 people listening now" indefinitely.

That number may no longer represent current activity.

Instead, it could display:

Live listener information temporarily unavailable.

If a recent count is retained, it could say:

12 listeners — last updated 1 minute ago

provided that the timestamp is accurate and the stale-data policy allows it.

This is much more trustworthy than displaying an old number as though it were current.

What About Payments?

Payment-related gadgets require a much stricter approach.

Suppose a visitor pays for a digital product and the payment service temporarily stops responding.

The gadget should not tell the customer:

Payment successful

unless the system has actually received reliable confirmation.

A temporary failure should instead produce something like:

We couldn't confirm your payment yet. Please don't submit the payment again until we check the transaction status.

The exact wording should depend on the payment provider and transaction architecture.

Payment systems should use server-side verification, transaction IDs and idempotency mechanisms so that a retry does not accidentally create duplicate transactions.

In payment-related systems, "uncertain" is different from "failed."

That distinction should be reflected in the interface.

The Gadget Should Tell Visitors When Information Is Stale

Whenever freshness matters, timestamps are extremely valuable.

Instead of:

USD/KES: 129.40

consider:

USD/KES: 129.40
Updated 4 minutes ago

And if the API fails:

USD/KES: 129.40
Last updated 4 minutes ago
Live update temporarily unavailable

The visitor now has context.

The timestamp also prevents an old value from being mistaken for a current one.

Use Different Visual States

A well-designed gadget can visually distinguish different states without becoming complicated.

For example:

Loading

Loading information…

Success

Current information displayed.

Stale

Last updated 10 minutes ago.

Temporary failure

Live information temporarily unavailable.

No data

No information is currently available.

Retry

[Try Again]

The exact design can vary, but the principle remains the same:

The visitor should always understand what the gadget currently knows and what it does not know.

What Should Be Logged Behind the Scenes?

The visitor-facing message should be simple.

The developer-facing logs should be detailed.

When an API fails, the system can record:

  • Gadget ID

  • API/provider

  • Endpoint

  • Timestamp

  • HTTP status

  • Error category

  • Response time

  • Number of retry attempts

  • Visitor/session context where appropriate

  • Whether cached data was served

  • Whether the request eventually recovered

For example:

Gadget: Currency Converter
Provider: Exchange API
Time: 10:42:18
Failure: Timeout
Retry: 1
Fallback: Cached response
Cache age: 4 minutes

This allows you to diagnose problems without exposing technical information to visitors.

Build an Error State Before You Build the Gadget

One of the most useful development practices is to design failure states before the gadget is finished.

For every external dependency, ask:

What happens if it is unavailable?

Then define:

  • Loading state

  • Success state

  • Empty state

  • Error state

  • Timeout state

  • Rate-limit state

  • Stale-data state

  • Retry behaviour

  • Recovery behaviour

This turns failure handling into part of the product design rather than something added after the gadget breaks.

A Practical API Failure Specification

Before launching a gadget, you can create a simple specification like this:

SituationWhat visitor seesSystem behaviour
API loadingLoading messageWait for response
API succeedsCurrent informationStore/cache if appropriate
API timeoutTemporary unavailable messageRetry according to policy
API outageService unavailableUse fallback if safe
Cached data availableCached data + timestampMark as stale when necessary
No cached dataClear unavailable messageDo not invent data
Rate limitTry again laterSlow down requests
Authentication errorGeneric service messageAlert developer/admin
Invalid API responseUnable to load informationReject invalid data
Service recoversCurrent informationReplace stale data

This table can become part of the gadget's technical specification.

The Golden Rule: Never Pretend the Gadget Knows Something It Doesn't Know

This is perhaps the most important principle.

If the API is unavailable, do not invent information.

If the last successful update was 30 minutes ago, do not label it "live."

If the payment has not been confirmed, do not call it successful.

If property data cannot be retrieved, do not tell the visitor there are no properties.

If listener statistics are unavailable, do not continue presenting an old number as current.

A trustworthy gadget clearly communicates the difference between:

Current information

Previously retrieved information

Unavailable information

and

Unknown information.

That distinction protects both the visitor and the credibility of the website.

Designing Gadgets for Failure Makes Them Stronger

External APIs are incredibly useful because they allow a simple website gadget to access information and services far beyond the website itself.

But every external dependency introduces another possible point of failure.

The answer is not to avoid APIs.

The answer is to design the gadget so that API failures are expected, contained and understandable.

A strong gadget should therefore have:

  • A clear loading state

  • A clear success state

  • A useful empty state

  • A friendly error state

  • A retry mechanism where appropriate

  • Caching where appropriate

  • Clearly labelled timestamps

  • Sensible retry limits

  • Server-side protection

  • Secure API credentials

  • Detailed internal logging

  • A defined fallback strategy

  • Accurate recovery behaviour

The visitor should never have to understand your API architecture to use the gadget.

They simply need to know three things:

Is the information available?

How current is it?

What should I do next?

When those three questions are answered clearly, an external service outage does not have to become a poor user experience.

It becomes simply another state that the gadget knows how to handle.

No comments:

Post a Comment

We value your voice! Drop a comment to share your thoughts, ask a question, or start a meaningful discussion. Be kind, be respectful, and let’s chat!

Shop Smart, Save Big; Why you should Shop on Jumia Today

Looking to upgrade your home appliances, grab the latest smartphone, restock everyday groceries, or refresh your wardrobe without stretchin...