Skip to main content
Version: 4.55.1

Remote Service Module

The Remote Service Module allows you to obtain data from external APIs and use them in your Lenses. In order to get started simply navigate to the Asset Library and import the remote service module for the API you’d like to use.

If you have ideas around APIs that you’d like to build AR Lenses with, be it your own APIs or those of other third party partners, please get in touch. Your input helps inform Snap’s product team on what we should be building to support our Lens Creator Community. We look forward to hearing from you!

Then, you can use the remote service modules scripting API to call the various endpoints of that API.

Templates

You can view the templates for the APIs in the library to access helpful utilities and examples of how to use each API.

Example

Here is an example of how you can call to a Remote Service Module.

var req = global.RemoteApiRequest.create();
req.endpoint = 'ENDPOINT_NAME';
script.remoteServiceModule.performApiRequest(req, function (response) {
handleAPIResponse(response);
});

Best Practices When Utilizing a Third-Party Remote API

Remote APIs in Lenses are a way to expand Lens functionality by calling a third-party service. However, if not optimized and thoughtfully planned, this technology can cause latency and can cause memory limitations. Below are some best practices to ensure the best possible user experience.

  1. Read the third party API documentation and correlate those with your Lens concept.
    1. Identify endpoints. For example, the Sportradar API has an API map that shows data flow.
  2. Choosing the right API to use is important. Consider the size of the data response. In general, try to use the minimum number of API calls to endpoints that return the least amount of data.
    1. If over 800 KB, there is probably a different endpoint you can use or try configuring parameters to reduce the size.
    2. If not able to reduce the size or the API calls take too long to finish, contact Lens Studio Support
  3. Before you start to build the actual Lens, call the API endpoints with a simple script in Lens Studio to make sure they work properly. This will save debugging time later on.

Do’s

  • Anticipate high latency. Ensure there is an intro experience or that there is meaningful content that loads immediately in order to give the API time to load. This way, the Snapchatter does not have to wait and the experience begins immediately.
  • When receiving errors while developing with APIs, reference the error descriptions to see what needs to be fixed. Here are some common error codes.

Don’ts

  • Don’t make too many API calls at the same time. We recommend no more than three, but try to keep it to only one if possible.
  • Don’t utilize APIs for fetching images dynamically. Use Remote Assets for this purpose by authoring them at time of Lens creation.

Restrictions

When using a remote service module, some APIs will be restricted in order to protect the user’s privacy. The following APIs will be disabled:

Please note: You may not add sports leagues logos, team logos, trademarks, or any other league, player, team, or related intellectual property (including statistics) to your lens unless you have all necessary legal rights to use such elements. Failure to secure such rights may result in takedowns or other legal liability to you.

Was this page helpful?
Yes
No