I believe that due to the difficulty in the performance of such a web service (API), there are very few suppliers offering automation functions for converting video to GIF via the REST API.
However, recently I found myself in a similar situation, did some research and came across two API products that could do the job for you:
giflayer API
This is one REST API designed to convert videos to GIF animations. It works for both video URLs and portals such as YouTube , and direct links to videos, such as http://website.com/video.mp4 .
Here's how you make an API request:
https://apilayer.net/api/capture ? access_key = YOUR_ACCESS_KEY & url = https://www.youtube.com/watch?v=3W6hZR29l5o & start = 170 & duration = 1.5
Then after a few seconds, the API directly returns your GIF animation according to the parameters specified in the request:

This is what there is now a second service that can meet the requirements mentioned above:
- gfycat
Until they create real GIFs, they complement them by converting to HTML5 video, which is lighter in size. Just include this link if you are still not sure if this is the GIF transform you need.
Hope I can help.
source share