MOBI to EPUB

Convert MOBI to EPUB Online

MOBI file is a Mobipocket eBook file used for storing digital books and is designed specifically for mobile devices with low bandwidth. On the other end, EPUB is widely supported across all platforms whilst MOBI is predominantly a Kindle format. Furthermore, the most significant advantage is that such ebooks are created in a format that changes shape according to the device you read them. In this article, we are going to discuss the steps on how to convert MOBI to EPUB using .NET REST API.

MOBI File Conversion API

Aspose.Words Cloud is developed to facilitate operations like creating, editing, merging, splitting, comparing, and converting a Word document in the Cloud. It also supports the feature to handle eBook formats including MOBI and EPUB. The .NET SDK is available for download at NuGet and GitHub. So in order to use the SDK, we need to execute the following command to install it via NuGet.

nuget install Aspose.Words-Cloud

In case you need to install from NuGet Package Manager, please execute the following command:

PM> Install-Package Aspose.Words-Cloud

The next important step is to create a free subscription account by visiting Aspose.Cloud dashboard. Use your existing GitHub or Google account or simply Sign Up while Creating a new Account. Login to the dashboard and obtain the Client Credentials.

Convert MOBI to EPUB in C#

Please visit the following details to perform MOBI format conversion to EPUB using the C# .NET code snippet.

  • Create Configuration object while providing Client ID and Client Secret details
  • Secondly, create an instance of WordsApi class that takes a Configuration object as an argument
  • Thirdly, initialize an object of UploadFileRequest class which takes the input MOBI file stream instance as an argument
  • Now upload the input file to Cloud storage using the UploadFile(..) method of WordsApi
  • The next step is to create an object of GetDocumentWithFormatRequest while providing an input file, the resultant format and resultant file names are arguments
  • Finally, call the GetDocumentWithFormat(..) method to perform the conversion operation. The output file is saved in Cloud storage
Mobi to EPUB Preview

Image 1:- MOBI to EPUB Conversion Preview.

The sample files used in the above example can be downloaded from famouspaintings.mobi and converted.epub.

MOBI to EPUB conversion using cURL command

We can also use the cURL commands to access Aspose.Words Cloud API. Now as a pre-requisite, we need to first generate a JSON Web Token (JWT) based on ClientID and ClientSecret details retrieved from Aspose.Cloud dashboard. Please execute the following command in the terminal to generate the JWT token.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=4ccf1790-accc-41e9-8d18-a78dbb2ed1aa&client_secret=caac6e3d4a4724b2feb53f4e460eade3" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Now that we have got the JWT access token, we need to upload the input MOBI file to cloud storage using the following command. If the content is multipart and we do not provide the file name, it tries to get them from the filename parameter from the Content-Disposition header.

curl -X PUT "https://api.aspose.cloud/v4.0/words/storage/file/famouspaintings.mobi" \
-H  "accept: application/json" \
-H  "Authorization: Bearer <JWT Token>" \
-H  "Content-Type: multipart/form-data" \
-d {"fileContent":{}}

Finally, execute the following command to convert MOBI to EPUB and save the resultant file in Cloud storage.

curl -X GET "https://api.aspose.cloud/v4.0/words/famouspaintings.mobi?format=EPUB&outPath=conveted.epub" \
-H  "accept: application/octet-stream" \
-H  "Authorization: Bearer <JWT Token>"

Conclusion

In this blog, we have explored the capabilities of converting MOBI kindle files to EPUB format using C# .NET. We have also learned the steps to develop a MOBI file reader using cURL commands. The API can also be tested using the swagger interface.

Please note that all our Cloud SDKs are distributed under an MIT license, therefore the complete code snippet for Aspose.Words Cloud SDK for .NET can be downloaded from GitHub. In case you encounter any issues or have any queries while using the API, please feel free to contact us through the Free product support forum.

We also recommend visiting the following links to learn more about