Is there an API that counts the number of pages in a PDF file?

Does anyone know of an API that counts how many pages are in a pdf file?

Or possibly a workflow I can create that counts how many pages are in a pdf file that a user has uploaded.