Does ezgif have an API?
No, at least not an official and supported one. However, I am aware that some people use automated requests to ezgif, for example, to convert images in chatbots. I am okay with this as long as they don't generate an excessive number of requests that could slow down the service for other users. I don't intentionally make it difficult, but I also cannot guarantee that this method won't break if I ever decide to make updates on the site.
In general, I recommend that people install ImageMagick, FFmpeg, or Gifsicle locally for scripted or batch tasks. They are free open-source tools and can perform everything that ezgif does and much more. To me it makes more sense than using code for sending the files over the Internet to some free website designed for end users who can't or don't want to use command line tools directly.