I have found a draw tool in OpenLayers-3 which allows us to draw on a map (see http://openlayers.org/en/v3.2.0/examples/draw-features.html). Is there an API in openlayers to store the drawn feature in geojson format?
You can use ol.format.GeoJSON to write out your feature as GeoJSON, and then use any AJAX / XHR library to get it back to your server.
See also this example which uses EsriJSON but the concepts are the same:
Further to the answer above, this is how I'm grabbing the draw features before storing them in an indexed db for offline storage:
// declare vars to populate later var routetitle, routeDescription, routeFeatures, routeScreenshot, routePNG, tags; // THIS IS THE IMPORTANT BIT var allFeatures = drawLayer.getSource().getFeatures(); var format = new ol.format.GeoJSON(); var routeFeatures = format.writeFeatures(allFeatures);
If you then console log(routeFeatures it should give you a JSON Feature Collection