Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Read an external API in After Effects

Community Beginner ,
Jun 25, 2021 Jun 25, 2021

Copy link to clipboard

Copied

Hi, 

 

Is there a way to read an external API to load JSON sports data into After Effects?

Maybe via an easy extendscript? A load button than imports the data.

 

The manual way is to download the JSON file and replace footage.

 

Thanks

Matthias

TOPICS
Dynamic link, Expressions, Import and export, Scripting

Views

119

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 25, 2021 Jun 25, 2021

Copy link to clipboard

Copied

You can do this by scripting a CEP panel, but you can also use the Templater plugin from Dataclay to work with API data pretty easily.  You point Templater to the API's end-point that responds with JSON object arrays and the values can be mapped to specific layers quite easily.

 

There is documentation about using URL Feeds with Templater as well.  Many users in the Sports-tech world use Templater + AE in their workflow to save time.  You can preview the data live within comps.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 28, 2021 Jun 28, 2021

Copy link to clipboard

Copied

Hi Arie,

 

I've tried the Dataclay Templater. It doesn't fetch the data because the URL is behind a protected login. Any tips for that?

 

Thanks

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 30, 2021 Jun 30, 2021

Copy link to clipboard

Copied

LATEST

If the API is behind basic authentication scheme, you can enter the username and password into the "Remote JSON Configuration" dialog.  If it requires some kind of OAuth token, then you would need to see what the headers look like from another application that are required to make that request and then get those headers into the "Optional Request Headers".  For example, if there was an "Authorization" header that look liked

 

"Authorization" : "Bearer <long token here>"

 

In each request that was authorized, you can take that value and paste it onto a new line in the "Optional Request Headers" field.  In this case, you would write on one line:

Authorization : Bearer <long token here> 

 

Screen Shot 2021-06-30 at 1.29.06 PM.png

 So essentially, you login via your normal app, maybe a browser, and then look at how that browser is making requests, and try to emulate that via the Optional Headers in Templater's Remote JSON configuration dialog.  It's not ideal, and is hacky because once the token you grabbed from the authenticated app expires, you would have to change it once more.  However, this is the best that can be done given that each API will always have a different method for authentication and authorization.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 30, 2021 Jun 30, 2021

Copy link to clipboard

Copied

You can use the built-in Socket object in After Effects, but it's pretty complicated with hardly any documentation. Check out this library for making HTTP requests:

 

https://github.com/buraktamturk/adobe-javascript-http-client

 

Once you've included that library, making HTTP requests are pretty straightforward:

 

var data = $http({

   method: 'GET',

   url: 'example.com/

   headers: {'Accept': 'application/json','Content-Type': 'application/json'} });

alert(data.payload);

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines