What do you mean by "available"?
Let's begin by assuming that you don't mean kernel memory that will be used by the kernel for tasks on your behalf (like your network traffic, or bounce buffers for you IOs). Let's also assume that you don't mean buffer cache that will be used for write-behind or read caching of file IO you are doing. Let's assume that you mean only memory that can be used by running applications.
Do you mean stack or heap? Honestly, I have no idea how to determine how much stack space you have, programmatically, other than by trial and error. Heap space is hard. First, there are various limits that can be applied to a running program (such as ulimit). Then, you can typically allocate a lot with sbrk() and malloc(), as long as you don't actually touch the pages. And then, the number of pages you actually touch depends on whether you want to count only resident memory, or also shared libraries, mmap()'ed files, and memory that is currently swapped out.
Please explain what you are really trying to accomplish. This thing sounds like a "XY problem".