We show how first and second law of thermodynamics can be formulated for a Markov process including the effect of fluctuations and applicable far from equilibrium. Next we formulate stochastic thermodynamics at the trajectory level and derive the detailed and integral fluctuation theorems.