Actually, QGIS API Documentation (and maybe many API Docs) is written in C++ terminology. At first, users who don't know about C++ find it hard to understand API Docs. However, over time it's getting easier. Sometimes, documentation which is written in Python terminology may not contain enough information about library. And getting used to C++ terminology is inevitable.
Let me answer your questions briefly:
- Here are three identical(?) functions listed?
It means that you can use
writeAsVectorFormat in three different ways with different parameters for different goals. Such functions are called overloaded functions, and normally, you don't need such functions in Python and they come from C++.
- Which variables are mandatory and which are optional?
If any parameter definition doesn't include 'equal sign (=)', i.e.
fileEncoding in following lines, it is mandatory. Which includes 'equal sign' is optional, i.e.
driverName and if you don't specify, value next to it will pass to function by default, for example
QgsVectorFileWriter::writeAsVectorFormat (QgsVectorLayer * layer,
const QString & fileName,
const QString & fileEncoding,
const QgsCoordinateReferenceSystem &
destCRS = QgsCoordinateReferenceSystem(),
const QString & driverName = "GPKG",
QgsCoordinateReferenceSystem etc. are data types, and parameters which you pass to function have to match them. That's,
layer has to be an instance of
fileNamehas to be a
string and so on. If they don't match, you encounter an error as in QgsVectorFileWriter.writeAsVectorFormat differents Qgis2.xx Qgis3.XX.
There is a book I'd like to recommend: Building Mapping Applications with QGIS. It contains a chapter gives an extensive explanation about QGIS API.