Api2Pdf launches v2 in beta!

January 11th, 2020 / by api2pdf /

Welcome everybody, this is a follow up to our post six months ago. We are very excited to give you an update and to announce the launch of version 2 of API2PDF, now in early access beta.

The documentation is available here.

Version 2 currently only has our Headless Chrome endpoint. We will be migrating our other endpoints (wkhtmltopdf, merge, zebra, libreoffice) in the coming months. Pricing is slightly different – We have removed the cost for bandwidth intake (only mb out is factored in), but increased the cost of computation time. For most customers, we imagine it’ll be a wash, but you may want to do some testing.

Pricing is $0.001 per mb generated + $0.00009551 per second of computation.

There is no change to the cost of v1.

Do I have to migrate from v1 to v2?

No, v1 will be maintained in coordination with v2 for the foreseeable future, but all new bells and whistles will be added to v2.

What’s New on Version 2?

  • Headless Chrome now supports both PDFs and Screenshots / Images!
  • Headless Chrome has a new delay attribute in its options. Specified in milliseconds, you can tell api2pdf to wait for that period of time for the page to render before taking the PDF and screenshot. This is useful if you have a lot of javascript on the page that manipulates the UI.
  • Headless Chrome w/ Puppeteer options added in. You will find puppeteerWaitForMethod and puppeteerWaitForValue options. See docs for details.
  • The URL to PDF and URL to Image endpoints now support an extraHTTPHeaders attribute. Pass in a JSON dictionary of key-values to include as headers to the URLs API2PDF will visit. This is useful if your page is behind an authentication.
  • All endpoints now support useCustomStorage attribute. If you set this value to true, then you need to include the storage JSON object. By default, it will assume a PUT with no extraHTTPHeaders, so the only required attribute is a URL. This should be a URL that api2pdf will upload the resulting file to. This is immensely helpful if you do not want to store any data on API2PDF servers, even if just for a second or so.

Are there any updated SDKs for v2?

Not yet, just the REST API, no client SDKs. After all endpoints are migrated, we’ll work on the client libraries. But these rest calls are super easy.

Where do I report a bug or issue?

This is an early access beta for those who were itching for these new Headless Chrome features. If you run into a bug or problem with the API, please email support@api2pdf.com. Thanks!

What is the v2 Infrastructure?

Version 2 is not running AWS Lambda! We have done a lot of work on our docker container and AWS Lambda does not support the running of docker containers. They might one day. We looked into Azure and the technologies offered there.

Our first experimentation was with Azure Kubernetes and Azure Container Instances. Unfortunately it takes 45 seconds to spin up a new Azure Container Instance after it has detected that a scaling event is required. This is too slow for us. Api2Pdf has a strange scaling requirement in that it must handle “burst scale”. We might be cruising along at a nice 10 PDFs per second on average, but it needs to scale to handle 1000 PDFs in an instant and then go away. This is a little different than a traditional web application that has scaling events that grow over minutes.

Azure announced a new version of Azure Functions called Azure Premium Functions, which supports Docker Containers! We experimented with this last month and ultimately it does not scale fast enough at a reasonable cost to meet our needs.

What we really want is the best of both worlds. Run a docker container, but at AWS Lambda scale and pricing. Google has demonstrated they are committed to being a force in the Cloud Provider space. Turns out, they recently released a new product called Google Cloud Run that is exactly as we want. Run a container, priced and scales like AWS Lambda.

We migrated our Azure Function docker container to Google Cloud Run (that’s a blog post by itself) and that is where v2 is currently living today.

We look forward to your feedback!

Comments are closed.