Surfaces API Overview
The Surfaces API is a low-latency solution for retrieving personalized content to display in your application. This is typically an app or website, but could be any application.When you make a request to the Surfaces API for one of your users, the API will respond with the recommended content to display to that user for each specified surface.
- If you’d like a refresher on the Surfaces product, read our User Guide overview.
- For instructions on calling the Surfaces API, see our API documentation.
App Integration
The Surfaces API integrates into your application in one of two ways:- Real time
- Pre-fetched and cached
Real Time
- How it works: your application calls the Surfaces API whenever a page loads with Aampe-generated content

- Advantages: simple to implement, and you only make calls only when needed
-
Disadvantages: potentially higher latency from calling out to an external service
A common technique used when implementing this approach is to display a spinner or a skeleton screen while the data is loading.
Periodically Cached
- How it works: your application calls the Surfaces API and caches the results, then pulls content from the cache whenever a page loads with Aampe-generated content

- Advantages: no latency risk, can implement retries and other backups
- Disadvantages: some extra work to maintain a fresh cache of content
Real Time vs Cached
| Cached | Real Time | |
|---|---|---|
| Call Type | Background call, on app open | Blocking call, on component rendering |
| Batching | Get content for several surfaces at once | One or more surfaces at a time |
| Timeout | Longer timeout options | Shorter timeout |
| Retrying | Time to retry in case of network issues | Not recommended |
| Fallback | Static content in case of failed retries, timeouts, or API returning 404 | Static content in case of failed retries, timeouts, or API returning 404 |
| Control | App controls if, what, when to render | App or Aampe can control if, what, when to render |
| Tracking | App is responsible for propagating a unique id to tracking event metadata | Aampe can approximate tracking without extra instrumentation |
Surface API Latency
Latency SLA
The Surfaces API comes with a Service Level Agreement of P95 round trip latency of <=150ms for requests originating from within the same region as the API.Reducing Latency
We recommend the following steps to reduce latency within your app when interacting with the Surfaces API- Pre-fetch surface content, when possible
- Include multiple surface IDs when calling the Surface API
- Enforce strict timeouts such that the page will load with default content in the rare cases where the API takes longer than expected to respond
- Call the Surfaces API from within the same geographic region as the service calling the API.
Multi Region Deployments
To minimize latency, we recommend locating your Surfaces API deployment in the same geographic region as the service from which you will be calling the API. For instance, if your application backend runs in theus-east1 region, we can locate your Surfaces API deployment within the same region. Differences between cloud provider regions may impact our ability to directly match your region, but we will locate it as close as possible.
When calling the Surfaces API, you will include the region identifier in the URL. For example, if you are using the asia-southeast1 region, you will make calls to https://content.asia-southeast1.api.aampe.com.
Work with your customer success manager to ensure your Surfaces API deployment is located in the correct region.
Fallback Content
In cases where the Surfaces API does not have any content to show a user for a specific Surface (e.g. if the user isn’t eligible for any of the content defined on that Surface), it’s important to define fallback content, so you still have something to show the user. Fallback content should be defined within your application. If no content is available for a givencontact_id and surface_id, the API will return a 404 response.
Configuration Options
The Surfaces API response contains acontrol key which includes values you can use to govern how frequently specific Surface content is displayed in your application.
min_gap_days:minimum number of days between surface content viewsmax_displays_per_day:maximum number of personalized surface displays per daydisplay_every_x_times:a rule to show personalized surface content every X page loads (otherwise, the surface loads with fallback content).