I believe you are mistaken in your understanding of asm.js.
First off, from their FAQ
Q. Is asm.js a new language?
A. No, it's just (a subset of) JavaScript.
And you asked clarification added :
But how is it possible to write one [an asm.js application] in C++
You don't write an "asm.js application", rather asm.js is a target1 to compile your C++ code to.
This article by John Resig provides a number of details that may better explain how asm.js would be used.
Starting with this image:

you can see that asm.js is a translation target of emscripten. Emscripten handles translating the LLVM bytecode into JavaScript, and asm.js is a subset of JavaScript. Staying within asm.js' restricted subset of JavaScript allows the code to be optimized and run faster.
You also asked:
And if I write the code in C++, then how to use the js API-s
Again, you're kind of missing the point. Asm.js enables porting existing C/C++ applications into JavaScript so they can be run within a browser. You wouldn't normally be able to use JS APIs within your C/C++ code, and there's nothing magical about asm.js to allow that.
If you have a new application to write that needs JS APIs then you should write the application in JS and not futz with trying to write in C++ and then port to JavaScript.
And going back to Resig's article, there are two key quotes for your question:
the kind of applications that are going to target Asm.js, in the near future, are those that will benefit from the portability of running in a browser but which have a level of complexity in which a direct port to JavaScript would be infeasible
and
As you can probably see from the code above Asm.js isn’t designed to be written by hand. ... The most common use case for Asm.js right now is in applications complied from C/C++ to JavaScript. Almost none of these applications interact with the DOM in a meaningful way, beyond using WebGL and the like.
What you might want to consider doing instead is having a JavaScript program that calls the JS APIs that you need along with making calls to the C++ that you compiled to JavaScript. Have a look at this emscripten tutorial to see how to call C++ code from JavaScript.
For some additional research, emscripten has a tutorial that might help you get started with understanding how to take C++ code, run it through LLVM, and then target asm.js.
1Strictly speaking, that's not true. The C/C++ code is unaware of what it's going to be compiled to, so I can't really call asm.js a target. Another tool (emscripten) takes the LLVM output and then translates to asm.js compliant JavaScript. But I'm going to call it a target because it's easier to understand.